Qbservable.Generated.cs 1.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851
  1. /*
  2. * WARNING: Auto-generated file (1/10/2013 8:30:32 PM)
  3. * Run Rx's auto-homoiconizer tool to generate this file (in the HomoIcon directory).
  4. */
  5. #pragma warning disable 1591
  6. #if !NO_EXPRESSIONS
  7. using System;
  8. using System.Reactive.Concurrency;
  9. using System.Collections.Generic;
  10. using System.Reactive.Joins;
  11. using System.Linq;
  12. using System.Linq.Expressions;
  13. using System.Reflection;
  14. using System.Threading;
  15. using System.Reactive;
  16. using System.Reactive.Subjects;
  17. #if !NO_TPL
  18. using System.Threading.Tasks;
  19. #endif
  20. #if !NO_REMOTING
  21. using System.Runtime.Remoting.Lifetime;
  22. #endif
  23. namespace System.Reactive.Linq
  24. {
  25. public static partial class Qbservable
  26. {
  27. /// <summary>
  28. /// Applies an accumulator function over an observable sequence, returning the result of the aggregation as a single element in the result sequence.
  29. /// For aggregation behavior with incremental intermediate results, see <see cref="M:System.Reactive.Linq.Observable.Scan``1(System.IObservable{``0},System.Func{``0,``0,``0})" />.
  30. /// </summary>
  31. /// <typeparam name="TSource">The type of the elements in the source sequence and the result of the aggregation.</typeparam>
  32. /// <param name="source">An observable sequence to aggregate over.</param>
  33. /// <param name="accumulator">An accumulator function to be invoked on each element.</param>
  34. /// <returns>An observable sequence containing a single element with the final accumulator value.</returns>
  35. /// <exception cref="T:System.ArgumentNullException">
  36. /// <paramref name="source" /> or <paramref name="accumulator" /> is null.</exception>
  37. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  38. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  39. public static IQbservable<TSource> Aggregate<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, TSource, TSource>> accumulator)
  40. {
  41. if (source == null)
  42. throw new ArgumentNullException("source");
  43. if (accumulator == null)
  44. throw new ArgumentNullException("accumulator");
  45. return source.Provider.CreateQuery<TSource>(
  46. Expression.Call(
  47. null,
  48. #if CRIPPLED_REFLECTION
  49. InfoOf(() => Qbservable.Aggregate<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, TSource, TSource>>))),
  50. #else
  51. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  52. #endif
  53. source.Expression,
  54. accumulator
  55. )
  56. );
  57. }
  58. /// <summary>
  59. /// 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.
  60. /// For aggregation behavior with incremental intermediate results, see <see cref="M:System.Reactive.Linq.Observable.Scan``2(System.IObservable{``0},``1,System.Func{``1,``0,``1})" />.
  61. /// </summary>
  62. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  63. /// <typeparam name="TAccumulate">The type of the result of the aggregation.</typeparam>
  64. /// <param name="source">An observable sequence to aggregate over.</param>
  65. /// <param name="seed">The initial accumulator value.</param>
  66. /// <param name="accumulator">An accumulator function to be invoked on each element.</param>
  67. /// <returns>An observable sequence containing a single element with the final accumulator value.</returns>
  68. /// <exception cref="T:System.ArgumentNullException">
  69. /// <paramref name="source" /> or <paramref name="accumulator" /> is null.</exception>
  70. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  71. public static IQbservable<TAccumulate> Aggregate<TSource, TAccumulate>(this IQbservable<TSource> source, TAccumulate seed, Expression<Func<TAccumulate, TSource, TAccumulate>> accumulator)
  72. {
  73. if (source == null)
  74. throw new ArgumentNullException("source");
  75. if (accumulator == null)
  76. throw new ArgumentNullException("accumulator");
  77. return source.Provider.CreateQuery<TAccumulate>(
  78. Expression.Call(
  79. null,
  80. #if CRIPPLED_REFLECTION
  81. InfoOf(() => Qbservable.Aggregate<TSource, TAccumulate>(default(IQbservable<TSource>), default(TAccumulate), default(Expression<Func<TAccumulate, TSource, TAccumulate>>))),
  82. #else
  83. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)),
  84. #endif
  85. source.Expression,
  86. Expression.Constant(seed, typeof(TAccumulate)),
  87. accumulator
  88. )
  89. );
  90. }
  91. /// <summary>
  92. /// 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,
  93. /// and the specified result selector function is used to select the result value.
  94. /// </summary>
  95. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  96. /// <typeparam name="TAccumulate">The type of the accumulator value.</typeparam>
  97. /// <typeparam name="TResult">The type of the resulting value.</typeparam>
  98. /// <param name="source">An observable sequence to aggregate over.</param>
  99. /// <param name="seed">The initial accumulator value.</param>
  100. /// <param name="accumulator">An accumulator function to be invoked on each element.</param>
  101. /// <param name="resultSelector">A function to transform the final accumulator value into the result value.</param>
  102. /// <returns>An observable sequence containing a single element with the final accumulator value.</returns>
  103. /// <exception cref="T:System.ArgumentNullException">
  104. /// <paramref name="source" /> or <paramref name="accumulator" /> or <paramref name="resultSelector" /> is null.</exception>
  105. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  106. 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)
  107. {
  108. if (source == null)
  109. throw new ArgumentNullException("source");
  110. if (accumulator == null)
  111. throw new ArgumentNullException("accumulator");
  112. if (resultSelector == null)
  113. throw new ArgumentNullException("resultSelector");
  114. return source.Provider.CreateQuery<TResult>(
  115. Expression.Call(
  116. null,
  117. #if CRIPPLED_REFLECTION
  118. InfoOf(() => Qbservable.Aggregate<TSource, TAccumulate, TResult>(default(IQbservable<TSource>), default(TAccumulate), default(Expression<Func<TAccumulate, TSource, TAccumulate>>), default(Expression<Func<TAccumulate, TResult>>))),
  119. #else
  120. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate), typeof(TResult)),
  121. #endif
  122. source.Expression,
  123. Expression.Constant(seed, typeof(TAccumulate)),
  124. accumulator,
  125. resultSelector
  126. )
  127. );
  128. }
  129. /// <summary>
  130. /// Determines whether all elements of an observable sequence satisfy a condition.
  131. /// </summary>
  132. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  133. /// <param name="source">An observable sequence whose elements to apply the predicate to.</param>
  134. /// <param name="predicate">A function to test each element for a condition.</param>
  135. /// <returns>An observable sequence containing a single element determining whether all elements in the source sequence pass the test in the specified predicate.</returns>
  136. /// <exception cref="T:System.ArgumentNullException">
  137. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  138. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  139. public static IQbservable<bool> All<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  140. {
  141. if (source == null)
  142. throw new ArgumentNullException("source");
  143. if (predicate == null)
  144. throw new ArgumentNullException("predicate");
  145. return source.Provider.CreateQuery<bool>(
  146. Expression.Call(
  147. null,
  148. #if CRIPPLED_REFLECTION
  149. InfoOf(() => Qbservable.All<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  150. #else
  151. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  152. #endif
  153. source.Expression,
  154. predicate
  155. )
  156. );
  157. }
  158. /// <summary>
  159. /// Propagates the observable sequence that reacts first.
  160. /// </summary>
  161. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  162. /// <param name="first">First observable sequence.</param>
  163. /// <param name="second">Second observable sequence.</param>
  164. /// <returns>An observable sequence that surfaces either of the given sequences, whichever reacted first.</returns>
  165. /// <exception cref="T:System.ArgumentNullException">
  166. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  167. public static IQbservable<TSource> Amb<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  168. {
  169. if (first == null)
  170. throw new ArgumentNullException("first");
  171. if (second == null)
  172. throw new ArgumentNullException("second");
  173. return first.Provider.CreateQuery<TSource>(
  174. Expression.Call(
  175. null,
  176. #if CRIPPLED_REFLECTION
  177. InfoOf(() => Qbservable.Amb<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  178. #else
  179. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  180. #endif
  181. first.Expression,
  182. GetSourceExpression(second)
  183. )
  184. );
  185. }
  186. /// <summary>
  187. /// Propagates the observable sequence that reacts first.
  188. /// </summary>
  189. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  190. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  191. /// <param name="sources">Observable sources competing to react first.</param>
  192. /// <returns>An observable sequence that surfaces any of the given sequences, whichever reacted first.</returns>
  193. /// <exception cref="T:System.ArgumentNullException">
  194. /// <paramref name="sources" /> is null.</exception>
  195. public static IQbservable<TSource> Amb<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  196. {
  197. if (provider == null)
  198. throw new ArgumentNullException("provider");
  199. if (sources == null)
  200. throw new ArgumentNullException("sources");
  201. return provider.CreateQuery<TSource>(
  202. Expression.Call(
  203. null,
  204. #if CRIPPLED_REFLECTION
  205. InfoOf(() => Qbservable.Amb<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  206. #else
  207. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  208. #endif
  209. Expression.Constant(provider, typeof(IQbservableProvider)),
  210. GetSourceExpression(sources)
  211. )
  212. );
  213. }
  214. /// <summary>
  215. /// Propagates the observable sequence that reacts first.
  216. /// </summary>
  217. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  218. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  219. /// <param name="sources">Observable sources competing to react first.</param>
  220. /// <returns>An observable sequence that surfaces any of the given sequences, whichever reacted first.</returns>
  221. /// <exception cref="T:System.ArgumentNullException">
  222. /// <paramref name="sources" /> is null.</exception>
  223. public static IQbservable<TSource> Amb<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  224. {
  225. if (provider == null)
  226. throw new ArgumentNullException("provider");
  227. if (sources == null)
  228. throw new ArgumentNullException("sources");
  229. return provider.CreateQuery<TSource>(
  230. Expression.Call(
  231. null,
  232. #if CRIPPLED_REFLECTION
  233. InfoOf(() => Qbservable.Amb<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  234. #else
  235. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  236. #endif
  237. Expression.Constant(provider, typeof(IQbservableProvider)),
  238. GetSourceExpression(sources)
  239. )
  240. );
  241. }
  242. /// <summary>
  243. /// Determines whether an observable sequence contains any elements.
  244. /// </summary>
  245. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  246. /// <param name="source">An observable sequence to check for non-emptiness.</param>
  247. /// <returns>An observable sequence containing a single element determining whether the source sequence contains any elements.</returns>
  248. /// <exception cref="T:System.ArgumentNullException">
  249. /// <paramref name="source" /> is null.</exception>
  250. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  251. public static IQbservable<bool> Any<TSource>(this IQbservable<TSource> source)
  252. {
  253. if (source == null)
  254. throw new ArgumentNullException("source");
  255. return source.Provider.CreateQuery<bool>(
  256. Expression.Call(
  257. null,
  258. #if CRIPPLED_REFLECTION
  259. InfoOf(() => Qbservable.Any<TSource>(default(IQbservable<TSource>))),
  260. #else
  261. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  262. #endif
  263. source.Expression
  264. )
  265. );
  266. }
  267. /// <summary>
  268. /// Determines whether any element of an observable sequence satisfies a condition.
  269. /// </summary>
  270. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  271. /// <param name="source">An observable sequence whose elements to apply the predicate to.</param>
  272. /// <param name="predicate">A function to test each element for a condition.</param>
  273. /// <returns>An observable sequence containing a single element determining whether any elements in the source sequence pass the test in the specified predicate.</returns>
  274. /// <exception cref="T:System.ArgumentNullException">
  275. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  276. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  277. public static IQbservable<bool> Any<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  278. {
  279. if (source == null)
  280. throw new ArgumentNullException("source");
  281. if (predicate == null)
  282. throw new ArgumentNullException("predicate");
  283. return source.Provider.CreateQuery<bool>(
  284. Expression.Call(
  285. null,
  286. #if CRIPPLED_REFLECTION
  287. InfoOf(() => Qbservable.Any<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  288. #else
  289. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  290. #endif
  291. source.Expression,
  292. predicate
  293. )
  294. );
  295. }
  296. /// <summary>
  297. /// Computes the average of an observable sequence of <see cref="T:System.Decimal" /> values.
  298. /// </summary>
  299. /// <param name="source">A sequence of <see cref="T:System.Decimal" /> values to calculate the average of.</param>
  300. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  301. /// <exception cref="T:System.ArgumentNullException">
  302. /// <paramref name="source" /> is null.</exception>
  303. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  304. /// <exception cref="T:System.OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="M:System.Decimal.MaxValue" />.</exception>
  305. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  306. public static IQbservable<decimal> Average(this IQbservable<decimal> source)
  307. {
  308. if (source == null)
  309. throw new ArgumentNullException("source");
  310. return source.Provider.CreateQuery<decimal>(
  311. Expression.Call(
  312. null,
  313. #if CRIPPLED_REFLECTION
  314. InfoOf(() => Qbservable.Average(default(IQbservable<decimal>))),
  315. #else
  316. (MethodInfo)MethodInfo.GetCurrentMethod(),
  317. #endif
  318. source.Expression
  319. )
  320. );
  321. }
  322. /// <summary>
  323. /// Computes the average of an observable sequence of <see cref="T:System.Double" /> values.
  324. /// </summary>
  325. /// <param name="source">A sequence of <see cref="T:System.Double" /> values to calculate the average of.</param>
  326. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  327. /// <exception cref="T:System.ArgumentNullException">
  328. /// <paramref name="source" /> is null.</exception>
  329. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  330. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  331. public static IQbservable<double> Average(this IQbservable<double> source)
  332. {
  333. if (source == null)
  334. throw new ArgumentNullException("source");
  335. return source.Provider.CreateQuery<double>(
  336. Expression.Call(
  337. null,
  338. #if CRIPPLED_REFLECTION
  339. InfoOf(() => Qbservable.Average(default(IQbservable<double>))),
  340. #else
  341. (MethodInfo)MethodInfo.GetCurrentMethod(),
  342. #endif
  343. source.Expression
  344. )
  345. );
  346. }
  347. /// <summary>
  348. /// Computes the average of an observable sequence of <see cref="T:System.Int32" /> values.
  349. /// </summary>
  350. /// <param name="source">A sequence of <see cref="T:System.Int32" /> values to calculate the average of.</param>
  351. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  352. /// <exception cref="T:System.ArgumentNullException">
  353. /// <paramref name="source" /> is null.</exception>
  354. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  355. /// <exception cref="T:System.OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue" />.</exception>
  356. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  357. public static IQbservable<double> Average(this IQbservable<int> source)
  358. {
  359. if (source == null)
  360. throw new ArgumentNullException("source");
  361. return source.Provider.CreateQuery<double>(
  362. Expression.Call(
  363. null,
  364. #if CRIPPLED_REFLECTION
  365. InfoOf(() => Qbservable.Average(default(IQbservable<int>))),
  366. #else
  367. (MethodInfo)MethodInfo.GetCurrentMethod(),
  368. #endif
  369. source.Expression
  370. )
  371. );
  372. }
  373. /// <summary>
  374. /// Computes the average of an observable sequence of <see cref="T:System.Int64" /> values.
  375. /// </summary>
  376. /// <param name="source">A sequence of <see cref="T:System.Int64" /> values to calculate the average of.</param>
  377. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  378. /// <exception cref="T:System.ArgumentNullException">
  379. /// <paramref name="source" /> is null.</exception>
  380. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  381. /// <exception cref="T:System.OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue" />.</exception>
  382. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  383. public static IQbservable<double> Average(this IQbservable<long> source)
  384. {
  385. if (source == null)
  386. throw new ArgumentNullException("source");
  387. return source.Provider.CreateQuery<double>(
  388. Expression.Call(
  389. null,
  390. #if CRIPPLED_REFLECTION
  391. InfoOf(() => Qbservable.Average(default(IQbservable<long>))),
  392. #else
  393. (MethodInfo)MethodInfo.GetCurrentMethod(),
  394. #endif
  395. source.Expression
  396. )
  397. );
  398. }
  399. /// <summary>
  400. /// Computes the average of an observable sequence of nullable <see cref="T:System.Decimal" /> values.
  401. /// </summary>
  402. /// <param name="source">A sequence of nullable <see cref="T:System.Decimal" /> values to calculate the average of.</param>
  403. /// <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>
  404. /// <exception cref="T:System.ArgumentNullException">
  405. /// <paramref name="source" /> is null.</exception>
  406. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  407. /// <exception cref="T:System.OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="M:System.Decimal.MaxValue" />.</exception>
  408. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  409. public static IQbservable<decimal?> Average(this IQbservable<decimal?> source)
  410. {
  411. if (source == null)
  412. throw new ArgumentNullException("source");
  413. return source.Provider.CreateQuery<decimal?>(
  414. Expression.Call(
  415. null,
  416. #if CRIPPLED_REFLECTION
  417. InfoOf(() => Qbservable.Average(default(IQbservable<decimal?>))),
  418. #else
  419. (MethodInfo)MethodInfo.GetCurrentMethod(),
  420. #endif
  421. source.Expression
  422. )
  423. );
  424. }
  425. /// <summary>
  426. /// Computes the average of an observable sequence of nullable <see cref="T:System.Double" /> values.
  427. /// </summary>
  428. /// <param name="source">A sequence of nullable <see cref="T:System.Double" /> values to calculate the average of.</param>
  429. /// <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>
  430. /// <exception cref="T:System.ArgumentNullException">
  431. /// <paramref name="source" /> is null.</exception>
  432. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  433. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  434. public static IQbservable<double?> Average(this IQbservable<double?> source)
  435. {
  436. if (source == null)
  437. throw new ArgumentNullException("source");
  438. return source.Provider.CreateQuery<double?>(
  439. Expression.Call(
  440. null,
  441. #if CRIPPLED_REFLECTION
  442. InfoOf(() => Qbservable.Average(default(IQbservable<double?>))),
  443. #else
  444. (MethodInfo)MethodInfo.GetCurrentMethod(),
  445. #endif
  446. source.Expression
  447. )
  448. );
  449. }
  450. /// <summary>
  451. /// Computes the average of an observable sequence of nullable <see cref="T:System.Int32" /> values.
  452. /// </summary>
  453. /// <param name="source">A sequence of nullable <see cref="T:System.Int32" /> values to calculate the average of.</param>
  454. /// <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>
  455. /// <exception cref="T:System.ArgumentNullException">
  456. /// <paramref name="source" /> is null.</exception>
  457. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  458. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  459. /// <exception cref="T:System.OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue" />.</exception>
  460. public static IQbservable<double?> Average(this IQbservable<int?> source)
  461. {
  462. if (source == null)
  463. throw new ArgumentNullException("source");
  464. return source.Provider.CreateQuery<double?>(
  465. Expression.Call(
  466. null,
  467. #if CRIPPLED_REFLECTION
  468. InfoOf(() => Qbservable.Average(default(IQbservable<int?>))),
  469. #else
  470. (MethodInfo)MethodInfo.GetCurrentMethod(),
  471. #endif
  472. source.Expression
  473. )
  474. );
  475. }
  476. /// <summary>
  477. /// Computes the average of an observable sequence of nullable <see cref="T:System.Int64" /> values.
  478. /// </summary>
  479. /// <param name="source">A sequence of nullable <see cref="T:System.Int64" /> values to calculate the average of.</param>
  480. /// <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>
  481. /// <exception cref="T:System.ArgumentNullException">
  482. /// <paramref name="source" /> is null.</exception>
  483. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  484. /// <exception cref="T:System.OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue" />.</exception>
  485. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  486. public static IQbservable<double?> Average(this IQbservable<long?> source)
  487. {
  488. if (source == null)
  489. throw new ArgumentNullException("source");
  490. return source.Provider.CreateQuery<double?>(
  491. Expression.Call(
  492. null,
  493. #if CRIPPLED_REFLECTION
  494. InfoOf(() => Qbservable.Average(default(IQbservable<long?>))),
  495. #else
  496. (MethodInfo)MethodInfo.GetCurrentMethod(),
  497. #endif
  498. source.Expression
  499. )
  500. );
  501. }
  502. /// <summary>
  503. /// Computes the average of an observable sequence of nullable <see cref="T:System.Single" /> values.
  504. /// </summary>
  505. /// <param name="source">A sequence of nullable <see cref="T:System.Single" /> values to calculate the average of.</param>
  506. /// <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>
  507. /// <exception cref="T:System.ArgumentNullException">
  508. /// <paramref name="source" /> is null.</exception>
  509. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  510. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  511. public static IQbservable<float?> Average(this IQbservable<float?> source)
  512. {
  513. if (source == null)
  514. throw new ArgumentNullException("source");
  515. return source.Provider.CreateQuery<float?>(
  516. Expression.Call(
  517. null,
  518. #if CRIPPLED_REFLECTION
  519. InfoOf(() => Qbservable.Average(default(IQbservable<float?>))),
  520. #else
  521. (MethodInfo)MethodInfo.GetCurrentMethod(),
  522. #endif
  523. source.Expression
  524. )
  525. );
  526. }
  527. /// <summary>
  528. /// Computes the average of an observable sequence of <see cref="T:System.Single" /> values.
  529. /// </summary>
  530. /// <param name="source">A sequence of <see cref="T:System.Single" /> values to calculate the average of.</param>
  531. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  532. /// <exception cref="T:System.ArgumentNullException">
  533. /// <paramref name="source" /> is null.</exception>
  534. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  535. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  536. public static IQbservable<float> Average(this IQbservable<float> source)
  537. {
  538. if (source == null)
  539. throw new ArgumentNullException("source");
  540. return source.Provider.CreateQuery<float>(
  541. Expression.Call(
  542. null,
  543. #if CRIPPLED_REFLECTION
  544. InfoOf(() => Qbservable.Average(default(IQbservable<float>))),
  545. #else
  546. (MethodInfo)MethodInfo.GetCurrentMethod(),
  547. #endif
  548. source.Expression
  549. )
  550. );
  551. }
  552. /// <summary>
  553. /// Computes the average of an observable sequence of <see cref="T:System.Decimal" /> values that are obtained by invoking a transform function on each element of the input sequence.
  554. /// </summary>
  555. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  556. /// <param name="source">A sequence of values to calculate the average of.</param>
  557. /// <param name="selector">A transform function to apply to each element.</param>
  558. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  559. /// <exception cref="T:System.ArgumentNullException">
  560. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  561. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  562. /// <exception cref="T:System.OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="M:System.Decimal.MaxValue" />.</exception>
  563. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  564. public static IQbservable<decimal> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal>> selector)
  565. {
  566. if (source == null)
  567. throw new ArgumentNullException("source");
  568. if (selector == null)
  569. throw new ArgumentNullException("selector");
  570. return source.Provider.CreateQuery<decimal>(
  571. Expression.Call(
  572. null,
  573. #if CRIPPLED_REFLECTION
  574. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal>>))),
  575. #else
  576. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  577. #endif
  578. source.Expression,
  579. selector
  580. )
  581. );
  582. }
  583. /// <summary>
  584. /// Computes the average of an observable sequence of <see cref="T:System.Double" /> values that are obtained by invoking a transform function on each element of the input sequence.
  585. /// </summary>
  586. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  587. /// <param name="source">A sequence of values to calculate the average of.</param>
  588. /// <param name="selector">A transform function to apply to each element.</param>
  589. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  590. /// <exception cref="T:System.ArgumentNullException">
  591. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  592. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  593. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  594. public static IQbservable<double> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double>> selector)
  595. {
  596. if (source == null)
  597. throw new ArgumentNullException("source");
  598. if (selector == null)
  599. throw new ArgumentNullException("selector");
  600. return source.Provider.CreateQuery<double>(
  601. Expression.Call(
  602. null,
  603. #if CRIPPLED_REFLECTION
  604. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double>>))),
  605. #else
  606. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  607. #endif
  608. source.Expression,
  609. selector
  610. )
  611. );
  612. }
  613. /// <summary>
  614. /// Computes the average of an observable sequence of <see cref="T:System.Single" /> values that are obtained by invoking a transform function on each element of the input sequence.
  615. /// </summary>
  616. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  617. /// <param name="source">A sequence of values to calculate the average of.</param>
  618. /// <param name="selector">A transform function to apply to each element.</param>
  619. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  620. /// <exception cref="T:System.ArgumentNullException">
  621. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  622. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  623. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  624. public static IQbservable<float> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float>> selector)
  625. {
  626. if (source == null)
  627. throw new ArgumentNullException("source");
  628. if (selector == null)
  629. throw new ArgumentNullException("selector");
  630. return source.Provider.CreateQuery<float>(
  631. Expression.Call(
  632. null,
  633. #if CRIPPLED_REFLECTION
  634. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float>>))),
  635. #else
  636. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  637. #endif
  638. source.Expression,
  639. selector
  640. )
  641. );
  642. }
  643. /// <summary>
  644. /// Computes the average of an observable sequence of <see cref="T:System.Int32" /> values that are obtained by invoking a transform function on each element of the input sequence.
  645. /// </summary>
  646. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  647. /// <param name="source">A sequence of values to calculate the average of.</param>
  648. /// <param name="selector">A transform function to apply to each element.</param>
  649. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  650. /// <exception cref="T:System.ArgumentNullException">
  651. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  652. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  653. /// <exception cref="T:System.OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue" />.</exception>
  654. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  655. public static IQbservable<double> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int>> selector)
  656. {
  657. if (source == null)
  658. throw new ArgumentNullException("source");
  659. if (selector == null)
  660. throw new ArgumentNullException("selector");
  661. return source.Provider.CreateQuery<double>(
  662. Expression.Call(
  663. null,
  664. #if CRIPPLED_REFLECTION
  665. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int>>))),
  666. #else
  667. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  668. #endif
  669. source.Expression,
  670. selector
  671. )
  672. );
  673. }
  674. /// <summary>
  675. /// Computes the average of an observable sequence of <see cref="T:System.Int64" /> values that are obtained by invoking a transform function on each element of the input sequence.
  676. /// </summary>
  677. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  678. /// <param name="source">A sequence of values to calculate the average of.</param>
  679. /// <param name="selector">A transform function to apply to each element.</param>
  680. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  681. /// <exception cref="T:System.ArgumentNullException">
  682. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  683. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  684. /// <exception cref="T:System.OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue" />.</exception>
  685. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  686. public static IQbservable<double> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long>> selector)
  687. {
  688. if (source == null)
  689. throw new ArgumentNullException("source");
  690. if (selector == null)
  691. throw new ArgumentNullException("selector");
  692. return source.Provider.CreateQuery<double>(
  693. Expression.Call(
  694. null,
  695. #if CRIPPLED_REFLECTION
  696. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long>>))),
  697. #else
  698. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  699. #endif
  700. source.Expression,
  701. selector
  702. )
  703. );
  704. }
  705. /// <summary>
  706. /// Computes the average of an observable sequence of nullable <see cref="T:System.Decimal" /> values that are obtained by invoking a transform function on each element of the input sequence.
  707. /// </summary>
  708. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  709. /// <param name="source">A sequence of values to calculate the average of.</param>
  710. /// <param name="selector">A transform function to apply to each element.</param>
  711. /// <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>
  712. /// <exception cref="T:System.ArgumentNullException">
  713. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  714. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  715. /// <exception cref="T:System.OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="M:System.Decimal.MaxValue" />.</exception>
  716. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  717. public static IQbservable<decimal?> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal?>> selector)
  718. {
  719. if (source == null)
  720. throw new ArgumentNullException("source");
  721. if (selector == null)
  722. throw new ArgumentNullException("selector");
  723. return source.Provider.CreateQuery<decimal?>(
  724. Expression.Call(
  725. null,
  726. #if CRIPPLED_REFLECTION
  727. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal?>>))),
  728. #else
  729. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  730. #endif
  731. source.Expression,
  732. selector
  733. )
  734. );
  735. }
  736. /// <summary>
  737. /// Computes the average of an observable sequence of nullable <see cref="T:System.Double" /> values that are obtained by invoking a transform function on each element of the input sequence.
  738. /// </summary>
  739. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  740. /// <param name="source">A sequence of values to calculate the average of.</param>
  741. /// <param name="selector">A transform function to apply to each element.</param>
  742. /// <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>
  743. /// <exception cref="T:System.ArgumentNullException">
  744. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  745. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  746. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  747. public static IQbservable<double?> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double?>> selector)
  748. {
  749. if (source == null)
  750. throw new ArgumentNullException("source");
  751. if (selector == null)
  752. throw new ArgumentNullException("selector");
  753. return source.Provider.CreateQuery<double?>(
  754. Expression.Call(
  755. null,
  756. #if CRIPPLED_REFLECTION
  757. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double?>>))),
  758. #else
  759. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  760. #endif
  761. source.Expression,
  762. selector
  763. )
  764. );
  765. }
  766. /// <summary>
  767. /// Computes the average of an observable sequence of nullable <see cref="T:System.Single" /> values that are obtained by invoking a transform function on each element of the input sequence.
  768. /// </summary>
  769. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  770. /// <param name="source">A sequence of values to calculate the average of.</param>
  771. /// <param name="selector">A transform function to apply to each element.</param>
  772. /// <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>
  773. /// <exception cref="T:System.ArgumentNullException">
  774. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  775. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  776. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  777. public static IQbservable<float?> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float?>> selector)
  778. {
  779. if (source == null)
  780. throw new ArgumentNullException("source");
  781. if (selector == null)
  782. throw new ArgumentNullException("selector");
  783. return source.Provider.CreateQuery<float?>(
  784. Expression.Call(
  785. null,
  786. #if CRIPPLED_REFLECTION
  787. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float?>>))),
  788. #else
  789. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  790. #endif
  791. source.Expression,
  792. selector
  793. )
  794. );
  795. }
  796. /// <summary>
  797. /// Computes the average of an observable sequence of nullable <see cref="T:System.Int32" /> values that are obtained by invoking a transform function on each element of the input sequence.
  798. /// </summary>
  799. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  800. /// <param name="source">A sequence of values to calculate the average of.</param>
  801. /// <param name="selector">A transform function to apply to each element.</param>
  802. /// <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>
  803. /// <exception cref="T:System.ArgumentNullException">
  804. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  805. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  806. /// <exception cref="T:System.OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue" />.</exception>
  807. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  808. public static IQbservable<double?> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int?>> selector)
  809. {
  810. if (source == null)
  811. throw new ArgumentNullException("source");
  812. if (selector == null)
  813. throw new ArgumentNullException("selector");
  814. return source.Provider.CreateQuery<double?>(
  815. Expression.Call(
  816. null,
  817. #if CRIPPLED_REFLECTION
  818. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int?>>))),
  819. #else
  820. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  821. #endif
  822. source.Expression,
  823. selector
  824. )
  825. );
  826. }
  827. /// <summary>
  828. /// Computes the average of an observable sequence of nullable <see cref="T:System.Int64" /> values that are obtained by invoking a transform function on each element of the input sequence.
  829. /// </summary>
  830. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  831. /// <param name="source">A sequence of values to calculate the average of.</param>
  832. /// <param name="selector">A transform function to apply to each element.</param>
  833. /// <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>
  834. /// <exception cref="T:System.ArgumentNullException">
  835. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  836. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  837. /// <exception cref="T:System.OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue" />.</exception>
  838. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  839. public static IQbservable<double?> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long?>> selector)
  840. {
  841. if (source == null)
  842. throw new ArgumentNullException("source");
  843. if (selector == null)
  844. throw new ArgumentNullException("selector");
  845. return source.Provider.CreateQuery<double?>(
  846. Expression.Call(
  847. null,
  848. #if CRIPPLED_REFLECTION
  849. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long?>>))),
  850. #else
  851. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  852. #endif
  853. source.Expression,
  854. selector
  855. )
  856. );
  857. }
  858. /// <summary>
  859. /// Projects each element of an observable sequence into consecutive non-overlapping buffers which are produced based on element count information.
  860. /// </summary>
  861. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  862. /// <param name="source">Source sequence to produce buffers over.</param>
  863. /// <param name="count">Length of each buffer.</param>
  864. /// <returns>An observable sequence of buffers.</returns>
  865. /// <exception cref="T:System.ArgumentNullException">
  866. /// <paramref name="source" /> is null.</exception>
  867. /// <exception cref="T:System.ArgumentOutOfRangeException">
  868. /// <paramref name="count" /> is less than or equal to zero.</exception>
  869. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, int count)
  870. {
  871. if (source == null)
  872. throw new ArgumentNullException("source");
  873. return source.Provider.CreateQuery<IList<TSource>>(
  874. Expression.Call(
  875. null,
  876. #if CRIPPLED_REFLECTION
  877. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(int))),
  878. #else
  879. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  880. #endif
  881. source.Expression,
  882. Expression.Constant(count, typeof(int))
  883. )
  884. );
  885. }
  886. /// <summary>
  887. /// Projects each element of an observable sequence into zero or more buffers which are produced based on element count information.
  888. /// </summary>
  889. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  890. /// <param name="source">Source sequence to produce buffers over.</param>
  891. /// <param name="count">Length of each buffer.</param>
  892. /// <param name="skip">Number of elements to skip between creation of consecutive buffers.</param>
  893. /// <returns>An observable sequence of buffers.</returns>
  894. /// <exception cref="T:System.ArgumentNullException">
  895. /// <paramref name="source" /> is null.</exception>
  896. /// <exception cref="T:System.ArgumentOutOfRangeException">
  897. /// <paramref name="count" /> or <paramref name="skip" /> is less than or equal to zero.</exception>
  898. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, int count, int skip)
  899. {
  900. if (source == null)
  901. throw new ArgumentNullException("source");
  902. return source.Provider.CreateQuery<IList<TSource>>(
  903. Expression.Call(
  904. null,
  905. #if CRIPPLED_REFLECTION
  906. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(int), default(int))),
  907. #else
  908. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  909. #endif
  910. source.Expression,
  911. Expression.Constant(count, typeof(int)),
  912. Expression.Constant(skip, typeof(int))
  913. )
  914. );
  915. }
  916. /// <summary>
  917. /// Projects each element of an observable sequence into consecutive non-overlapping buffers which are produced based on timing information.
  918. /// </summary>
  919. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  920. /// <param name="source">Source sequence to produce buffers over.</param>
  921. /// <param name="timeSpan">Length of each buffer.</param>
  922. /// <returns>An observable sequence of buffers.</returns>
  923. /// <exception cref="T:System.ArgumentNullException">
  924. /// <paramref name="source" /> is null.</exception>
  925. /// <exception cref="T:System.ArgumentOutOfRangeException">
  926. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  927. /// <remarks>
  928. /// 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.
  929. /// 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
  930. /// 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.
  931. /// </remarks>
  932. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan)
  933. {
  934. if (source == null)
  935. throw new ArgumentNullException("source");
  936. return source.Provider.CreateQuery<IList<TSource>>(
  937. Expression.Call(
  938. null,
  939. #if CRIPPLED_REFLECTION
  940. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  941. #else
  942. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  943. #endif
  944. source.Expression,
  945. Expression.Constant(timeSpan, typeof(TimeSpan))
  946. )
  947. );
  948. }
  949. /// <summary>
  950. /// 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.
  951. /// 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.
  952. /// </summary>
  953. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  954. /// <param name="source">Source sequence to produce buffers over.</param>
  955. /// <param name="timeSpan">Maximum time length of a window.</param>
  956. /// <param name="count">Maximum element count of a window.</param>
  957. /// <returns>An observable sequence of buffers.</returns>
  958. /// <exception cref="T:System.ArgumentNullException">
  959. /// <paramref name="source" /> is null.</exception>
  960. /// <exception cref="T:System.ArgumentOutOfRangeException">
  961. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero. -or- <paramref name="count" /> is less than or equal to zero.</exception>
  962. /// <remarks>
  963. /// 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.
  964. /// 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
  965. /// 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.
  966. /// </remarks>
  967. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, int count)
  968. {
  969. if (source == null)
  970. throw new ArgumentNullException("source");
  971. return source.Provider.CreateQuery<IList<TSource>>(
  972. Expression.Call(
  973. null,
  974. #if CRIPPLED_REFLECTION
  975. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(int))),
  976. #else
  977. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  978. #endif
  979. source.Expression,
  980. Expression.Constant(timeSpan, typeof(TimeSpan)),
  981. Expression.Constant(count, typeof(int))
  982. )
  983. );
  984. }
  985. /// <summary>
  986. /// 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.
  987. /// 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.
  988. /// </summary>
  989. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  990. /// <param name="source">Source sequence to produce buffers over.</param>
  991. /// <param name="timeSpan">Maximum time length of a buffer.</param>
  992. /// <param name="count">Maximum element count of a buffer.</param>
  993. /// <param name="scheduler">Scheduler to run buffering timers on.</param>
  994. /// <returns>An observable sequence of buffers.</returns>
  995. /// <exception cref="T:System.ArgumentNullException">
  996. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  997. /// <exception cref="T:System.ArgumentOutOfRangeException">
  998. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero. -or- <paramref name="count" /> is less than or equal to zero.</exception>
  999. /// <remarks>
  1000. /// 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.
  1001. /// 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
  1002. /// 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.
  1003. /// </remarks>
  1004. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, int count, IScheduler scheduler)
  1005. {
  1006. if (source == null)
  1007. throw new ArgumentNullException("source");
  1008. if (scheduler == null)
  1009. throw new ArgumentNullException("scheduler");
  1010. return source.Provider.CreateQuery<IList<TSource>>(
  1011. Expression.Call(
  1012. null,
  1013. #if CRIPPLED_REFLECTION
  1014. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(int), default(IScheduler))),
  1015. #else
  1016. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1017. #endif
  1018. source.Expression,
  1019. Expression.Constant(timeSpan, typeof(TimeSpan)),
  1020. Expression.Constant(count, typeof(int)),
  1021. Expression.Constant(scheduler, typeof(IScheduler))
  1022. )
  1023. );
  1024. }
  1025. /// <summary>
  1026. /// 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.
  1027. /// </summary>
  1028. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1029. /// <param name="source">Source sequence to produce buffers over.</param>
  1030. /// <param name="timeSpan">Length of each buffer.</param>
  1031. /// <param name="scheduler">Scheduler to run buffering timers on.</param>
  1032. /// <returns>An observable sequence of buffers.</returns>
  1033. /// <exception cref="T:System.ArgumentNullException">
  1034. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  1035. /// <exception cref="T:System.ArgumentOutOfRangeException">
  1036. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  1037. /// <remarks>
  1038. /// 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.
  1039. /// 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
  1040. /// 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.
  1041. /// </remarks>
  1042. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, IScheduler scheduler)
  1043. {
  1044. if (source == null)
  1045. throw new ArgumentNullException("source");
  1046. if (scheduler == null)
  1047. throw new ArgumentNullException("scheduler");
  1048. return source.Provider.CreateQuery<IList<TSource>>(
  1049. Expression.Call(
  1050. null,
  1051. #if CRIPPLED_REFLECTION
  1052. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  1053. #else
  1054. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1055. #endif
  1056. source.Expression,
  1057. Expression.Constant(timeSpan, typeof(TimeSpan)),
  1058. Expression.Constant(scheduler, typeof(IScheduler))
  1059. )
  1060. );
  1061. }
  1062. /// <summary>
  1063. /// Projects each element of an observable sequence into zero or more buffers which are produced based on timing information.
  1064. /// </summary>
  1065. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1066. /// <param name="source">Source sequence to produce buffers over.</param>
  1067. /// <param name="timeSpan">Length of each buffer.</param>
  1068. /// <param name="timeShift">Interval between creation of consecutive buffers.</param>
  1069. /// <returns>An observable sequence of buffers.</returns>
  1070. /// <exception cref="T:System.ArgumentNullException">
  1071. /// <paramref name="source" /> is null.</exception>
  1072. /// <exception cref="T:System.ArgumentOutOfRangeException">
  1073. /// <paramref name="timeSpan" /> or <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  1074. /// <remarks>
  1075. /// <para>
  1076. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create buffers with minimum duration
  1077. /// 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
  1078. /// current buffer may not execute immediately, despite the TimeSpan.Zero due time.
  1079. /// </para>
  1080. /// <para>
  1081. /// 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.
  1082. /// 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,
  1083. /// where the action to create a new buffer may not execute immediately, despite the TimeSpan.Zero due time.
  1084. /// </para>
  1085. /// </remarks>
  1086. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, TimeSpan timeShift)
  1087. {
  1088. if (source == null)
  1089. throw new ArgumentNullException("source");
  1090. return source.Provider.CreateQuery<IList<TSource>>(
  1091. Expression.Call(
  1092. null,
  1093. #if CRIPPLED_REFLECTION
  1094. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(TimeSpan))),
  1095. #else
  1096. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1097. #endif
  1098. source.Expression,
  1099. Expression.Constant(timeSpan, typeof(TimeSpan)),
  1100. Expression.Constant(timeShift, typeof(TimeSpan))
  1101. )
  1102. );
  1103. }
  1104. /// <summary>
  1105. /// 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.
  1106. /// </summary>
  1107. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1108. /// <param name="source">Source sequence to produce buffers over.</param>
  1109. /// <param name="timeSpan">Length of each buffer.</param>
  1110. /// <param name="timeShift">Interval between creation of consecutive buffers.</param>
  1111. /// <param name="scheduler">Scheduler to run buffering timers on.</param>
  1112. /// <returns>An observable sequence of buffers.</returns>
  1113. /// <exception cref="T:System.ArgumentNullException">
  1114. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  1115. /// <exception cref="T:System.ArgumentOutOfRangeException">
  1116. /// <paramref name="timeSpan" /> or <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  1117. /// <remarks>
  1118. /// <para>
  1119. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create buffers with minimum duration
  1120. /// 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
  1121. /// current buffer may not execute immediately, despite the TimeSpan.Zero due time.
  1122. /// </para>
  1123. /// <para>
  1124. /// 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.
  1125. /// 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,
  1126. /// where the action to create a new buffer may not execute immediately, despite the TimeSpan.Zero due time.
  1127. /// </para>
  1128. /// </remarks>
  1129. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, TimeSpan timeShift, IScheduler scheduler)
  1130. {
  1131. if (source == null)
  1132. throw new ArgumentNullException("source");
  1133. if (scheduler == null)
  1134. throw new ArgumentNullException("scheduler");
  1135. return source.Provider.CreateQuery<IList<TSource>>(
  1136. Expression.Call(
  1137. null,
  1138. #if CRIPPLED_REFLECTION
  1139. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(TimeSpan), default(IScheduler))),
  1140. #else
  1141. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1142. #endif
  1143. source.Expression,
  1144. Expression.Constant(timeSpan, typeof(TimeSpan)),
  1145. Expression.Constant(timeShift, typeof(TimeSpan)),
  1146. Expression.Constant(scheduler, typeof(IScheduler))
  1147. )
  1148. );
  1149. }
  1150. /// <summary>
  1151. /// Projects each element of an observable sequence into consecutive non-overlapping buffers.
  1152. /// </summary>
  1153. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1154. /// <typeparam name="TBufferBoundary">The type of the elements in the sequences indicating buffer boundary events.</typeparam>
  1155. /// <param name="source">Source sequence to produce buffers over.</param>
  1156. /// <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>
  1157. /// <returns>An observable sequence of buffers.</returns>
  1158. /// <exception cref="T:System.ArgumentNullException">
  1159. /// <paramref name="source" /> or <paramref name="bufferBoundaries" /> is null.</exception>
  1160. public static IQbservable<IList<TSource>> Buffer<TSource, TBufferBoundary>(this IQbservable<TSource> source, IObservable<TBufferBoundary> bufferBoundaries)
  1161. {
  1162. if (source == null)
  1163. throw new ArgumentNullException("source");
  1164. if (bufferBoundaries == null)
  1165. throw new ArgumentNullException("bufferBoundaries");
  1166. return source.Provider.CreateQuery<IList<TSource>>(
  1167. Expression.Call(
  1168. null,
  1169. #if CRIPPLED_REFLECTION
  1170. InfoOf(() => Qbservable.Buffer<TSource, TBufferBoundary>(default(IQbservable<TSource>), default(IObservable<TBufferBoundary>))),
  1171. #else
  1172. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TBufferBoundary)),
  1173. #endif
  1174. source.Expression,
  1175. GetSourceExpression(bufferBoundaries)
  1176. )
  1177. );
  1178. }
  1179. /// <summary>
  1180. /// Projects each element of an observable sequence into consecutive non-overlapping buffers.
  1181. /// </summary>
  1182. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1183. /// <typeparam name="TBufferClosing">The type of the elements in the sequences indicating buffer closing events.</typeparam>
  1184. /// <param name="source">Source sequence to produce buffers over.</param>
  1185. /// <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>
  1186. /// <returns>An observable sequence of buffers.</returns>
  1187. /// <exception cref="T:System.ArgumentNullException">
  1188. /// <paramref name="source" /> or <paramref name="bufferClosingSelector" /> is null.</exception>
  1189. public static IQbservable<IList<TSource>> Buffer<TSource, TBufferClosing>(this IQbservable<TSource> source, Expression<Func<IObservable<TBufferClosing>>> bufferClosingSelector)
  1190. {
  1191. if (source == null)
  1192. throw new ArgumentNullException("source");
  1193. if (bufferClosingSelector == null)
  1194. throw new ArgumentNullException("bufferClosingSelector");
  1195. return source.Provider.CreateQuery<IList<TSource>>(
  1196. Expression.Call(
  1197. null,
  1198. #if CRIPPLED_REFLECTION
  1199. InfoOf(() => Qbservable.Buffer<TSource, TBufferClosing>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TBufferClosing>>>))),
  1200. #else
  1201. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TBufferClosing)),
  1202. #endif
  1203. source.Expression,
  1204. bufferClosingSelector
  1205. )
  1206. );
  1207. }
  1208. /// <summary>
  1209. /// Projects each element of an observable sequence into zero or more buffers.
  1210. /// </summary>
  1211. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1212. /// <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>
  1213. /// <typeparam name="TBufferClosing">The type of the elements in the sequences indicating buffer closing events.</typeparam>
  1214. /// <param name="source">Source sequence to produce buffers over.</param>
  1215. /// <param name="bufferOpenings">Observable sequence whose elements denote the creation of new buffers.</param>
  1216. /// <param name="bufferClosingSelector">A function invoked to define the closing of each produced buffer.</param>
  1217. /// <returns>An observable sequence of buffers.</returns>
  1218. /// <exception cref="T:System.ArgumentNullException">
  1219. /// <paramref name="source" /> or <paramref name="bufferOpenings" /> or <paramref name="bufferClosingSelector" /> is null.</exception>
  1220. public static IQbservable<IList<TSource>> Buffer<TSource, TBufferOpening, TBufferClosing>(this IQbservable<TSource> source, IObservable<TBufferOpening> bufferOpenings, Expression<Func<TBufferOpening, IObservable<TBufferClosing>>> bufferClosingSelector)
  1221. {
  1222. if (source == null)
  1223. throw new ArgumentNullException("source");
  1224. if (bufferOpenings == null)
  1225. throw new ArgumentNullException("bufferOpenings");
  1226. if (bufferClosingSelector == null)
  1227. throw new ArgumentNullException("bufferClosingSelector");
  1228. return source.Provider.CreateQuery<IList<TSource>>(
  1229. Expression.Call(
  1230. null,
  1231. #if CRIPPLED_REFLECTION
  1232. InfoOf(() => Qbservable.Buffer<TSource, TBufferOpening, TBufferClosing>(default(IQbservable<TSource>), default(IObservable<TBufferOpening>), default(Expression<Func<TBufferOpening, IObservable<TBufferClosing>>>))),
  1233. #else
  1234. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TBufferOpening), typeof(TBufferClosing)),
  1235. #endif
  1236. source.Expression,
  1237. GetSourceExpression(bufferOpenings),
  1238. bufferClosingSelector
  1239. )
  1240. );
  1241. }
  1242. /// <summary>
  1243. /// Uses <paramref name="selector" /> to determine which source in <paramref name="sources" /> to return, choosing an empty sequence if no match is found.
  1244. /// </summary>
  1245. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  1246. /// <typeparam name="TValue">The type of the value returned by the selector function, used to look up the resulting source.</typeparam>
  1247. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  1248. /// <param name="selector">Selector function invoked to determine the source to lookup in the <paramref name="sources" /> dictionary.</param>
  1249. /// <param name="sources">Dictionary of sources to select from based on the <paramref name="selector" /> invocation result.</param>
  1250. /// <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>
  1251. /// <exception cref="T:System.ArgumentNullException">
  1252. /// <paramref name="selector" /> or <paramref name="sources" /> is null.</exception>
  1253. public static IQbservable<TResult> Case<TValue, TResult>(this IQbservableProvider provider, Expression<Func<TValue>> selector, IDictionary<TValue, IObservable<TResult>> sources)
  1254. {
  1255. if (provider == null)
  1256. throw new ArgumentNullException("provider");
  1257. if (selector == null)
  1258. throw new ArgumentNullException("selector");
  1259. if (sources == null)
  1260. throw new ArgumentNullException("sources");
  1261. return provider.CreateQuery<TResult>(
  1262. Expression.Call(
  1263. null,
  1264. #if CRIPPLED_REFLECTION
  1265. InfoOf(() => Qbservable.Case<TValue, TResult>(default(IQbservableProvider), default(Expression<Func<TValue>>), default(IDictionary<TValue, IObservable<TResult>>))),
  1266. #else
  1267. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TValue), typeof(TResult)),
  1268. #endif
  1269. Expression.Constant(provider, typeof(IQbservableProvider)),
  1270. selector,
  1271. Expression.Constant(sources, typeof(IDictionary<TValue, IObservable<TResult>>))
  1272. )
  1273. );
  1274. }
  1275. /// <summary>
  1276. /// Uses <paramref name="selector" /> to determine which source in <paramref name="sources" /> to return, choosing <paramref name="defaultSource" /> if no match is found.
  1277. /// </summary>
  1278. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  1279. /// <typeparam name="TValue">The type of the value returned by the selector function, used to look up the resulting source.</typeparam>
  1280. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  1281. /// <param name="selector">Selector function invoked to determine the source to lookup in the <paramref name="sources" /> dictionary.</param>
  1282. /// <param name="sources">Dictionary of sources to select from based on the <paramref name="selector" /> invocation result.</param>
  1283. /// <param name="defaultSource">Default source to select in case no matching source in <paramref name="sources" /> is found.</param>
  1284. /// <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>
  1285. /// <exception cref="T:System.ArgumentNullException">
  1286. /// <paramref name="selector" /> or <paramref name="sources" /> or <paramref name="defaultSource" /> is null.</exception>
  1287. public static IQbservable<TResult> Case<TValue, TResult>(this IQbservableProvider provider, Expression<Func<TValue>> selector, IDictionary<TValue, IObservable<TResult>> sources, IObservable<TResult> defaultSource)
  1288. {
  1289. if (provider == null)
  1290. throw new ArgumentNullException("provider");
  1291. if (selector == null)
  1292. throw new ArgumentNullException("selector");
  1293. if (sources == null)
  1294. throw new ArgumentNullException("sources");
  1295. if (defaultSource == null)
  1296. throw new ArgumentNullException("defaultSource");
  1297. return provider.CreateQuery<TResult>(
  1298. Expression.Call(
  1299. null,
  1300. #if CRIPPLED_REFLECTION
  1301. InfoOf(() => Qbservable.Case<TValue, TResult>(default(IQbservableProvider), default(Expression<Func<TValue>>), default(IDictionary<TValue, IObservable<TResult>>), default(IObservable<TResult>))),
  1302. #else
  1303. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TValue), typeof(TResult)),
  1304. #endif
  1305. Expression.Constant(provider, typeof(IQbservableProvider)),
  1306. selector,
  1307. Expression.Constant(sources, typeof(IDictionary<TValue, IObservable<TResult>>)),
  1308. GetSourceExpression(defaultSource)
  1309. )
  1310. );
  1311. }
  1312. /// <summary>
  1313. /// 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.
  1314. /// </summary>
  1315. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  1316. /// <typeparam name="TValue">The type of the value returned by the selector function, used to look up the resulting source.</typeparam>
  1317. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  1318. /// <param name="selector">Selector function invoked to determine the source to lookup in the <paramref name="sources" /> dictionary.</param>
  1319. /// <param name="sources">Dictionary of sources to select from based on the <paramref name="selector" /> invocation result.</param>
  1320. /// <param name="scheduler">Scheduler to generate an empty sequence on in case no matching source in <paramref name="sources" /> is found.</param>
  1321. /// <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>
  1322. /// <exception cref="T:System.ArgumentNullException">
  1323. /// <paramref name="selector" /> or <paramref name="sources" /> or <paramref name="scheduler" /> is null.</exception>
  1324. public static IQbservable<TResult> Case<TValue, TResult>(this IQbservableProvider provider, Expression<Func<TValue>> selector, IDictionary<TValue, IObservable<TResult>> sources, IScheduler scheduler)
  1325. {
  1326. if (provider == null)
  1327. throw new ArgumentNullException("provider");
  1328. if (selector == null)
  1329. throw new ArgumentNullException("selector");
  1330. if (sources == null)
  1331. throw new ArgumentNullException("sources");
  1332. if (scheduler == null)
  1333. throw new ArgumentNullException("scheduler");
  1334. return provider.CreateQuery<TResult>(
  1335. Expression.Call(
  1336. null,
  1337. #if CRIPPLED_REFLECTION
  1338. InfoOf(() => Qbservable.Case<TValue, TResult>(default(IQbservableProvider), default(Expression<Func<TValue>>), default(IDictionary<TValue, IObservable<TResult>>), default(IScheduler))),
  1339. #else
  1340. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TValue), typeof(TResult)),
  1341. #endif
  1342. Expression.Constant(provider, typeof(IQbservableProvider)),
  1343. selector,
  1344. Expression.Constant(sources, typeof(IDictionary<TValue, IObservable<TResult>>)),
  1345. Expression.Constant(scheduler, typeof(IScheduler))
  1346. )
  1347. );
  1348. }
  1349. /// <summary>
  1350. /// Converts the elements of an observable sequence to the specified type.
  1351. /// </summary>
  1352. /// <typeparam name="TResult">The type to convert the elements in the source sequence to.</typeparam>
  1353. /// <param name="source">The observable sequence that contains the elements to be converted.</param>
  1354. /// <returns>An observable sequence that contains each element of the source sequence converted to the specified type.</returns>
  1355. /// <exception cref="T:System.ArgumentNullException">
  1356. /// <paramref name="source" /> is null.</exception>
  1357. public static IQbservable<TResult> Cast<TResult>(this IQbservable<object> source)
  1358. {
  1359. if (source == null)
  1360. throw new ArgumentNullException("source");
  1361. return source.Provider.CreateQuery<TResult>(
  1362. Expression.Call(
  1363. null,
  1364. #if CRIPPLED_REFLECTION
  1365. InfoOf(() => Qbservable.Cast<TResult>(default(IQbservable<object>))),
  1366. #else
  1367. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  1368. #endif
  1369. source.Expression
  1370. )
  1371. );
  1372. }
  1373. /// <summary>
  1374. /// Continues an observable sequence that is terminated by an exception with the next observable sequence.
  1375. /// </summary>
  1376. /// <typeparam name="TSource">The type of the elements in the source sequence and handler sequence.</typeparam>
  1377. /// <param name="first">First observable sequence whose exception (if any) is caught.</param>
  1378. /// <param name="second">Second observable sequence used to produce results when an error occurred in the first sequence.</param>
  1379. /// <returns>An observable sequence containing the first sequence's elements, followed by the elements of the second sequence in case an exception occurred.</returns>
  1380. /// <exception cref="T:System.ArgumentNullException">
  1381. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  1382. public static IQbservable<TSource> Catch<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  1383. {
  1384. if (first == null)
  1385. throw new ArgumentNullException("first");
  1386. if (second == null)
  1387. throw new ArgumentNullException("second");
  1388. return first.Provider.CreateQuery<TSource>(
  1389. Expression.Call(
  1390. null,
  1391. #if CRIPPLED_REFLECTION
  1392. InfoOf(() => Qbservable.Catch<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  1393. #else
  1394. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1395. #endif
  1396. first.Expression,
  1397. GetSourceExpression(second)
  1398. )
  1399. );
  1400. }
  1401. /// <summary>
  1402. /// Continues an observable sequence that is terminated by an exception with the next observable sequence.
  1403. /// </summary>
  1404. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  1405. /// <typeparam name="TSource">The type of the elements in the source and handler sequences.</typeparam>
  1406. /// <param name="sources">Observable sequences to catch exceptions for.</param>
  1407. /// <returns>An observable sequence containing elements from consecutive source sequences until a source sequence terminates successfully.</returns>
  1408. /// <exception cref="T:System.ArgumentNullException">
  1409. /// <paramref name="sources" /> is null.</exception>
  1410. public static IQbservable<TSource> Catch<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  1411. {
  1412. if (provider == null)
  1413. throw new ArgumentNullException("provider");
  1414. if (sources == null)
  1415. throw new ArgumentNullException("sources");
  1416. return provider.CreateQuery<TSource>(
  1417. Expression.Call(
  1418. null,
  1419. #if CRIPPLED_REFLECTION
  1420. InfoOf(() => Qbservable.Catch<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  1421. #else
  1422. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1423. #endif
  1424. Expression.Constant(provider, typeof(IQbservableProvider)),
  1425. GetSourceExpression(sources)
  1426. )
  1427. );
  1428. }
  1429. /// <summary>
  1430. /// Continues an observable sequence that is terminated by an exception with the next observable sequence.
  1431. /// </summary>
  1432. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  1433. /// <typeparam name="TSource">The type of the elements in the source and handler sequences.</typeparam>
  1434. /// <param name="sources">Observable sequences to catch exceptions for.</param>
  1435. /// <returns>An observable sequence containing elements from consecutive source sequences until a source sequence terminates successfully.</returns>
  1436. /// <exception cref="T:System.ArgumentNullException">
  1437. /// <paramref name="sources" /> is null.</exception>
  1438. public static IQbservable<TSource> Catch<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  1439. {
  1440. if (provider == null)
  1441. throw new ArgumentNullException("provider");
  1442. if (sources == null)
  1443. throw new ArgumentNullException("sources");
  1444. return provider.CreateQuery<TSource>(
  1445. Expression.Call(
  1446. null,
  1447. #if CRIPPLED_REFLECTION
  1448. InfoOf(() => Qbservable.Catch<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  1449. #else
  1450. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1451. #endif
  1452. Expression.Constant(provider, typeof(IQbservableProvider)),
  1453. GetSourceExpression(sources)
  1454. )
  1455. );
  1456. }
  1457. /// <summary>
  1458. /// Continues an observable sequence that is terminated by an exception of the specified type with the observable sequence produced by the handler.
  1459. /// </summary>
  1460. /// <typeparam name="TSource">The type of the elements in the source sequence and sequences returned by the exception handler function.</typeparam>
  1461. /// <typeparam name="TException">The type of the exception to catch and handle. Needs to derive from <see cref="T:System.Exception" />.</typeparam>
  1462. /// <param name="source">Source sequence.</param>
  1463. /// <param name="handler">Exception handler function, producing another observable sequence.</param>
  1464. /// <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>
  1465. /// <exception cref="T:System.ArgumentNullException">
  1466. /// <paramref name="source" /> or <paramref name="handler" /> is null.</exception>
  1467. public static IQbservable<TSource> Catch<TSource, TException>(this IQbservable<TSource> source, Expression<Func<TException, IObservable<TSource>>> handler)
  1468. where TException : Exception
  1469. {
  1470. if (source == null)
  1471. throw new ArgumentNullException("source");
  1472. if (handler == null)
  1473. throw new ArgumentNullException("handler");
  1474. return source.Provider.CreateQuery<TSource>(
  1475. Expression.Call(
  1476. null,
  1477. #if CRIPPLED_REFLECTION
  1478. InfoOf(() => Qbservable.Catch<TSource, TException>(default(IQbservable<TSource>), default(Expression<Func<TException, IObservable<TSource>>>))),
  1479. #else
  1480. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TException)),
  1481. #endif
  1482. source.Expression,
  1483. handler
  1484. )
  1485. );
  1486. }
  1487. /// <summary>
  1488. /// Produces an enumerable sequence of consecutive (possibly empty) chunks of the source sequence.
  1489. /// </summary>
  1490. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  1491. /// <param name="source">Source observable sequence.</param>
  1492. /// <returns>The enumerable sequence that returns consecutive (possibly empty) chunks upon each iteration.</returns>
  1493. /// <exception cref="T:System.ArgumentNullException">
  1494. /// <paramref name="source" /> is null.</exception>
  1495. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  1496. public static IQueryable<IList<TSource>> Chunkify<TSource>(this IQbservable<TSource> source)
  1497. {
  1498. if (source == null)
  1499. throw new ArgumentNullException("source");
  1500. return ((IQueryProvider)source.Provider).CreateQuery<IList<TSource>>(
  1501. Expression.Call(
  1502. null,
  1503. #if CRIPPLED_REFLECTION
  1504. InfoOf(() => Qbservable.Chunkify<TSource>(default(IQbservable<TSource>))),
  1505. #else
  1506. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1507. #endif
  1508. source.Expression
  1509. )
  1510. );
  1511. }
  1512. /// <summary>
  1513. /// Produces an enumerable sequence that returns elements collected/aggregated from the source sequence between consecutive iterations.
  1514. /// </summary>
  1515. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  1516. /// <typeparam name="TResult">The type of the elements produced by the merge operation during collection.</typeparam>
  1517. /// <param name="source">Source observable sequence.</param>
  1518. /// <param name="getInitialCollector">Factory to create the initial collector object.</param>
  1519. /// <param name="merge">Merges a sequence element with the current collector.</param>
  1520. /// <param name="getNewCollector">Factory to replace the current collector by a new collector.</param>
  1521. /// <returns>The enumerable sequence that returns collected/aggregated elements from the source sequence upon each iteration.</returns>
  1522. /// <exception cref="T:System.ArgumentNullException">
  1523. /// <paramref name="source" /> or <paramref name="getInitialCollector" /> or <paramref name="merge" /> or <paramref name="getNewCollector" /> is null.</exception>
  1524. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  1525. 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)
  1526. {
  1527. if (source == null)
  1528. throw new ArgumentNullException("source");
  1529. if (getInitialCollector == null)
  1530. throw new ArgumentNullException("getInitialCollector");
  1531. if (merge == null)
  1532. throw new ArgumentNullException("merge");
  1533. if (getNewCollector == null)
  1534. throw new ArgumentNullException("getNewCollector");
  1535. return ((IQueryProvider)source.Provider).CreateQuery<TResult>(
  1536. Expression.Call(
  1537. null,
  1538. #if CRIPPLED_REFLECTION
  1539. InfoOf(() => Qbservable.Collect<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TResult>>), default(Expression<Func<TResult, TSource, TResult>>), default(Expression<Func<TResult, TResult>>))),
  1540. #else
  1541. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  1542. #endif
  1543. source.Expression,
  1544. getInitialCollector,
  1545. merge,
  1546. getNewCollector
  1547. )
  1548. );
  1549. }
  1550. /// <summary>
  1551. /// Produces an enumerable sequence that returns elements collected/aggregated from the source sequence between consecutive iterations.
  1552. /// </summary>
  1553. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  1554. /// <typeparam name="TResult">The type of the elements produced by the merge operation during collection.</typeparam>
  1555. /// <param name="source">Source observable sequence.</param>
  1556. /// <param name="newCollector">Factory to create a new collector object.</param>
  1557. /// <param name="merge">Merges a sequence element with the current collector.</param>
  1558. /// <returns>The enumerable sequence that returns collected/aggregated elements from the source sequence upon each iteration.</returns>
  1559. /// <exception cref="T:System.ArgumentNullException">
  1560. /// <paramref name="source" /> or <paramref name="newCollector" /> or <paramref name="merge" /> is null.</exception>
  1561. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  1562. public static IQueryable<TResult> Collect<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TResult>> newCollector, Expression<Func<TResult, TSource, TResult>> merge)
  1563. {
  1564. if (source == null)
  1565. throw new ArgumentNullException("source");
  1566. if (newCollector == null)
  1567. throw new ArgumentNullException("newCollector");
  1568. if (merge == null)
  1569. throw new ArgumentNullException("merge");
  1570. return ((IQueryProvider)source.Provider).CreateQuery<TResult>(
  1571. Expression.Call(
  1572. null,
  1573. #if CRIPPLED_REFLECTION
  1574. InfoOf(() => Qbservable.Collect<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TResult>>), default(Expression<Func<TResult, TSource, TResult>>))),
  1575. #else
  1576. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  1577. #endif
  1578. source.Expression,
  1579. newCollector,
  1580. merge
  1581. )
  1582. );
  1583. }
  1584. /// <summary>
  1585. /// 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.
  1586. /// </summary>
  1587. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  1588. /// <typeparam name="TSource">The type of the elements in the source sequences, and in the lists in the result sequence.</typeparam>
  1589. /// <param name="sources">Observable sources.</param>
  1590. /// <returns>An observable sequence containing lists of the latest elements of the sources.</returns>
  1591. /// <exception cref="T:System.ArgumentNullException">
  1592. /// <paramref name="sources" /> is null.</exception>
  1593. public static IQbservable<IList<TSource>> CombineLatest<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  1594. {
  1595. if (provider == null)
  1596. throw new ArgumentNullException("provider");
  1597. if (sources == null)
  1598. throw new ArgumentNullException("sources");
  1599. return provider.CreateQuery<IList<TSource>>(
  1600. Expression.Call(
  1601. null,
  1602. #if CRIPPLED_REFLECTION
  1603. InfoOf(() => Qbservable.CombineLatest<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  1604. #else
  1605. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1606. #endif
  1607. Expression.Constant(provider, typeof(IQbservableProvider)),
  1608. GetSourceExpression(sources)
  1609. )
  1610. );
  1611. }
  1612. /// <summary>
  1613. /// 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.
  1614. /// </summary>
  1615. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  1616. /// <typeparam name="TSource">The type of the elements in the source sequences, and in the lists in the result sequence.</typeparam>
  1617. /// <param name="sources">Observable sources.</param>
  1618. /// <returns>An observable sequence containing lists of the latest elements of the sources.</returns>
  1619. /// <exception cref="T:System.ArgumentNullException">
  1620. /// <paramref name="sources" /> is null.</exception>
  1621. public static IQbservable<IList<TSource>> CombineLatest<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  1622. {
  1623. if (provider == null)
  1624. throw new ArgumentNullException("provider");
  1625. if (sources == null)
  1626. throw new ArgumentNullException("sources");
  1627. return provider.CreateQuery<IList<TSource>>(
  1628. Expression.Call(
  1629. null,
  1630. #if CRIPPLED_REFLECTION
  1631. InfoOf(() => Qbservable.CombineLatest<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  1632. #else
  1633. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1634. #endif
  1635. Expression.Constant(provider, typeof(IQbservableProvider)),
  1636. GetSourceExpression(sources)
  1637. )
  1638. );
  1639. }
  1640. /// <summary>
  1641. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1642. /// </summary>
  1643. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  1644. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  1645. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1646. /// <param name="sources">Observable sources.</param>
  1647. /// <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>
  1648. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1649. /// <exception cref="T:System.ArgumentNullException">
  1650. /// <paramref name="sources" /> or <paramref name="resultSelector" /> is null.</exception>
  1651. public static IQbservable<TResult> CombineLatest<TSource, TResult>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, Expression<Func<IList<TSource>, TResult>> resultSelector)
  1652. {
  1653. if (provider == null)
  1654. throw new ArgumentNullException("provider");
  1655. if (sources == null)
  1656. throw new ArgumentNullException("sources");
  1657. if (resultSelector == null)
  1658. throw new ArgumentNullException("resultSelector");
  1659. return provider.CreateQuery<TResult>(
  1660. Expression.Call(
  1661. null,
  1662. #if CRIPPLED_REFLECTION
  1663. InfoOf(() => Qbservable.CombineLatest<TSource, TResult>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(Expression<Func<IList<TSource>, TResult>>))),
  1664. #else
  1665. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  1666. #endif
  1667. Expression.Constant(provider, typeof(IQbservableProvider)),
  1668. GetSourceExpression(sources),
  1669. resultSelector
  1670. )
  1671. );
  1672. }
  1673. /// <summary>
  1674. /// Merges two observable sequences into one observable sequence by using the selector function whenever one of the observable sequences produces an element.
  1675. /// </summary>
  1676. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1677. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1678. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1679. /// <param name="first">First observable source.</param>
  1680. /// <param name="second">Second observable source.</param>
  1681. /// <param name="resultSelector">Function to invoke whenever either of the sources produces an element.</param>
  1682. /// <returns>An observable sequence containing the result of combining elements of both sources using the specified result selector function.</returns>
  1683. /// <exception cref="T:System.ArgumentNullException">
  1684. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="resultSelector" /> is null.</exception>
  1685. public static IQbservable<TResult> CombineLatest<TSource1, TSource2, TResult>(this IQbservable<TSource1> first, IObservable<TSource2> second, Expression<Func<TSource1, TSource2, TResult>> resultSelector)
  1686. {
  1687. if (first == null)
  1688. throw new ArgumentNullException("first");
  1689. if (second == null)
  1690. throw new ArgumentNullException("second");
  1691. if (resultSelector == null)
  1692. throw new ArgumentNullException("resultSelector");
  1693. return first.Provider.CreateQuery<TResult>(
  1694. Expression.Call(
  1695. null,
  1696. #if CRIPPLED_REFLECTION
  1697. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(Expression<Func<TSource1, TSource2, TResult>>))),
  1698. #else
  1699. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TResult)),
  1700. #endif
  1701. first.Expression,
  1702. GetSourceExpression(second),
  1703. resultSelector
  1704. )
  1705. );
  1706. }
  1707. /// <summary>
  1708. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1709. /// </summary>
  1710. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1711. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1712. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  1713. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1714. /// <param name="source1">First observable source.</param>
  1715. /// <param name="source2">Second observable source.</param>
  1716. /// <param name="source3">Third observable source.</param>
  1717. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  1718. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1719. /// <exception cref="T:System.ArgumentNullException">
  1720. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="resultSelector" /> is null.</exception>
  1721. 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)
  1722. {
  1723. if (source1 == null)
  1724. throw new ArgumentNullException("source1");
  1725. if (source2 == null)
  1726. throw new ArgumentNullException("source2");
  1727. if (source3 == null)
  1728. throw new ArgumentNullException("source3");
  1729. if (resultSelector == null)
  1730. throw new ArgumentNullException("resultSelector");
  1731. return source1.Provider.CreateQuery<TResult>(
  1732. Expression.Call(
  1733. null,
  1734. #if CRIPPLED_REFLECTION
  1735. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TSource3, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(Expression<Func<TSource1, TSource2, TSource3, TResult>>))),
  1736. #else
  1737. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TResult)),
  1738. #endif
  1739. source1.Expression,
  1740. GetSourceExpression(source2),
  1741. GetSourceExpression(source3),
  1742. resultSelector
  1743. )
  1744. );
  1745. }
  1746. /// <summary>
  1747. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1748. /// </summary>
  1749. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1750. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1751. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  1752. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  1753. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1754. /// <param name="source1">First observable source.</param>
  1755. /// <param name="source2">Second observable source.</param>
  1756. /// <param name="source3">Third observable source.</param>
  1757. /// <param name="source4">Fourth observable source.</param>
  1758. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  1759. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1760. /// <exception cref="T:System.ArgumentNullException">
  1761. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="resultSelector" /> is null.</exception>
  1762. 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)
  1763. {
  1764. if (source1 == null)
  1765. throw new ArgumentNullException("source1");
  1766. if (source2 == null)
  1767. throw new ArgumentNullException("source2");
  1768. if (source3 == null)
  1769. throw new ArgumentNullException("source3");
  1770. if (source4 == null)
  1771. throw new ArgumentNullException("source4");
  1772. if (resultSelector == null)
  1773. throw new ArgumentNullException("resultSelector");
  1774. return source1.Provider.CreateQuery<TResult>(
  1775. Expression.Call(
  1776. null,
  1777. #if CRIPPLED_REFLECTION
  1778. 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>>))),
  1779. #else
  1780. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TResult)),
  1781. #endif
  1782. source1.Expression,
  1783. GetSourceExpression(source2),
  1784. GetSourceExpression(source3),
  1785. GetSourceExpression(source4),
  1786. resultSelector
  1787. )
  1788. );
  1789. }
  1790. #if !NO_LARGEARITY
  1791. /// <summary>
  1792. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1793. /// </summary>
  1794. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1795. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1796. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  1797. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  1798. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  1799. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1800. /// <param name="source1">First observable source.</param>
  1801. /// <param name="source2">Second observable source.</param>
  1802. /// <param name="source3">Third observable source.</param>
  1803. /// <param name="source4">Fourth observable source.</param>
  1804. /// <param name="source5">Fifth observable source.</param>
  1805. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  1806. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1807. /// <exception cref="T:System.ArgumentNullException">
  1808. /// <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>
  1809. 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)
  1810. {
  1811. if (source1 == null)
  1812. throw new ArgumentNullException("source1");
  1813. if (source2 == null)
  1814. throw new ArgumentNullException("source2");
  1815. if (source3 == null)
  1816. throw new ArgumentNullException("source3");
  1817. if (source4 == null)
  1818. throw new ArgumentNullException("source4");
  1819. if (source5 == null)
  1820. throw new ArgumentNullException("source5");
  1821. if (resultSelector == null)
  1822. throw new ArgumentNullException("resultSelector");
  1823. return source1.Provider.CreateQuery<TResult>(
  1824. Expression.Call(
  1825. null,
  1826. #if CRIPPLED_REFLECTION
  1827. 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>>))),
  1828. #else
  1829. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TResult)),
  1830. #endif
  1831. source1.Expression,
  1832. GetSourceExpression(source2),
  1833. GetSourceExpression(source3),
  1834. GetSourceExpression(source4),
  1835. GetSourceExpression(source5),
  1836. resultSelector
  1837. )
  1838. );
  1839. }
  1840. #endif
  1841. #if !NO_LARGEARITY
  1842. /// <summary>
  1843. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1844. /// </summary>
  1845. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1846. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1847. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  1848. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  1849. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  1850. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  1851. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1852. /// <param name="source1">First observable source.</param>
  1853. /// <param name="source2">Second observable source.</param>
  1854. /// <param name="source3">Third observable source.</param>
  1855. /// <param name="source4">Fourth observable source.</param>
  1856. /// <param name="source5">Fifth observable source.</param>
  1857. /// <param name="source6">Sixth observable source.</param>
  1858. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  1859. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1860. /// <exception cref="T:System.ArgumentNullException">
  1861. /// <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>
  1862. 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)
  1863. {
  1864. if (source1 == null)
  1865. throw new ArgumentNullException("source1");
  1866. if (source2 == null)
  1867. throw new ArgumentNullException("source2");
  1868. if (source3 == null)
  1869. throw new ArgumentNullException("source3");
  1870. if (source4 == null)
  1871. throw new ArgumentNullException("source4");
  1872. if (source5 == null)
  1873. throw new ArgumentNullException("source5");
  1874. if (source6 == null)
  1875. throw new ArgumentNullException("source6");
  1876. if (resultSelector == null)
  1877. throw new ArgumentNullException("resultSelector");
  1878. return source1.Provider.CreateQuery<TResult>(
  1879. Expression.Call(
  1880. null,
  1881. #if CRIPPLED_REFLECTION
  1882. 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>>))),
  1883. #else
  1884. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TResult)),
  1885. #endif
  1886. source1.Expression,
  1887. GetSourceExpression(source2),
  1888. GetSourceExpression(source3),
  1889. GetSourceExpression(source4),
  1890. GetSourceExpression(source5),
  1891. GetSourceExpression(source6),
  1892. resultSelector
  1893. )
  1894. );
  1895. }
  1896. #endif
  1897. #if !NO_LARGEARITY
  1898. /// <summary>
  1899. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1900. /// </summary>
  1901. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1902. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1903. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  1904. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  1905. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  1906. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  1907. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  1908. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1909. /// <param name="source1">First observable source.</param>
  1910. /// <param name="source2">Second observable source.</param>
  1911. /// <param name="source3">Third observable source.</param>
  1912. /// <param name="source4">Fourth observable source.</param>
  1913. /// <param name="source5">Fifth observable source.</param>
  1914. /// <param name="source6">Sixth observable source.</param>
  1915. /// <param name="source7">Seventh observable source.</param>
  1916. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  1917. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1918. /// <exception cref="T:System.ArgumentNullException">
  1919. /// <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>
  1920. 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)
  1921. {
  1922. if (source1 == null)
  1923. throw new ArgumentNullException("source1");
  1924. if (source2 == null)
  1925. throw new ArgumentNullException("source2");
  1926. if (source3 == null)
  1927. throw new ArgumentNullException("source3");
  1928. if (source4 == null)
  1929. throw new ArgumentNullException("source4");
  1930. if (source5 == null)
  1931. throw new ArgumentNullException("source5");
  1932. if (source6 == null)
  1933. throw new ArgumentNullException("source6");
  1934. if (source7 == null)
  1935. throw new ArgumentNullException("source7");
  1936. if (resultSelector == null)
  1937. throw new ArgumentNullException("resultSelector");
  1938. return source1.Provider.CreateQuery<TResult>(
  1939. Expression.Call(
  1940. null,
  1941. #if CRIPPLED_REFLECTION
  1942. 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>>))),
  1943. #else
  1944. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TResult)),
  1945. #endif
  1946. source1.Expression,
  1947. GetSourceExpression(source2),
  1948. GetSourceExpression(source3),
  1949. GetSourceExpression(source4),
  1950. GetSourceExpression(source5),
  1951. GetSourceExpression(source6),
  1952. GetSourceExpression(source7),
  1953. resultSelector
  1954. )
  1955. );
  1956. }
  1957. #endif
  1958. #if !NO_LARGEARITY
  1959. /// <summary>
  1960. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1961. /// </summary>
  1962. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1963. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1964. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  1965. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  1966. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  1967. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  1968. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  1969. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  1970. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1971. /// <param name="source1">First observable source.</param>
  1972. /// <param name="source2">Second observable source.</param>
  1973. /// <param name="source3">Third observable source.</param>
  1974. /// <param name="source4">Fourth observable source.</param>
  1975. /// <param name="source5">Fifth observable source.</param>
  1976. /// <param name="source6">Sixth observable source.</param>
  1977. /// <param name="source7">Seventh observable source.</param>
  1978. /// <param name="source8">Eighth observable source.</param>
  1979. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  1980. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1981. /// <exception cref="T:System.ArgumentNullException">
  1982. /// <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>
  1983. 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)
  1984. {
  1985. if (source1 == null)
  1986. throw new ArgumentNullException("source1");
  1987. if (source2 == null)
  1988. throw new ArgumentNullException("source2");
  1989. if (source3 == null)
  1990. throw new ArgumentNullException("source3");
  1991. if (source4 == null)
  1992. throw new ArgumentNullException("source4");
  1993. if (source5 == null)
  1994. throw new ArgumentNullException("source5");
  1995. if (source6 == null)
  1996. throw new ArgumentNullException("source6");
  1997. if (source7 == null)
  1998. throw new ArgumentNullException("source7");
  1999. if (source8 == null)
  2000. throw new ArgumentNullException("source8");
  2001. if (resultSelector == null)
  2002. throw new ArgumentNullException("resultSelector");
  2003. return source1.Provider.CreateQuery<TResult>(
  2004. Expression.Call(
  2005. null,
  2006. #if CRIPPLED_REFLECTION
  2007. 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>>))),
  2008. #else
  2009. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TResult)),
  2010. #endif
  2011. source1.Expression,
  2012. GetSourceExpression(source2),
  2013. GetSourceExpression(source3),
  2014. GetSourceExpression(source4),
  2015. GetSourceExpression(source5),
  2016. GetSourceExpression(source6),
  2017. GetSourceExpression(source7),
  2018. GetSourceExpression(source8),
  2019. resultSelector
  2020. )
  2021. );
  2022. }
  2023. #endif
  2024. #if !NO_LARGEARITY
  2025. /// <summary>
  2026. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2027. /// </summary>
  2028. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2029. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2030. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2031. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2032. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2033. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2034. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2035. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2036. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2037. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2038. /// <param name="source1">First observable source.</param>
  2039. /// <param name="source2">Second observable source.</param>
  2040. /// <param name="source3">Third observable source.</param>
  2041. /// <param name="source4">Fourth observable source.</param>
  2042. /// <param name="source5">Fifth observable source.</param>
  2043. /// <param name="source6">Sixth observable source.</param>
  2044. /// <param name="source7">Seventh observable source.</param>
  2045. /// <param name="source8">Eighth observable source.</param>
  2046. /// <param name="source9">Ninth observable source.</param>
  2047. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2048. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2049. /// <exception cref="T:System.ArgumentNullException">
  2050. /// <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>
  2051. 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)
  2052. {
  2053. if (source1 == null)
  2054. throw new ArgumentNullException("source1");
  2055. if (source2 == null)
  2056. throw new ArgumentNullException("source2");
  2057. if (source3 == null)
  2058. throw new ArgumentNullException("source3");
  2059. if (source4 == null)
  2060. throw new ArgumentNullException("source4");
  2061. if (source5 == null)
  2062. throw new ArgumentNullException("source5");
  2063. if (source6 == null)
  2064. throw new ArgumentNullException("source6");
  2065. if (source7 == null)
  2066. throw new ArgumentNullException("source7");
  2067. if (source8 == null)
  2068. throw new ArgumentNullException("source8");
  2069. if (source9 == null)
  2070. throw new ArgumentNullException("source9");
  2071. if (resultSelector == null)
  2072. throw new ArgumentNullException("resultSelector");
  2073. return source1.Provider.CreateQuery<TResult>(
  2074. Expression.Call(
  2075. null,
  2076. #if CRIPPLED_REFLECTION
  2077. 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>>))),
  2078. #else
  2079. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TSource9), typeof(TResult)),
  2080. #endif
  2081. source1.Expression,
  2082. GetSourceExpression(source2),
  2083. GetSourceExpression(source3),
  2084. GetSourceExpression(source4),
  2085. GetSourceExpression(source5),
  2086. GetSourceExpression(source6),
  2087. GetSourceExpression(source7),
  2088. GetSourceExpression(source8),
  2089. GetSourceExpression(source9),
  2090. resultSelector
  2091. )
  2092. );
  2093. }
  2094. #endif
  2095. #if !NO_LARGEARITY
  2096. /// <summary>
  2097. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2098. /// </summary>
  2099. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2100. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2101. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2102. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2103. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2104. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2105. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2106. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2107. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2108. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2109. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2110. /// <param name="source1">First observable source.</param>
  2111. /// <param name="source2">Second observable source.</param>
  2112. /// <param name="source3">Third observable source.</param>
  2113. /// <param name="source4">Fourth observable source.</param>
  2114. /// <param name="source5">Fifth observable source.</param>
  2115. /// <param name="source6">Sixth observable source.</param>
  2116. /// <param name="source7">Seventh observable source.</param>
  2117. /// <param name="source8">Eighth observable source.</param>
  2118. /// <param name="source9">Ninth observable source.</param>
  2119. /// <param name="source10">Tenth observable source.</param>
  2120. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2121. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2122. /// <exception cref="T:System.ArgumentNullException">
  2123. /// <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>
  2124. 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)
  2125. {
  2126. if (source1 == null)
  2127. throw new ArgumentNullException("source1");
  2128. if (source2 == null)
  2129. throw new ArgumentNullException("source2");
  2130. if (source3 == null)
  2131. throw new ArgumentNullException("source3");
  2132. if (source4 == null)
  2133. throw new ArgumentNullException("source4");
  2134. if (source5 == null)
  2135. throw new ArgumentNullException("source5");
  2136. if (source6 == null)
  2137. throw new ArgumentNullException("source6");
  2138. if (source7 == null)
  2139. throw new ArgumentNullException("source7");
  2140. if (source8 == null)
  2141. throw new ArgumentNullException("source8");
  2142. if (source9 == null)
  2143. throw new ArgumentNullException("source9");
  2144. if (source10 == null)
  2145. throw new ArgumentNullException("source10");
  2146. if (resultSelector == null)
  2147. throw new ArgumentNullException("resultSelector");
  2148. return source1.Provider.CreateQuery<TResult>(
  2149. Expression.Call(
  2150. null,
  2151. #if CRIPPLED_REFLECTION
  2152. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, 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>>))),
  2153. #else
  2154. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TSource9), typeof(TSource10), typeof(TResult)),
  2155. #endif
  2156. source1.Expression,
  2157. GetSourceExpression(source2),
  2158. GetSourceExpression(source3),
  2159. GetSourceExpression(source4),
  2160. GetSourceExpression(source5),
  2161. GetSourceExpression(source6),
  2162. GetSourceExpression(source7),
  2163. GetSourceExpression(source8),
  2164. GetSourceExpression(source9),
  2165. GetSourceExpression(source10),
  2166. resultSelector
  2167. )
  2168. );
  2169. }
  2170. #endif
  2171. #if !NO_LARGEARITY
  2172. /// <summary>
  2173. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2174. /// </summary>
  2175. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2176. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2177. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2178. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2179. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2180. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2181. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2182. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2183. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2184. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2185. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  2186. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2187. /// <param name="source1">First observable source.</param>
  2188. /// <param name="source2">Second observable source.</param>
  2189. /// <param name="source3">Third observable source.</param>
  2190. /// <param name="source4">Fourth observable source.</param>
  2191. /// <param name="source5">Fifth observable source.</param>
  2192. /// <param name="source6">Sixth observable source.</param>
  2193. /// <param name="source7">Seventh observable source.</param>
  2194. /// <param name="source8">Eighth observable source.</param>
  2195. /// <param name="source9">Ninth observable source.</param>
  2196. /// <param name="source10">Tenth observable source.</param>
  2197. /// <param name="source11">Eleventh observable source.</param>
  2198. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2199. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2200. /// <exception cref="T:System.ArgumentNullException">
  2201. /// <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>
  2202. 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)
  2203. {
  2204. if (source1 == null)
  2205. throw new ArgumentNullException("source1");
  2206. if (source2 == null)
  2207. throw new ArgumentNullException("source2");
  2208. if (source3 == null)
  2209. throw new ArgumentNullException("source3");
  2210. if (source4 == null)
  2211. throw new ArgumentNullException("source4");
  2212. if (source5 == null)
  2213. throw new ArgumentNullException("source5");
  2214. if (source6 == null)
  2215. throw new ArgumentNullException("source6");
  2216. if (source7 == null)
  2217. throw new ArgumentNullException("source7");
  2218. if (source8 == null)
  2219. throw new ArgumentNullException("source8");
  2220. if (source9 == null)
  2221. throw new ArgumentNullException("source9");
  2222. if (source10 == null)
  2223. throw new ArgumentNullException("source10");
  2224. if (source11 == null)
  2225. throw new ArgumentNullException("source11");
  2226. if (resultSelector == null)
  2227. throw new ArgumentNullException("resultSelector");
  2228. return source1.Provider.CreateQuery<TResult>(
  2229. Expression.Call(
  2230. null,
  2231. #if CRIPPLED_REFLECTION
  2232. 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>>))),
  2233. #else
  2234. ((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)),
  2235. #endif
  2236. source1.Expression,
  2237. GetSourceExpression(source2),
  2238. GetSourceExpression(source3),
  2239. GetSourceExpression(source4),
  2240. GetSourceExpression(source5),
  2241. GetSourceExpression(source6),
  2242. GetSourceExpression(source7),
  2243. GetSourceExpression(source8),
  2244. GetSourceExpression(source9),
  2245. GetSourceExpression(source10),
  2246. GetSourceExpression(source11),
  2247. resultSelector
  2248. )
  2249. );
  2250. }
  2251. #endif
  2252. #if !NO_LARGEARITY
  2253. /// <summary>
  2254. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2255. /// </summary>
  2256. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2257. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2258. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2259. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2260. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2261. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2262. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2263. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2264. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2265. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2266. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  2267. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  2268. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2269. /// <param name="source1">First observable source.</param>
  2270. /// <param name="source2">Second observable source.</param>
  2271. /// <param name="source3">Third observable source.</param>
  2272. /// <param name="source4">Fourth observable source.</param>
  2273. /// <param name="source5">Fifth observable source.</param>
  2274. /// <param name="source6">Sixth observable source.</param>
  2275. /// <param name="source7">Seventh observable source.</param>
  2276. /// <param name="source8">Eighth observable source.</param>
  2277. /// <param name="source9">Ninth observable source.</param>
  2278. /// <param name="source10">Tenth observable source.</param>
  2279. /// <param name="source11">Eleventh observable source.</param>
  2280. /// <param name="source12">Twelfth observable source.</param>
  2281. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2282. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2283. /// <exception cref="T:System.ArgumentNullException">
  2284. /// <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>
  2285. 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)
  2286. {
  2287. if (source1 == null)
  2288. throw new ArgumentNullException("source1");
  2289. if (source2 == null)
  2290. throw new ArgumentNullException("source2");
  2291. if (source3 == null)
  2292. throw new ArgumentNullException("source3");
  2293. if (source4 == null)
  2294. throw new ArgumentNullException("source4");
  2295. if (source5 == null)
  2296. throw new ArgumentNullException("source5");
  2297. if (source6 == null)
  2298. throw new ArgumentNullException("source6");
  2299. if (source7 == null)
  2300. throw new ArgumentNullException("source7");
  2301. if (source8 == null)
  2302. throw new ArgumentNullException("source8");
  2303. if (source9 == null)
  2304. throw new ArgumentNullException("source9");
  2305. if (source10 == null)
  2306. throw new ArgumentNullException("source10");
  2307. if (source11 == null)
  2308. throw new ArgumentNullException("source11");
  2309. if (source12 == null)
  2310. throw new ArgumentNullException("source12");
  2311. if (resultSelector == null)
  2312. throw new ArgumentNullException("resultSelector");
  2313. return source1.Provider.CreateQuery<TResult>(
  2314. Expression.Call(
  2315. null,
  2316. #if CRIPPLED_REFLECTION
  2317. 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>>))),
  2318. #else
  2319. ((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)),
  2320. #endif
  2321. source1.Expression,
  2322. GetSourceExpression(source2),
  2323. GetSourceExpression(source3),
  2324. GetSourceExpression(source4),
  2325. GetSourceExpression(source5),
  2326. GetSourceExpression(source6),
  2327. GetSourceExpression(source7),
  2328. GetSourceExpression(source8),
  2329. GetSourceExpression(source9),
  2330. GetSourceExpression(source10),
  2331. GetSourceExpression(source11),
  2332. GetSourceExpression(source12),
  2333. resultSelector
  2334. )
  2335. );
  2336. }
  2337. #endif
  2338. #if !NO_LARGEARITY
  2339. /// <summary>
  2340. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2341. /// </summary>
  2342. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2343. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2344. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2345. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2346. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2347. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2348. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2349. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2350. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2351. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2352. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  2353. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  2354. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  2355. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2356. /// <param name="source1">First observable source.</param>
  2357. /// <param name="source2">Second observable source.</param>
  2358. /// <param name="source3">Third observable source.</param>
  2359. /// <param name="source4">Fourth observable source.</param>
  2360. /// <param name="source5">Fifth observable source.</param>
  2361. /// <param name="source6">Sixth observable source.</param>
  2362. /// <param name="source7">Seventh observable source.</param>
  2363. /// <param name="source8">Eighth observable source.</param>
  2364. /// <param name="source9">Ninth observable source.</param>
  2365. /// <param name="source10">Tenth observable source.</param>
  2366. /// <param name="source11">Eleventh observable source.</param>
  2367. /// <param name="source12">Twelfth observable source.</param>
  2368. /// <param name="source13">Thirteenth observable source.</param>
  2369. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2370. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2371. /// <exception cref="T:System.ArgumentNullException">
  2372. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="source6" /> or <paramref name="source7" /> or <paramref name="source8" /> or <paramref name="source9" /> or <paramref name="source10" /> or <paramref name="source11" /> or <paramref name="source12" /> or <paramref name="source13" /> or <paramref name="resultSelector" /> is null.</exception>
  2373. 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)
  2374. {
  2375. if (source1 == null)
  2376. throw new ArgumentNullException("source1");
  2377. if (source2 == null)
  2378. throw new ArgumentNullException("source2");
  2379. if (source3 == null)
  2380. throw new ArgumentNullException("source3");
  2381. if (source4 == null)
  2382. throw new ArgumentNullException("source4");
  2383. if (source5 == null)
  2384. throw new ArgumentNullException("source5");
  2385. if (source6 == null)
  2386. throw new ArgumentNullException("source6");
  2387. if (source7 == null)
  2388. throw new ArgumentNullException("source7");
  2389. if (source8 == null)
  2390. throw new ArgumentNullException("source8");
  2391. if (source9 == null)
  2392. throw new ArgumentNullException("source9");
  2393. if (source10 == null)
  2394. throw new ArgumentNullException("source10");
  2395. if (source11 == null)
  2396. throw new ArgumentNullException("source11");
  2397. if (source12 == null)
  2398. throw new ArgumentNullException("source12");
  2399. if (source13 == null)
  2400. throw new ArgumentNullException("source13");
  2401. if (resultSelector == null)
  2402. throw new ArgumentNullException("resultSelector");
  2403. return source1.Provider.CreateQuery<TResult>(
  2404. Expression.Call(
  2405. null,
  2406. #if CRIPPLED_REFLECTION
  2407. 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>>))),
  2408. #else
  2409. ((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)),
  2410. #endif
  2411. source1.Expression,
  2412. GetSourceExpression(source2),
  2413. GetSourceExpression(source3),
  2414. GetSourceExpression(source4),
  2415. GetSourceExpression(source5),
  2416. GetSourceExpression(source6),
  2417. GetSourceExpression(source7),
  2418. GetSourceExpression(source8),
  2419. GetSourceExpression(source9),
  2420. GetSourceExpression(source10),
  2421. GetSourceExpression(source11),
  2422. GetSourceExpression(source12),
  2423. GetSourceExpression(source13),
  2424. resultSelector
  2425. )
  2426. );
  2427. }
  2428. #endif
  2429. #if !NO_LARGEARITY
  2430. /// <summary>
  2431. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2432. /// </summary>
  2433. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2434. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2435. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2436. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2437. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2438. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2439. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2440. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2441. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2442. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2443. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  2444. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  2445. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  2446. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  2447. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2448. /// <param name="source1">First observable source.</param>
  2449. /// <param name="source2">Second observable source.</param>
  2450. /// <param name="source3">Third observable source.</param>
  2451. /// <param name="source4">Fourth observable source.</param>
  2452. /// <param name="source5">Fifth observable source.</param>
  2453. /// <param name="source6">Sixth observable source.</param>
  2454. /// <param name="source7">Seventh observable source.</param>
  2455. /// <param name="source8">Eighth observable source.</param>
  2456. /// <param name="source9">Ninth observable source.</param>
  2457. /// <param name="source10">Tenth observable source.</param>
  2458. /// <param name="source11">Eleventh observable source.</param>
  2459. /// <param name="source12">Twelfth observable source.</param>
  2460. /// <param name="source13">Thirteenth observable source.</param>
  2461. /// <param name="source14">Fourteenth observable source.</param>
  2462. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2463. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2464. /// <exception cref="T:System.ArgumentNullException">
  2465. /// <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>
  2466. 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)
  2467. {
  2468. if (source1 == null)
  2469. throw new ArgumentNullException("source1");
  2470. if (source2 == null)
  2471. throw new ArgumentNullException("source2");
  2472. if (source3 == null)
  2473. throw new ArgumentNullException("source3");
  2474. if (source4 == null)
  2475. throw new ArgumentNullException("source4");
  2476. if (source5 == null)
  2477. throw new ArgumentNullException("source5");
  2478. if (source6 == null)
  2479. throw new ArgumentNullException("source6");
  2480. if (source7 == null)
  2481. throw new ArgumentNullException("source7");
  2482. if (source8 == null)
  2483. throw new ArgumentNullException("source8");
  2484. if (source9 == null)
  2485. throw new ArgumentNullException("source9");
  2486. if (source10 == null)
  2487. throw new ArgumentNullException("source10");
  2488. if (source11 == null)
  2489. throw new ArgumentNullException("source11");
  2490. if (source12 == null)
  2491. throw new ArgumentNullException("source12");
  2492. if (source13 == null)
  2493. throw new ArgumentNullException("source13");
  2494. if (source14 == null)
  2495. throw new ArgumentNullException("source14");
  2496. if (resultSelector == null)
  2497. throw new ArgumentNullException("resultSelector");
  2498. return source1.Provider.CreateQuery<TResult>(
  2499. Expression.Call(
  2500. null,
  2501. #if CRIPPLED_REFLECTION
  2502. 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>>))),
  2503. #else
  2504. ((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)),
  2505. #endif
  2506. source1.Expression,
  2507. GetSourceExpression(source2),
  2508. GetSourceExpression(source3),
  2509. GetSourceExpression(source4),
  2510. GetSourceExpression(source5),
  2511. GetSourceExpression(source6),
  2512. GetSourceExpression(source7),
  2513. GetSourceExpression(source8),
  2514. GetSourceExpression(source9),
  2515. GetSourceExpression(source10),
  2516. GetSourceExpression(source11),
  2517. GetSourceExpression(source12),
  2518. GetSourceExpression(source13),
  2519. GetSourceExpression(source14),
  2520. resultSelector
  2521. )
  2522. );
  2523. }
  2524. #endif
  2525. #if !NO_LARGEARITY
  2526. /// <summary>
  2527. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2528. /// </summary>
  2529. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2530. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2531. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2532. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2533. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2534. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2535. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2536. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2537. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2538. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2539. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  2540. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  2541. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  2542. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  2543. /// <typeparam name="TSource15">The type of the elements in the fifteenth source sequence.</typeparam>
  2544. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2545. /// <param name="source1">First observable source.</param>
  2546. /// <param name="source2">Second observable source.</param>
  2547. /// <param name="source3">Third observable source.</param>
  2548. /// <param name="source4">Fourth observable source.</param>
  2549. /// <param name="source5">Fifth observable source.</param>
  2550. /// <param name="source6">Sixth observable source.</param>
  2551. /// <param name="source7">Seventh observable source.</param>
  2552. /// <param name="source8">Eighth observable source.</param>
  2553. /// <param name="source9">Ninth observable source.</param>
  2554. /// <param name="source10">Tenth observable source.</param>
  2555. /// <param name="source11">Eleventh observable source.</param>
  2556. /// <param name="source12">Twelfth observable source.</param>
  2557. /// <param name="source13">Thirteenth observable source.</param>
  2558. /// <param name="source14">Fourteenth observable source.</param>
  2559. /// <param name="source15">Fifteenth observable source.</param>
  2560. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2561. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2562. /// <exception cref="T:System.ArgumentNullException">
  2563. /// <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>
  2564. 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)
  2565. {
  2566. if (source1 == null)
  2567. throw new ArgumentNullException("source1");
  2568. if (source2 == null)
  2569. throw new ArgumentNullException("source2");
  2570. if (source3 == null)
  2571. throw new ArgumentNullException("source3");
  2572. if (source4 == null)
  2573. throw new ArgumentNullException("source4");
  2574. if (source5 == null)
  2575. throw new ArgumentNullException("source5");
  2576. if (source6 == null)
  2577. throw new ArgumentNullException("source6");
  2578. if (source7 == null)
  2579. throw new ArgumentNullException("source7");
  2580. if (source8 == null)
  2581. throw new ArgumentNullException("source8");
  2582. if (source9 == null)
  2583. throw new ArgumentNullException("source9");
  2584. if (source10 == null)
  2585. throw new ArgumentNullException("source10");
  2586. if (source11 == null)
  2587. throw new ArgumentNullException("source11");
  2588. if (source12 == null)
  2589. throw new ArgumentNullException("source12");
  2590. if (source13 == null)
  2591. throw new ArgumentNullException("source13");
  2592. if (source14 == null)
  2593. throw new ArgumentNullException("source14");
  2594. if (source15 == null)
  2595. throw new ArgumentNullException("source15");
  2596. if (resultSelector == null)
  2597. throw new ArgumentNullException("resultSelector");
  2598. return source1.Provider.CreateQuery<TResult>(
  2599. Expression.Call(
  2600. null,
  2601. #if CRIPPLED_REFLECTION
  2602. 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>>))),
  2603. #else
  2604. ((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)),
  2605. #endif
  2606. source1.Expression,
  2607. GetSourceExpression(source2),
  2608. GetSourceExpression(source3),
  2609. GetSourceExpression(source4),
  2610. GetSourceExpression(source5),
  2611. GetSourceExpression(source6),
  2612. GetSourceExpression(source7),
  2613. GetSourceExpression(source8),
  2614. GetSourceExpression(source9),
  2615. GetSourceExpression(source10),
  2616. GetSourceExpression(source11),
  2617. GetSourceExpression(source12),
  2618. GetSourceExpression(source13),
  2619. GetSourceExpression(source14),
  2620. GetSourceExpression(source15),
  2621. resultSelector
  2622. )
  2623. );
  2624. }
  2625. #endif
  2626. #if !NO_LARGEARITY
  2627. /// <summary>
  2628. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2629. /// </summary>
  2630. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2631. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2632. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2633. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2634. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2635. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2636. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2637. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2638. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2639. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2640. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  2641. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  2642. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  2643. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  2644. /// <typeparam name="TSource15">The type of the elements in the fifteenth source sequence.</typeparam>
  2645. /// <typeparam name="TSource16">The type of the elements in the sixteenth source sequence.</typeparam>
  2646. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2647. /// <param name="source1">First observable source.</param>
  2648. /// <param name="source2">Second observable source.</param>
  2649. /// <param name="source3">Third observable source.</param>
  2650. /// <param name="source4">Fourth observable source.</param>
  2651. /// <param name="source5">Fifth observable source.</param>
  2652. /// <param name="source6">Sixth observable source.</param>
  2653. /// <param name="source7">Seventh observable source.</param>
  2654. /// <param name="source8">Eighth observable source.</param>
  2655. /// <param name="source9">Ninth observable source.</param>
  2656. /// <param name="source10">Tenth observable source.</param>
  2657. /// <param name="source11">Eleventh observable source.</param>
  2658. /// <param name="source12">Twelfth observable source.</param>
  2659. /// <param name="source13">Thirteenth observable source.</param>
  2660. /// <param name="source14">Fourteenth observable source.</param>
  2661. /// <param name="source15">Fifteenth observable source.</param>
  2662. /// <param name="source16">Sixteenth observable source.</param>
  2663. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2664. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2665. /// <exception cref="T:System.ArgumentNullException">
  2666. /// <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>
  2667. 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)
  2668. {
  2669. if (source1 == null)
  2670. throw new ArgumentNullException("source1");
  2671. if (source2 == null)
  2672. throw new ArgumentNullException("source2");
  2673. if (source3 == null)
  2674. throw new ArgumentNullException("source3");
  2675. if (source4 == null)
  2676. throw new ArgumentNullException("source4");
  2677. if (source5 == null)
  2678. throw new ArgumentNullException("source5");
  2679. if (source6 == null)
  2680. throw new ArgumentNullException("source6");
  2681. if (source7 == null)
  2682. throw new ArgumentNullException("source7");
  2683. if (source8 == null)
  2684. throw new ArgumentNullException("source8");
  2685. if (source9 == null)
  2686. throw new ArgumentNullException("source9");
  2687. if (source10 == null)
  2688. throw new ArgumentNullException("source10");
  2689. if (source11 == null)
  2690. throw new ArgumentNullException("source11");
  2691. if (source12 == null)
  2692. throw new ArgumentNullException("source12");
  2693. if (source13 == null)
  2694. throw new ArgumentNullException("source13");
  2695. if (source14 == null)
  2696. throw new ArgumentNullException("source14");
  2697. if (source15 == null)
  2698. throw new ArgumentNullException("source15");
  2699. if (source16 == null)
  2700. throw new ArgumentNullException("source16");
  2701. if (resultSelector == null)
  2702. throw new ArgumentNullException("resultSelector");
  2703. return source1.Provider.CreateQuery<TResult>(
  2704. Expression.Call(
  2705. null,
  2706. #if CRIPPLED_REFLECTION
  2707. 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>>))),
  2708. #else
  2709. ((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)),
  2710. #endif
  2711. source1.Expression,
  2712. GetSourceExpression(source2),
  2713. GetSourceExpression(source3),
  2714. GetSourceExpression(source4),
  2715. GetSourceExpression(source5),
  2716. GetSourceExpression(source6),
  2717. GetSourceExpression(source7),
  2718. GetSourceExpression(source8),
  2719. GetSourceExpression(source9),
  2720. GetSourceExpression(source10),
  2721. GetSourceExpression(source11),
  2722. GetSourceExpression(source12),
  2723. GetSourceExpression(source13),
  2724. GetSourceExpression(source14),
  2725. GetSourceExpression(source15),
  2726. GetSourceExpression(source16),
  2727. resultSelector
  2728. )
  2729. );
  2730. }
  2731. #endif
  2732. /// <summary>
  2733. /// Concatenates the second observable sequence to the first observable sequence upon successful termination of the first.
  2734. /// </summary>
  2735. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  2736. /// <param name="first">First observable sequence.</param>
  2737. /// <param name="second">Second observable sequence.</param>
  2738. /// <returns>An observable sequence that contains the elements of the first sequence, followed by those of the second the sequence.</returns>
  2739. /// <exception cref="T:System.ArgumentNullException">
  2740. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  2741. public static IQbservable<TSource> Concat<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  2742. {
  2743. if (first == null)
  2744. throw new ArgumentNullException("first");
  2745. if (second == null)
  2746. throw new ArgumentNullException("second");
  2747. return first.Provider.CreateQuery<TSource>(
  2748. Expression.Call(
  2749. null,
  2750. #if CRIPPLED_REFLECTION
  2751. InfoOf(() => Qbservable.Concat<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  2752. #else
  2753. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2754. #endif
  2755. first.Expression,
  2756. GetSourceExpression(second)
  2757. )
  2758. );
  2759. }
  2760. /// <summary>
  2761. /// Concatenates all of the specified observable sequences, as long as the previous observable sequence terminated successfully.
  2762. /// </summary>
  2763. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  2764. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  2765. /// <param name="sources">Observable sequences to concatenate.</param>
  2766. /// <returns>An observable sequence that contains the elements of each given sequence, in sequential order.</returns>
  2767. /// <exception cref="T:System.ArgumentNullException">
  2768. /// <paramref name="sources" /> is null.</exception>
  2769. public static IQbservable<TSource> Concat<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  2770. {
  2771. if (provider == null)
  2772. throw new ArgumentNullException("provider");
  2773. if (sources == null)
  2774. throw new ArgumentNullException("sources");
  2775. return provider.CreateQuery<TSource>(
  2776. Expression.Call(
  2777. null,
  2778. #if CRIPPLED_REFLECTION
  2779. InfoOf(() => Qbservable.Concat<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  2780. #else
  2781. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2782. #endif
  2783. Expression.Constant(provider, typeof(IQbservableProvider)),
  2784. GetSourceExpression(sources)
  2785. )
  2786. );
  2787. }
  2788. /// <summary>
  2789. /// Concatenates all observable sequences in the given enumerable sequence, as long as the previous observable sequence terminated successfully.
  2790. /// </summary>
  2791. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  2792. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  2793. /// <param name="sources">Observable sequences to concatenate.</param>
  2794. /// <returns>An observable sequence that contains the elements of each given sequence, in sequential order.</returns>
  2795. /// <exception cref="T:System.ArgumentNullException">
  2796. /// <paramref name="sources" /> is null.</exception>
  2797. public static IQbservable<TSource> Concat<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  2798. {
  2799. if (provider == null)
  2800. throw new ArgumentNullException("provider");
  2801. if (sources == null)
  2802. throw new ArgumentNullException("sources");
  2803. return provider.CreateQuery<TSource>(
  2804. Expression.Call(
  2805. null,
  2806. #if CRIPPLED_REFLECTION
  2807. InfoOf(() => Qbservable.Concat<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  2808. #else
  2809. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2810. #endif
  2811. Expression.Constant(provider, typeof(IQbservableProvider)),
  2812. GetSourceExpression(sources)
  2813. )
  2814. );
  2815. }
  2816. /// <summary>
  2817. /// Concatenates all inner observable sequences, as long as the previous observable sequence terminated successfully.
  2818. /// </summary>
  2819. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  2820. /// <param name="sources">Observable sequence of inner observable sequences.</param>
  2821. /// <returns>An observable sequence that contains the elements of each observed inner sequence, in sequential order.</returns>
  2822. /// <exception cref="T:System.ArgumentNullException">
  2823. /// <paramref name="sources" /> is null.</exception>
  2824. public static IQbservable<TSource> Concat<TSource>(this IQbservable<IObservable<TSource>> sources)
  2825. {
  2826. if (sources == null)
  2827. throw new ArgumentNullException("sources");
  2828. return sources.Provider.CreateQuery<TSource>(
  2829. Expression.Call(
  2830. null,
  2831. #if CRIPPLED_REFLECTION
  2832. InfoOf(() => Qbservable.Concat<TSource>(default(IQbservable<IObservable<TSource>>))),
  2833. #else
  2834. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2835. #endif
  2836. sources.Expression
  2837. )
  2838. );
  2839. }
  2840. #if !NO_TPL
  2841. /// <summary>
  2842. /// Concatenates all task results, as long as the previous task terminated successfully.
  2843. /// </summary>
  2844. /// <typeparam name="TSource">The type of the results produced by the tasks.</typeparam>
  2845. /// <param name="sources">Observable sequence of tasks.</param>
  2846. /// <returns>An observable sequence that contains the results of each task, in sequential order.</returns>
  2847. /// <exception cref="T:System.ArgumentNullException">
  2848. /// <paramref name="sources" /> is null.</exception>
  2849. /// <remarks>If the tasks support cancellation, consider manual conversion of the tasks using <see cref="M:System.Reactive.Linq.Observable.FromAsync``1(System.Func{System.Threading.CancellationToken,System.Threading.Tasks.Task{``0}})" />, followed by a concatenation operation using <see cref="M:System.Reactive.Linq.Observable.Concat``1(System.IObservable{System.IObservable{``0}})" />.</remarks>
  2850. public static IQbservable<TSource> Concat<TSource>(this IQbservable<Task<TSource>> sources)
  2851. {
  2852. if (sources == null)
  2853. throw new ArgumentNullException("sources");
  2854. return sources.Provider.CreateQuery<TSource>(
  2855. Expression.Call(
  2856. null,
  2857. #if CRIPPLED_REFLECTION
  2858. InfoOf(() => Qbservable.Concat<TSource>(default(IQbservable<Task<TSource>>))),
  2859. #else
  2860. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2861. #endif
  2862. sources.Expression
  2863. )
  2864. );
  2865. }
  2866. #endif
  2867. /// <summary>
  2868. /// Determines whether an observable sequence contains a specified element by using the default equality comparer.
  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. /// <returns>An observable sequence containing a single element determining whether the source sequence contains an element that has the specified value.</returns>
  2874. /// <exception cref="T:System.ArgumentNullException">
  2875. /// <paramref name="source" /> is null.</exception>
  2876. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  2877. public static IQbservable<bool> Contains<TSource>(this IQbservable<TSource> source, TSource value)
  2878. {
  2879. if (source == null)
  2880. throw new ArgumentNullException("source");
  2881. return source.Provider.CreateQuery<bool>(
  2882. Expression.Call(
  2883. null,
  2884. #if CRIPPLED_REFLECTION
  2885. InfoOf(() => Qbservable.Contains<TSource>(default(IQbservable<TSource>), default(TSource))),
  2886. #else
  2887. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2888. #endif
  2889. source.Expression,
  2890. Expression.Constant(value, typeof(TSource))
  2891. )
  2892. );
  2893. }
  2894. /// <summary>
  2895. /// Determines whether an observable sequence contains a specified element by using a specified System.Collections.Generic.IEqualityComparer&lt;T&gt;.
  2896. /// </summary>
  2897. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  2898. /// <param name="source">An observable sequence in which to locate a value.</param>
  2899. /// <param name="value">The value to locate in the source sequence.</param>
  2900. /// <param name="comparer">An equality comparer to compare elements.</param>
  2901. /// <returns>An observable sequence containing a single element determining whether the source sequence contains an element that has the specified value.</returns>
  2902. /// <exception cref="T:System.ArgumentNullException">
  2903. /// <paramref name="source" /> or <paramref name="comparer" /> is null.</exception>
  2904. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  2905. public static IQbservable<bool> Contains<TSource>(this IQbservable<TSource> source, TSource value, IEqualityComparer<TSource> comparer)
  2906. {
  2907. if (source == null)
  2908. throw new ArgumentNullException("source");
  2909. if (comparer == null)
  2910. throw new ArgumentNullException("comparer");
  2911. return source.Provider.CreateQuery<bool>(
  2912. Expression.Call(
  2913. null,
  2914. #if CRIPPLED_REFLECTION
  2915. InfoOf(() => Qbservable.Contains<TSource>(default(IQbservable<TSource>), default(TSource), default(IEqualityComparer<TSource>))),
  2916. #else
  2917. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2918. #endif
  2919. source.Expression,
  2920. Expression.Constant(value, typeof(TSource)),
  2921. Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))
  2922. )
  2923. );
  2924. }
  2925. /// <summary>
  2926. /// Returns an observable sequence containing an <see cref="T:System.Int32" /> that represents the total number of elements in an observable sequence.
  2927. /// </summary>
  2928. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  2929. /// <param name="source">An observable sequence that contains elements to be counted.</param>
  2930. /// <returns>An observable sequence containing a single element with the number of elements in the input sequence.</returns>
  2931. /// <exception cref="T:System.ArgumentNullException">
  2932. /// <paramref name="source" /> is null.</exception>
  2933. /// <exception cref="T:System.OverflowException">(Asynchronous) The number of elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue" />.</exception>
  2934. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  2935. public static IQbservable<int> Count<TSource>(this IQbservable<TSource> source)
  2936. {
  2937. if (source == null)
  2938. throw new ArgumentNullException("source");
  2939. return source.Provider.CreateQuery<int>(
  2940. Expression.Call(
  2941. null,
  2942. #if CRIPPLED_REFLECTION
  2943. InfoOf(() => Qbservable.Count<TSource>(default(IQbservable<TSource>))),
  2944. #else
  2945. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2946. #endif
  2947. source.Expression
  2948. )
  2949. );
  2950. }
  2951. /// <summary>
  2952. /// Returns an observable sequence containing an <see cref="T:System.Int32" /> that represents how many elements in the specified observable sequence satisfy a condition.
  2953. /// </summary>
  2954. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  2955. /// <param name="source">An observable sequence that contains elements to be counted.</param>
  2956. /// <param name="predicate">A function to test each element for a condition.</param>
  2957. /// <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>
  2958. /// <exception cref="T:System.ArgumentNullException">
  2959. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  2960. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  2961. public static IQbservable<int> Count<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  2962. {
  2963. if (source == null)
  2964. throw new ArgumentNullException("source");
  2965. if (predicate == null)
  2966. throw new ArgumentNullException("predicate");
  2967. return source.Provider.CreateQuery<int>(
  2968. Expression.Call(
  2969. null,
  2970. #if CRIPPLED_REFLECTION
  2971. InfoOf(() => Qbservable.Count<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  2972. #else
  2973. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2974. #endif
  2975. source.Expression,
  2976. predicate
  2977. )
  2978. );
  2979. }
  2980. /// <summary>
  2981. /// Creates an observable sequence from a specified Subscribe method implementation.
  2982. /// </summary>
  2983. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  2984. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  2985. /// <param name="subscribe">Implementation of the resulting observable sequence's Subscribe method.</param>
  2986. /// <returns>The observable sequence with the specified implementation for the Subscribe method.</returns>
  2987. /// <exception cref="T:System.ArgumentNullException">
  2988. /// <paramref name="subscribe" /> is null.</exception>
  2989. /// <remarks>
  2990. /// Use of this operator is preferred over manual implementation of the IObservable&lt;T&gt; interface. In case
  2991. /// you need a type implementing IObservable&lt;T&gt; rather than an anonymous implementation, consider using
  2992. /// the <see cref="T:System.Reactive.ObservableBase`1" /> abstract base class.
  2993. /// </remarks>
  2994. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, IDisposable>> subscribe)
  2995. {
  2996. if (provider == null)
  2997. throw new ArgumentNullException("provider");
  2998. if (subscribe == null)
  2999. throw new ArgumentNullException("subscribe");
  3000. return provider.CreateQuery<TResult>(
  3001. Expression.Call(
  3002. null,
  3003. #if CRIPPLED_REFLECTION
  3004. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, IDisposable>>))),
  3005. #else
  3006. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3007. #endif
  3008. Expression.Constant(provider, typeof(IQbservableProvider)),
  3009. subscribe
  3010. )
  3011. );
  3012. }
  3013. /// <summary>
  3014. /// Creates an observable sequence from a specified Subscribe method implementation.
  3015. /// </summary>
  3016. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  3017. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3018. /// <param name="subscribe">Implementation of the resulting observable sequence's Subscribe method, returning an Action delegate that will be wrapped in an IDisposable.</param>
  3019. /// <returns>The observable sequence with the specified implementation for the Subscribe method.</returns>
  3020. /// <exception cref="T:System.ArgumentNullException">
  3021. /// <paramref name="subscribe" /> is null.</exception>
  3022. /// <remarks>
  3023. /// Use of this operator is preferred over manual implementation of the IObservable&lt;T&gt; interface. In case
  3024. /// you need a type implementing IObservable&lt;T&gt; rather than an anonymous implementation, consider using
  3025. /// the <see cref="T:System.Reactive.ObservableBase`1" /> abstract base class.
  3026. /// </remarks>
  3027. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, Action>> subscribe)
  3028. {
  3029. if (provider == null)
  3030. throw new ArgumentNullException("provider");
  3031. if (subscribe == null)
  3032. throw new ArgumentNullException("subscribe");
  3033. return provider.CreateQuery<TResult>(
  3034. Expression.Call(
  3035. null,
  3036. #if CRIPPLED_REFLECTION
  3037. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, Action>>))),
  3038. #else
  3039. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3040. #endif
  3041. Expression.Constant(provider, typeof(IQbservableProvider)),
  3042. subscribe
  3043. )
  3044. );
  3045. }
  3046. #if !NO_TPL
  3047. /// <summary>
  3048. /// Creates an observable sequence from a specified cancellable asynchronous Subscribe method.
  3049. /// The CancellationToken passed to the asynchronous Subscribe method is tied to the returned disposable subscription, allowing best-effort cancellation.
  3050. /// </summary>
  3051. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  3052. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3053. /// <param name="subscribeAsync">Asynchronous method used to produce elements.</param>
  3054. /// <returns>The observable sequence surfacing the elements produced by the asynchronous method.</returns>
  3055. /// <exception cref="T:System.ArgumentNullException">
  3056. /// <paramref name="subscribeAsync" /> is null.</exception>
  3057. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3058. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous subscribe function will be signaled.</remarks>
  3059. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, CancellationToken, Task>> subscribeAsync)
  3060. {
  3061. if (provider == null)
  3062. throw new ArgumentNullException("provider");
  3063. if (subscribeAsync == null)
  3064. throw new ArgumentNullException("subscribeAsync");
  3065. return provider.CreateQuery<TResult>(
  3066. Expression.Call(
  3067. null,
  3068. #if CRIPPLED_REFLECTION
  3069. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, CancellationToken, Task>>))),
  3070. #else
  3071. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3072. #endif
  3073. Expression.Constant(provider, typeof(IQbservableProvider)),
  3074. subscribeAsync
  3075. )
  3076. );
  3077. }
  3078. #endif
  3079. #if !NO_TPL
  3080. /// <summary>
  3081. /// Creates an observable sequence from a specified asynchronous Subscribe method.
  3082. /// </summary>
  3083. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; 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 produce elements.</param>
  3086. /// <returns>The observable sequence surfacing the elements produced by the asynchronous method.</returns>
  3087. /// <exception cref="T:System.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. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, Task>> subscribeAsync)
  3091. {
  3092. if (provider == null)
  3093. throw new ArgumentNullException("provider");
  3094. if (subscribeAsync == null)
  3095. throw new ArgumentNullException("subscribeAsync");
  3096. return provider.CreateQuery<TResult>(
  3097. Expression.Call(
  3098. null,
  3099. #if CRIPPLED_REFLECTION
  3100. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, Task>>))),
  3101. #else
  3102. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3103. #endif
  3104. Expression.Constant(provider, typeof(IQbservableProvider)),
  3105. subscribeAsync
  3106. )
  3107. );
  3108. }
  3109. #endif
  3110. #if !NO_TPL
  3111. /// <summary>
  3112. /// Creates an observable sequence from a specified cancellable asynchronous Subscribe method.
  3113. /// The CancellationToken passed to the asynchronous Subscribe method is tied to the returned disposable subscription, allowing best-effort cancellation.
  3114. /// </summary>
  3115. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  3116. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3117. /// <param name="subscribeAsync">Asynchronous method used to implemented the resulting sequence's Subscribe method.</param>
  3118. /// <returns>The observable sequence with the specified implementation for the Subscribe method.</returns>
  3119. /// <exception cref="T:System.ArgumentNullException">
  3120. /// <paramref name="subscribeAsync" /> is null.</exception>
  3121. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3122. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous subscribe function will be signaled.</remarks>
  3123. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, CancellationToken, Task<IDisposable>>> subscribeAsync)
  3124. {
  3125. if (provider == null)
  3126. throw new ArgumentNullException("provider");
  3127. if (subscribeAsync == null)
  3128. throw new ArgumentNullException("subscribeAsync");
  3129. return provider.CreateQuery<TResult>(
  3130. Expression.Call(
  3131. null,
  3132. #if CRIPPLED_REFLECTION
  3133. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, CancellationToken, Task<IDisposable>>>))),
  3134. #else
  3135. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3136. #endif
  3137. Expression.Constant(provider, typeof(IQbservableProvider)),
  3138. subscribeAsync
  3139. )
  3140. );
  3141. }
  3142. #endif
  3143. #if !NO_TPL
  3144. /// <summary>
  3145. /// Creates an observable sequence from a specified asynchronous Subscribe method.
  3146. /// </summary>
  3147. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  3148. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3149. /// <param name="subscribeAsync">Asynchronous method used to implemented the resulting sequence's Subscribe method.</param>
  3150. /// <returns>The observable sequence with the specified implementation for the Subscribe method.</returns>
  3151. /// <exception cref="T:System.ArgumentNullException">
  3152. /// <paramref name="subscribeAsync" /> is null.</exception>
  3153. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3154. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, Task<IDisposable>>> subscribeAsync)
  3155. {
  3156. if (provider == null)
  3157. throw new ArgumentNullException("provider");
  3158. if (subscribeAsync == null)
  3159. throw new ArgumentNullException("subscribeAsync");
  3160. return provider.CreateQuery<TResult>(
  3161. Expression.Call(
  3162. null,
  3163. #if CRIPPLED_REFLECTION
  3164. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, Task<IDisposable>>>))),
  3165. #else
  3166. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3167. #endif
  3168. Expression.Constant(provider, typeof(IQbservableProvider)),
  3169. subscribeAsync
  3170. )
  3171. );
  3172. }
  3173. #endif
  3174. #if !NO_TPL
  3175. /// <summary>
  3176. /// Creates an observable sequence from a specified cancellable asynchronous Subscribe method.
  3177. /// The CancellationToken passed to the asynchronous Subscribe method is tied to the returned disposable subscription, allowing best-effort cancellation.
  3178. /// </summary>
  3179. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  3180. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3181. /// <param name="subscribeAsync">Asynchronous method used to implemented the resulting sequence's Subscribe method, returning an Action delegate that will be wrapped in an IDisposable.</param>
  3182. /// <returns>The observable sequence with the specified implementation for the Subscribe method.</returns>
  3183. /// <exception cref="T:System.ArgumentNullException">
  3184. /// <paramref name="subscribeAsync" /> is null.</exception>
  3185. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3186. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous subscribe function will be signaled.</remarks>
  3187. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, CancellationToken, Task<Action>>> subscribeAsync)
  3188. {
  3189. if (provider == null)
  3190. throw new ArgumentNullException("provider");
  3191. if (subscribeAsync == null)
  3192. throw new ArgumentNullException("subscribeAsync");
  3193. return provider.CreateQuery<TResult>(
  3194. Expression.Call(
  3195. null,
  3196. #if CRIPPLED_REFLECTION
  3197. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, CancellationToken, Task<Action>>>))),
  3198. #else
  3199. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3200. #endif
  3201. Expression.Constant(provider, typeof(IQbservableProvider)),
  3202. subscribeAsync
  3203. )
  3204. );
  3205. }
  3206. #endif
  3207. #if !NO_TPL
  3208. /// <summary>
  3209. /// Creates an observable sequence from a specified asynchronous Subscribe method.
  3210. /// </summary>
  3211. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  3212. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3213. /// <param name="subscribeAsync">Asynchronous method used to implemented the resulting sequence's Subscribe method, returning an Action delegate that will be wrapped in an IDisposable.</param>
  3214. /// <returns>The observable sequence with the specified implementation for the Subscribe method.</returns>
  3215. /// <exception cref="T:System.ArgumentNullException">
  3216. /// <paramref name="subscribeAsync" /> is null.</exception>
  3217. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3218. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, Task<Action>>> subscribeAsync)
  3219. {
  3220. if (provider == null)
  3221. throw new ArgumentNullException("provider");
  3222. if (subscribeAsync == null)
  3223. throw new ArgumentNullException("subscribeAsync");
  3224. return provider.CreateQuery<TResult>(
  3225. Expression.Call(
  3226. null,
  3227. #if CRIPPLED_REFLECTION
  3228. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, Task<Action>>>))),
  3229. #else
  3230. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3231. #endif
  3232. Expression.Constant(provider, typeof(IQbservableProvider)),
  3233. subscribeAsync
  3234. )
  3235. );
  3236. }
  3237. #endif
  3238. /// <summary>
  3239. /// Returns the elements of the specified sequence or the type parameter's default value in a singleton sequence if the sequence is empty.
  3240. /// </summary>
  3241. /// <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>
  3242. /// <param name="source">The sequence to return a default value for if it is empty.</param>
  3243. /// <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>
  3244. /// <exception cref="T:System.ArgumentNullException">
  3245. /// <paramref name="source" /> is null.</exception>
  3246. public static IQbservable<TSource> DefaultIfEmpty<TSource>(this IQbservable<TSource> source)
  3247. {
  3248. if (source == null)
  3249. throw new ArgumentNullException("source");
  3250. return source.Provider.CreateQuery<TSource>(
  3251. Expression.Call(
  3252. null,
  3253. #if CRIPPLED_REFLECTION
  3254. InfoOf(() => Qbservable.DefaultIfEmpty<TSource>(default(IQbservable<TSource>))),
  3255. #else
  3256. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3257. #endif
  3258. source.Expression
  3259. )
  3260. );
  3261. }
  3262. /// <summary>
  3263. /// Returns the elements of the specified sequence or the specified value in a singleton sequence if the sequence is empty.
  3264. /// </summary>
  3265. /// <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>
  3266. /// <param name="source">The sequence to return the specified value for if it is empty.</param>
  3267. /// <param name="defaultValue">The value to return if the sequence is empty.</param>
  3268. /// <returns>An observable sequence that contains the specified default value if the source is empty; otherwise, the elements of the source itself.</returns>
  3269. /// <exception cref="T:System.ArgumentNullException">
  3270. /// <paramref name="source" /> is null.</exception>
  3271. public static IQbservable<TSource> DefaultIfEmpty<TSource>(this IQbservable<TSource> source, TSource defaultValue)
  3272. {
  3273. if (source == null)
  3274. throw new ArgumentNullException("source");
  3275. return source.Provider.CreateQuery<TSource>(
  3276. Expression.Call(
  3277. null,
  3278. #if CRIPPLED_REFLECTION
  3279. InfoOf(() => Qbservable.DefaultIfEmpty<TSource>(default(IQbservable<TSource>), default(TSource))),
  3280. #else
  3281. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3282. #endif
  3283. source.Expression,
  3284. Expression.Constant(defaultValue, typeof(TSource))
  3285. )
  3286. );
  3287. }
  3288. /// <summary>
  3289. /// Returns an observable sequence that invokes the specified factory function whenever a new observer subscribes.
  3290. /// </summary>
  3291. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  3292. /// <typeparam name="TResult">The type of the elements in the sequence returned by the factory function, and in the resulting sequence.</typeparam>
  3293. /// <param name="observableFactory">Observable factory function to invoke for each observer that subscribes to the resulting sequence.</param>
  3294. /// <returns>An observable sequence whose observers trigger an invocation of the given observable factory function.</returns>
  3295. /// <exception cref="T:System.ArgumentNullException">
  3296. /// <paramref name="observableFactory" /> is null.</exception>
  3297. public static IQbservable<TResult> Defer<TResult>(this IQbservableProvider provider, Expression<Func<IObservable<TResult>>> observableFactory)
  3298. {
  3299. if (provider == null)
  3300. throw new ArgumentNullException("provider");
  3301. if (observableFactory == null)
  3302. throw new ArgumentNullException("observableFactory");
  3303. return provider.CreateQuery<TResult>(
  3304. Expression.Call(
  3305. null,
  3306. #if CRIPPLED_REFLECTION
  3307. InfoOf(() => Qbservable.Defer<TResult>(default(IQbservableProvider), default(Expression<Func<IObservable<TResult>>>))),
  3308. #else
  3309. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3310. #endif
  3311. Expression.Constant(provider, typeof(IQbservableProvider)),
  3312. observableFactory
  3313. )
  3314. );
  3315. }
  3316. #if !NO_TPL
  3317. /// <summary>
  3318. /// Returns an observable sequence that starts the specified asynchronous factory function whenever a new observer subscribes.
  3319. /// </summary>
  3320. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  3321. /// <typeparam name="TResult">The type of the elements in the sequence returned by the factory function, and in the resulting sequence.</typeparam>
  3322. /// <param name="observableFactoryAsync">Asynchronous factory function to start for each observer that subscribes to the resulting sequence.</param>
  3323. /// <returns>An observable sequence whose observers trigger the given asynchronous observable factory function to be started.</returns>
  3324. /// <exception cref="T:System.ArgumentNullException">
  3325. /// <paramref name="observableFactoryAsync" /> is null.</exception>
  3326. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3327. public static IQbservable<TResult> Defer<TResult>(this IQbservableProvider provider, Expression<Func<Task<IObservable<TResult>>>> observableFactoryAsync)
  3328. {
  3329. if (provider == null)
  3330. throw new ArgumentNullException("provider");
  3331. if (observableFactoryAsync == null)
  3332. throw new ArgumentNullException("observableFactoryAsync");
  3333. return provider.CreateQuery<TResult>(
  3334. Expression.Call(
  3335. null,
  3336. #if CRIPPLED_REFLECTION
  3337. InfoOf(() => Qbservable.Defer<TResult>(default(IQbservableProvider), default(Expression<Func<Task<IObservable<TResult>>>>))),
  3338. #else
  3339. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3340. #endif
  3341. Expression.Constant(provider, typeof(IQbservableProvider)),
  3342. observableFactoryAsync
  3343. )
  3344. );
  3345. }
  3346. #endif
  3347. #if !NO_TPL
  3348. /// <summary>
  3349. /// Returns an observable sequence that starts the specified cancellable asynchronous factory function whenever a new observer subscribes.
  3350. /// The CancellationToken passed to the asynchronous factory function is tied to the returned disposable subscription, allowing best-effort cancellation.
  3351. /// </summary>
  3352. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  3353. /// <typeparam name="TResult">The type of the elements in the sequence returned by the factory function, and in the resulting sequence.</typeparam>
  3354. /// <param name="observableFactoryAsync">Asynchronous factory function to start for each observer that subscribes to the resulting sequence.</param>
  3355. /// <returns>An observable sequence whose observers trigger the given asynchronous observable factory function to be started.</returns>
  3356. /// <exception cref="T:System.ArgumentNullException">
  3357. /// <paramref name="observableFactoryAsync" /> is null.</exception>
  3358. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3359. /// <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>
  3360. public static IQbservable<TResult> DeferAsync<TResult>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<IObservable<TResult>>>> observableFactoryAsync)
  3361. {
  3362. if (provider == null)
  3363. throw new ArgumentNullException("provider");
  3364. if (observableFactoryAsync == null)
  3365. throw new ArgumentNullException("observableFactoryAsync");
  3366. return provider.CreateQuery<TResult>(
  3367. Expression.Call(
  3368. null,
  3369. #if CRIPPLED_REFLECTION
  3370. InfoOf(() => Qbservable.DeferAsync<TResult>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<IObservable<TResult>>>>))),
  3371. #else
  3372. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3373. #endif
  3374. Expression.Constant(provider, typeof(IQbservableProvider)),
  3375. observableFactoryAsync
  3376. )
  3377. );
  3378. }
  3379. #endif
  3380. /// <summary>
  3381. /// Time shifts the observable sequence to start propagating notifications at the specified absolute time.
  3382. /// The relative time intervals between the values are preserved.
  3383. /// </summary>
  3384. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3385. /// <param name="source">Source sequence to delay values for.</param>
  3386. /// <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>
  3387. /// <returns>Time-shifted sequence.</returns>
  3388. /// <exception cref="T:System.ArgumentNullException">
  3389. /// <paramref name="source" /> is null.</exception>
  3390. /// <remarks>
  3391. /// <para>
  3392. /// This operator is less efficient than <see cref="M:System.Reactive.Linq.Observable.DelaySubscription``1(System.IObservable{``0},System.DateTimeOffset)">DelaySubscription</see> because it records all notifications and time-delays those. This allows for immediate propagation of errors.
  3393. /// </para>
  3394. /// <para>
  3395. /// Observer callbacks for the resulting sequence will be run on the default scheduler. This effect is similar to using ObserveOn.
  3396. /// </para>
  3397. /// <para>
  3398. /// 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.
  3399. /// In order to delay error propagation, consider using the <see cref="M:System.Reactive.Linq.Observable.Materialize``1(System.IObservable{``0})">Observable.Materialize</see> and <see cref="M:System.Reactive.Linq.Observable.Dematerialize``1(System.IObservable{System.Reactive.Notification{``0}})">Observable.Dematerialize</see> operators, or use <see cref="M:System.Reactive.Linq.Observable.DelaySubscription``1(System.IObservable{``0},System.DateTimeOffset)">DelaySubscription</see>.
  3400. /// </para>
  3401. /// </remarks>
  3402. public static IQbservable<TSource> Delay<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime)
  3403. {
  3404. if (source == null)
  3405. throw new ArgumentNullException("source");
  3406. return source.Provider.CreateQuery<TSource>(
  3407. Expression.Call(
  3408. null,
  3409. #if CRIPPLED_REFLECTION
  3410. InfoOf(() => Qbservable.Delay<TSource>(default(IQbservable<TSource>), default(DateTimeOffset))),
  3411. #else
  3412. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3413. #endif
  3414. source.Expression,
  3415. Expression.Constant(dueTime, typeof(DateTimeOffset))
  3416. )
  3417. );
  3418. }
  3419. /// <summary>
  3420. /// Time shifts the observable sequence to start propagating notifications at the specified absolute time, using the specified scheduler to run timers.
  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">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>
  3426. /// <param name="scheduler">Scheduler to run the delay timers on.</param>
  3427. /// <returns>Time-shifted sequence.</returns>
  3428. /// <exception cref="T:System.ArgumentNullException">
  3429. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  3430. /// <remarks>
  3431. /// <para>
  3432. /// This operator is less efficient than <see cref="M:System.Reactive.Linq.Observable.DelaySubscription``1(System.IObservable{``0},System.DateTimeOffset,System.Reactive.Concurrency.IScheduler)">DelaySubscription</see> because it records all notifications and time-delays those. This allows for immediate propagation of errors.
  3433. /// </para>
  3434. /// <para>
  3435. /// Observer callbacks for the resulting sequence will be run on the specified scheduler. This effect is similar to using ObserveOn.
  3436. /// </para>
  3437. /// <para>
  3438. /// 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.
  3439. /// In order to delay error propagation, consider using the <see cref="M:System.Reactive.Linq.Observable.Materialize``1(System.IObservable{``0})">Observable.Materialize</see> and <see cref="M:System.Reactive.Linq.Observable.Dematerialize``1(System.IObservable{System.Reactive.Notification{``0}})">Observable.Dematerialize</see> operators, or use <see cref="M:System.Reactive.Linq.Observable.DelaySubscription``1(System.IObservable{``0},System.DateTimeOffset,System.Reactive.Concurrency.IScheduler)">DelaySubscription</see>.
  3440. /// </para>
  3441. /// </remarks>
  3442. public static IQbservable<TSource> Delay<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime, IScheduler scheduler)
  3443. {
  3444. if (source == null)
  3445. throw new ArgumentNullException("source");
  3446. if (scheduler == null)
  3447. throw new ArgumentNullException("scheduler");
  3448. return source.Provider.CreateQuery<TSource>(
  3449. Expression.Call(
  3450. null,
  3451. #if CRIPPLED_REFLECTION
  3452. InfoOf(() => Qbservable.Delay<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IScheduler))),
  3453. #else
  3454. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3455. #endif
  3456. source.Expression,
  3457. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  3458. Expression.Constant(scheduler, typeof(IScheduler))
  3459. )
  3460. );
  3461. }
  3462. /// <summary>
  3463. /// Time shifts the observable sequence by the specified relative time duration.
  3464. /// The relative time intervals between the values are preserved.
  3465. /// </summary>
  3466. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3467. /// <param name="source">Source sequence to delay values for.</param>
  3468. /// <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>
  3469. /// <returns>Time-shifted sequence.</returns>
  3470. /// <exception cref="T:System.ArgumentNullException">
  3471. /// <paramref name="source" /> is null.</exception>
  3472. /// <exception cref="T:System.ArgumentOutOfRangeException">
  3473. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  3474. /// <remarks>
  3475. /// <para>
  3476. /// This operator is less efficient than <see cref="M:System.Reactive.Linq.Observable.DelaySubscription``1(System.IObservable{``0},System.TimeSpan)">DelaySubscription</see> because it records all notifications and time-delays those. This allows for immediate propagation of errors.
  3477. /// </para>
  3478. /// <para>
  3479. /// Observer callbacks for the resulting sequence will be run on the default scheduler. This effect is similar to using ObserveOn.
  3480. /// </para>
  3481. /// <para>
  3482. /// Exceptions signaled by the source sequence through an OnError callback are forwarded immediately to the result sequence. Any OnNext notifications that were in the queue at the point of the OnError callback will be dropped.
  3483. /// In order to delay error propagation, consider using the <see cref="M:System.Reactive.Linq.Observable.Materialize``1(System.IObservable{``0})">Observable.Materialize</see> and <see cref="M:System.Reactive.Linq.Observable.Dematerialize``1(System.IObservable{System.Reactive.Notification{``0}})">Observable.Dematerialize</see> operators, or use <see cref="M:System.Reactive.Linq.Observable.DelaySubscription``1(System.IObservable{``0},System.TimeSpan)">DelaySubscription</see>.
  3484. /// </para>
  3485. /// </remarks>
  3486. public static IQbservable<TSource> Delay<TSource>(this IQbservable<TSource> source, TimeSpan dueTime)
  3487. {
  3488. if (source == null)
  3489. throw new ArgumentNullException("source");
  3490. return source.Provider.CreateQuery<TSource>(
  3491. Expression.Call(
  3492. null,
  3493. #if CRIPPLED_REFLECTION
  3494. InfoOf(() => Qbservable.Delay<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  3495. #else
  3496. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3497. #endif
  3498. source.Expression,
  3499. Expression.Constant(dueTime, typeof(TimeSpan))
  3500. )
  3501. );
  3502. }
  3503. /// <summary>
  3504. /// Time shifts the observable sequence by the specified relative time duration, using the specified scheduler to run timers.
  3505. /// The relative time intervals between the values are preserved.
  3506. /// </summary>
  3507. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3508. /// <param name="source">Source sequence to delay values for.</param>
  3509. /// <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>
  3510. /// <param name="scheduler">Scheduler to run the delay timers on.</param>
  3511. /// <returns>Time-shifted sequence.</returns>
  3512. /// <exception cref="T:System.ArgumentNullException">
  3513. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  3514. /// <exception cref="T:System.ArgumentOutOfRangeException">
  3515. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  3516. /// <remarks>
  3517. /// <para>
  3518. /// This operator is less efficient than <see cref="M:System.Reactive.Linq.Observable.DelaySubscription``1(System.IObservable{``0},System.TimeSpan,System.Reactive.Concurrency.IScheduler)">DelaySubscription</see> because it records all notifications and time-delays those. This allows for immediate propagation of errors.
  3519. /// </para>
  3520. /// <para>
  3521. /// Observer callbacks for the resulting sequence will be run on the specified scheduler. This effect is similar to using ObserveOn.
  3522. /// </para>
  3523. /// <para>
  3524. /// Exceptions signaled by the source sequence through an OnError callback are forwarded immediately to the result sequence. Any OnNext notifications that were in the queue at the point of the OnError callback will be dropped.
  3525. /// </para>
  3526. /// <para>
  3527. /// 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.
  3528. /// In order to delay error propagation, consider using the <see cref="M:System.Reactive.Linq.Observable.Materialize``1(System.IObservable{``0})">Observable.Materialize</see> and <see cref="M:System.Reactive.Linq.Observable.Dematerialize``1(System.IObservable{System.Reactive.Notification{``0}})">Observable.Dematerialize</see> operators, or use <see cref="M:System.Reactive.Linq.Observable.DelaySubscription``1(System.IObservable{``0},System.TimeSpan,System.Reactive.Concurrency.IScheduler)">DelaySubscription</see>.
  3529. /// </para>
  3530. /// </remarks>
  3531. public static IQbservable<TSource> Delay<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IScheduler scheduler)
  3532. {
  3533. if (source == null)
  3534. throw new ArgumentNullException("source");
  3535. if (scheduler == null)
  3536. throw new ArgumentNullException("scheduler");
  3537. return source.Provider.CreateQuery<TSource>(
  3538. Expression.Call(
  3539. null,
  3540. #if CRIPPLED_REFLECTION
  3541. InfoOf(() => Qbservable.Delay<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  3542. #else
  3543. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3544. #endif
  3545. source.Expression,
  3546. Expression.Constant(dueTime, typeof(TimeSpan)),
  3547. Expression.Constant(scheduler, typeof(IScheduler))
  3548. )
  3549. );
  3550. }
  3551. /// <summary>
  3552. /// Time shifts the observable sequence based on a delay selector function for each element.
  3553. /// </summary>
  3554. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3555. /// <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>
  3556. /// <param name="source">Source sequence to delay values for.</param>
  3557. /// <param name="delayDurationSelector">Selector function to retrieve a sequence indicating the delay for each given element.</param>
  3558. /// <returns>Time-shifted sequence.</returns>
  3559. /// <exception cref="T:System.ArgumentNullException">
  3560. /// <paramref name="source" /> or <paramref name="delayDurationSelector" /> is null.</exception>
  3561. public static IQbservable<TSource> Delay<TSource, TDelay>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TDelay>>> delayDurationSelector)
  3562. {
  3563. if (source == null)
  3564. throw new ArgumentNullException("source");
  3565. if (delayDurationSelector == null)
  3566. throw new ArgumentNullException("delayDurationSelector");
  3567. return source.Provider.CreateQuery<TSource>(
  3568. Expression.Call(
  3569. null,
  3570. #if CRIPPLED_REFLECTION
  3571. InfoOf(() => Qbservable.Delay<TSource, TDelay>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TDelay>>>))),
  3572. #else
  3573. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TDelay)),
  3574. #endif
  3575. source.Expression,
  3576. delayDurationSelector
  3577. )
  3578. );
  3579. }
  3580. /// <summary>
  3581. /// Time shifts the observable sequence based on a subscription delay and a delay selector function for each element.
  3582. /// </summary>
  3583. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3584. /// <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>
  3585. /// <param name="source">Source sequence to delay values for.</param>
  3586. /// <param name="subscriptionDelay">Sequence indicating the delay for the subscription to the source.</param>
  3587. /// <param name="delayDurationSelector">Selector function to retrieve a sequence indicating the delay for each given element.</param>
  3588. /// <returns>Time-shifted sequence.</returns>
  3589. /// <exception cref="T:System.ArgumentNullException">
  3590. /// <paramref name="source" /> or <paramref name="subscriptionDelay" /> or <paramref name="delayDurationSelector" /> is null.</exception>
  3591. public static IQbservable<TSource> Delay<TSource, TDelay>(this IQbservable<TSource> source, IObservable<TDelay> subscriptionDelay, Expression<Func<TSource, IObservable<TDelay>>> delayDurationSelector)
  3592. {
  3593. if (source == null)
  3594. throw new ArgumentNullException("source");
  3595. if (subscriptionDelay == null)
  3596. throw new ArgumentNullException("subscriptionDelay");
  3597. if (delayDurationSelector == null)
  3598. throw new ArgumentNullException("delayDurationSelector");
  3599. return source.Provider.CreateQuery<TSource>(
  3600. Expression.Call(
  3601. null,
  3602. #if CRIPPLED_REFLECTION
  3603. InfoOf(() => Qbservable.Delay<TSource, TDelay>(default(IQbservable<TSource>), default(IObservable<TDelay>), default(Expression<Func<TSource, IObservable<TDelay>>>))),
  3604. #else
  3605. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TDelay)),
  3606. #endif
  3607. source.Expression,
  3608. GetSourceExpression(subscriptionDelay),
  3609. delayDurationSelector
  3610. )
  3611. );
  3612. }
  3613. /// <summary>
  3614. /// Time shifts the observable sequence by delaying the subscription to the specified absolute time.
  3615. /// </summary>
  3616. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3617. /// <param name="source">Source sequence to delay subscription for.</param>
  3618. /// <param name="dueTime">Absolute time to perform the subscription at.</param>
  3619. /// <returns>Time-shifted sequence.</returns>
  3620. /// <exception cref="T:System.ArgumentNullException">
  3621. /// <paramref name="source" /> is null.</exception>
  3622. /// <remarks>
  3623. /// <para>
  3624. /// This operator is more efficient than <see cref="M:System.Reactive.Linq.Observable.Delay``1(System.IObservable{``0},System.DateTimeOffset)">Delay</see> but postpones all side-effects of subscription and affects error propagation timing.
  3625. /// </para>
  3626. /// <para>
  3627. /// The side-effects of subscribing to the source sequence will be run on the default scheduler. Observer callbacks will not be affected.
  3628. /// </para>
  3629. /// </remarks>
  3630. public static IQbservable<TSource> DelaySubscription<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime)
  3631. {
  3632. if (source == null)
  3633. throw new ArgumentNullException("source");
  3634. return source.Provider.CreateQuery<TSource>(
  3635. Expression.Call(
  3636. null,
  3637. #if CRIPPLED_REFLECTION
  3638. InfoOf(() => Qbservable.DelaySubscription<TSource>(default(IQbservable<TSource>), default(DateTimeOffset))),
  3639. #else
  3640. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3641. #endif
  3642. source.Expression,
  3643. Expression.Constant(dueTime, typeof(DateTimeOffset))
  3644. )
  3645. );
  3646. }
  3647. /// <summary>
  3648. /// Time shifts the observable sequence by delaying the subscription to the specified absolute time, using the specified scheduler to run timers.
  3649. /// </summary>
  3650. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3651. /// <param name="source">Source sequence to delay subscription for.</param>
  3652. /// <param name="dueTime">Absolute time to perform the subscription at.</param>
  3653. /// <param name="scheduler">Scheduler to run the subscription delay timer on.</param>
  3654. /// <returns>Time-shifted sequence.</returns>
  3655. /// <exception cref="T:System.ArgumentNullException">
  3656. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  3657. /// <remarks>
  3658. /// <para>
  3659. /// This operator is more efficient than <see cref="M:System.Reactive.Linq.Observable.Delay``1(System.IObservable{``0},System.DateTimeOffset,System.Reactive.Concurrency.IScheduler)">Delay</see> but postpones all side-effects of subscription and affects error propagation timing.
  3660. /// </para>
  3661. /// <para>
  3662. /// The side-effects of subscribing to the source sequence will be run on the specified scheduler. Observer callbacks will not be affected.
  3663. /// </para>
  3664. /// </remarks>
  3665. public static IQbservable<TSource> DelaySubscription<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime, IScheduler scheduler)
  3666. {
  3667. if (source == null)
  3668. throw new ArgumentNullException("source");
  3669. if (scheduler == null)
  3670. throw new ArgumentNullException("scheduler");
  3671. return source.Provider.CreateQuery<TSource>(
  3672. Expression.Call(
  3673. null,
  3674. #if CRIPPLED_REFLECTION
  3675. InfoOf(() => Qbservable.DelaySubscription<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IScheduler))),
  3676. #else
  3677. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3678. #endif
  3679. source.Expression,
  3680. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  3681. Expression.Constant(scheduler, typeof(IScheduler))
  3682. )
  3683. );
  3684. }
  3685. /// <summary>
  3686. /// Time shifts the observable sequence by delaying the subscription with the specified relative time duration.
  3687. /// </summary>
  3688. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3689. /// <param name="source">Source sequence to delay subscription for.</param>
  3690. /// <param name="dueTime">Relative time shift of the subscription.</param>
  3691. /// <returns>Time-shifted sequence.</returns>
  3692. /// <exception cref="T:System.ArgumentNullException">
  3693. /// <paramref name="source" /> is null.</exception>
  3694. /// <exception cref="T:System.ArgumentOutOfRangeException">
  3695. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  3696. /// <remarks>
  3697. /// <para>
  3698. /// This operator is more efficient than <see cref="M:System.Reactive.Linq.Observable.Delay``1(System.IObservable{``0},System.TimeSpan)">Delay</see> but postpones all side-effects of subscription and affects error propagation timing.
  3699. /// </para>
  3700. /// <para>
  3701. /// The side-effects of subscribing to the source sequence will be run on the default scheduler. Observer callbacks will not be affected.
  3702. /// </para>
  3703. /// </remarks>
  3704. public static IQbservable<TSource> DelaySubscription<TSource>(this IQbservable<TSource> source, TimeSpan dueTime)
  3705. {
  3706. if (source == null)
  3707. throw new ArgumentNullException("source");
  3708. return source.Provider.CreateQuery<TSource>(
  3709. Expression.Call(
  3710. null,
  3711. #if CRIPPLED_REFLECTION
  3712. InfoOf(() => Qbservable.DelaySubscription<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  3713. #else
  3714. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3715. #endif
  3716. source.Expression,
  3717. Expression.Constant(dueTime, typeof(TimeSpan))
  3718. )
  3719. );
  3720. }
  3721. /// <summary>
  3722. /// Time shifts the observable sequence by delaying the subscription with the specified relative time duration, using the specified scheduler to run timers.
  3723. /// </summary>
  3724. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3725. /// <param name="source">Source sequence to delay subscription for.</param>
  3726. /// <param name="dueTime">Relative time shift of the subscription.</param>
  3727. /// <param name="scheduler">Scheduler to run the subscription delay timer on.</param>
  3728. /// <returns>Time-shifted sequence.</returns>
  3729. /// <exception cref="T:System.ArgumentNullException">
  3730. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  3731. /// <exception cref="T:System.ArgumentOutOfRangeException">
  3732. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  3733. /// <remarks>
  3734. /// <para>
  3735. /// This operator is more efficient than <see cref="M:System.Reactive.Linq.Observable.Delay``1(System.IObservable{``0},System.TimeSpan,System.Reactive.Concurrency.IScheduler)">Delay</see> but postpones all side-effects of subscription and affects error propagation timing.
  3736. /// </para>
  3737. /// <para>
  3738. /// The side-effects of subscribing to the source sequence will be run on the specified scheduler. Observer callbacks will not be affected.
  3739. /// </para>
  3740. /// </remarks>
  3741. public static IQbservable<TSource> DelaySubscription<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IScheduler scheduler)
  3742. {
  3743. if (source == null)
  3744. throw new ArgumentNullException("source");
  3745. if (scheduler == null)
  3746. throw new ArgumentNullException("scheduler");
  3747. return source.Provider.CreateQuery<TSource>(
  3748. Expression.Call(
  3749. null,
  3750. #if CRIPPLED_REFLECTION
  3751. InfoOf(() => Qbservable.DelaySubscription<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  3752. #else
  3753. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3754. #endif
  3755. source.Expression,
  3756. Expression.Constant(dueTime, typeof(TimeSpan)),
  3757. Expression.Constant(scheduler, typeof(IScheduler))
  3758. )
  3759. );
  3760. }
  3761. /// <summary>
  3762. /// Dematerializes the explicit notification values of an observable sequence as implicit notifications.
  3763. /// </summary>
  3764. /// <typeparam name="TSource">The type of the elements materialized in the source sequence notification objects.</typeparam>
  3765. /// <param name="source">An observable sequence containing explicit notification values which have to be turned into implicit notifications.</param>
  3766. /// <returns>An observable sequence exhibiting the behavior corresponding to the source sequence's notification values.</returns>
  3767. /// <exception cref="T:System.ArgumentNullException">
  3768. /// <paramref name="source" /> is null.</exception>
  3769. public static IQbservable<TSource> Dematerialize<TSource>(this IQbservable<Notification<TSource>> source)
  3770. {
  3771. if (source == null)
  3772. throw new ArgumentNullException("source");
  3773. return source.Provider.CreateQuery<TSource>(
  3774. Expression.Call(
  3775. null,
  3776. #if CRIPPLED_REFLECTION
  3777. InfoOf(() => Qbservable.Dematerialize<TSource>(default(IQbservable<Notification<TSource>>))),
  3778. #else
  3779. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3780. #endif
  3781. source.Expression
  3782. )
  3783. );
  3784. }
  3785. /// <summary>
  3786. /// Returns an observable sequence that contains only distinct elements.
  3787. /// </summary>
  3788. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3789. /// <param name="source">An observable sequence to retain distinct elements for.</param>
  3790. /// <returns>An observable sequence only containing the distinct elements from the source sequence.</returns>
  3791. /// <exception cref="T:System.ArgumentNullException">
  3792. /// <paramref name="source" /> is null.</exception>
  3793. /// <remarks>Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large.</remarks>
  3794. public static IQbservable<TSource> Distinct<TSource>(this IQbservable<TSource> source)
  3795. {
  3796. if (source == null)
  3797. throw new ArgumentNullException("source");
  3798. return source.Provider.CreateQuery<TSource>(
  3799. Expression.Call(
  3800. null,
  3801. #if CRIPPLED_REFLECTION
  3802. InfoOf(() => Qbservable.Distinct<TSource>(default(IQbservable<TSource>))),
  3803. #else
  3804. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3805. #endif
  3806. source.Expression
  3807. )
  3808. );
  3809. }
  3810. /// <summary>
  3811. /// Returns an observable sequence that contains only distinct elements according to the comparer.
  3812. /// </summary>
  3813. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3814. /// <param name="source">An observable sequence to retain distinct elements for.</param>
  3815. /// <param name="comparer">Equality comparer for source elements.</param>
  3816. /// <returns>An observable sequence only containing the distinct elements from the source sequence.</returns>
  3817. /// <exception cref="T:System.ArgumentNullException">
  3818. /// <paramref name="source" /> or <paramref name="comparer" /> is null.</exception>
  3819. /// <remarks>Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large.</remarks>
  3820. public static IQbservable<TSource> Distinct<TSource>(this IQbservable<TSource> source, IEqualityComparer<TSource> comparer)
  3821. {
  3822. if (source == null)
  3823. throw new ArgumentNullException("source");
  3824. if (comparer == null)
  3825. throw new ArgumentNullException("comparer");
  3826. return source.Provider.CreateQuery<TSource>(
  3827. Expression.Call(
  3828. null,
  3829. #if CRIPPLED_REFLECTION
  3830. InfoOf(() => Qbservable.Distinct<TSource>(default(IQbservable<TSource>), default(IEqualityComparer<TSource>))),
  3831. #else
  3832. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3833. #endif
  3834. source.Expression,
  3835. Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))
  3836. )
  3837. );
  3838. }
  3839. /// <summary>
  3840. /// Returns an observable sequence that contains only distinct elements according to the keySelector.
  3841. /// </summary>
  3842. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3843. /// <typeparam name="TKey">The type of the discriminator key computed for each element in the source sequence.</typeparam>
  3844. /// <param name="source">An observable sequence to retain distinct elements for.</param>
  3845. /// <param name="keySelector">A function to compute the comparison key for each element.</param>
  3846. /// <returns>An observable sequence only containing the distinct elements, based on a computed key value, from the source sequence.</returns>
  3847. /// <exception cref="T:System.ArgumentNullException">
  3848. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  3849. /// <remarks>Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large.</remarks>
  3850. public static IQbservable<TSource> Distinct<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  3851. {
  3852. if (source == null)
  3853. throw new ArgumentNullException("source");
  3854. if (keySelector == null)
  3855. throw new ArgumentNullException("keySelector");
  3856. return source.Provider.CreateQuery<TSource>(
  3857. Expression.Call(
  3858. null,
  3859. #if CRIPPLED_REFLECTION
  3860. InfoOf(() => Qbservable.Distinct<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  3861. #else
  3862. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  3863. #endif
  3864. source.Expression,
  3865. keySelector
  3866. )
  3867. );
  3868. }
  3869. /// <summary>
  3870. /// Returns an observable sequence that contains only distinct elements according to the keySelector and the comparer.
  3871. /// </summary>
  3872. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3873. /// <typeparam name="TKey">The type of the discriminator key computed for each element in the source sequence.</typeparam>
  3874. /// <param name="source">An observable sequence to retain distinct elements for.</param>
  3875. /// <param name="keySelector">A function to compute the comparison key for each element.</param>
  3876. /// <param name="comparer">Equality comparer for source elements.</param>
  3877. /// <returns>An observable sequence only containing the distinct elements, based on a computed key value, from the source sequence.</returns>
  3878. /// <exception cref="T:System.ArgumentNullException">
  3879. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  3880. /// <remarks>Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large.</remarks>
  3881. public static IQbservable<TSource> Distinct<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  3882. {
  3883. if (source == null)
  3884. throw new ArgumentNullException("source");
  3885. if (keySelector == null)
  3886. throw new ArgumentNullException("keySelector");
  3887. if (comparer == null)
  3888. throw new ArgumentNullException("comparer");
  3889. return source.Provider.CreateQuery<TSource>(
  3890. Expression.Call(
  3891. null,
  3892. #if CRIPPLED_REFLECTION
  3893. InfoOf(() => Qbservable.Distinct<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IEqualityComparer<TKey>))),
  3894. #else
  3895. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  3896. #endif
  3897. source.Expression,
  3898. keySelector,
  3899. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  3900. )
  3901. );
  3902. }
  3903. /// <summary>
  3904. /// Returns an observable sequence that contains only distinct contiguous elements.
  3905. /// </summary>
  3906. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3907. /// <param name="source">An observable sequence to retain distinct contiguous elements for.</param>
  3908. /// <returns>An observable sequence only containing the distinct contiguous elements from the source sequence.</returns>
  3909. /// <exception cref="T:System.ArgumentNullException">
  3910. /// <paramref name="source" /> is null.</exception>
  3911. public static IQbservable<TSource> DistinctUntilChanged<TSource>(this IQbservable<TSource> source)
  3912. {
  3913. if (source == null)
  3914. throw new ArgumentNullException("source");
  3915. return source.Provider.CreateQuery<TSource>(
  3916. Expression.Call(
  3917. null,
  3918. #if CRIPPLED_REFLECTION
  3919. InfoOf(() => Qbservable.DistinctUntilChanged<TSource>(default(IQbservable<TSource>))),
  3920. #else
  3921. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3922. #endif
  3923. source.Expression
  3924. )
  3925. );
  3926. }
  3927. /// <summary>
  3928. /// Returns an observable sequence that contains only distinct contiguous elements according to the comparer.
  3929. /// </summary>
  3930. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3931. /// <param name="source">An observable sequence to retain distinct contiguous elements for.</param>
  3932. /// <param name="comparer">Equality comparer for source elements.</param>
  3933. /// <returns>An observable sequence only containing the distinct contiguous elements from the source sequence.</returns>
  3934. /// <exception cref="T:System.ArgumentNullException">
  3935. /// <paramref name="source" /> or <paramref name="comparer" /> is null.</exception>
  3936. public static IQbservable<TSource> DistinctUntilChanged<TSource>(this IQbservable<TSource> source, IEqualityComparer<TSource> comparer)
  3937. {
  3938. if (source == null)
  3939. throw new ArgumentNullException("source");
  3940. if (comparer == null)
  3941. throw new ArgumentNullException("comparer");
  3942. return source.Provider.CreateQuery<TSource>(
  3943. Expression.Call(
  3944. null,
  3945. #if CRIPPLED_REFLECTION
  3946. InfoOf(() => Qbservable.DistinctUntilChanged<TSource>(default(IQbservable<TSource>), default(IEqualityComparer<TSource>))),
  3947. #else
  3948. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3949. #endif
  3950. source.Expression,
  3951. Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))
  3952. )
  3953. );
  3954. }
  3955. /// <summary>
  3956. /// Returns an observable sequence that contains only distinct contiguous elements according to the keySelector.
  3957. /// </summary>
  3958. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3959. /// <typeparam name="TKey">The type of the discriminator key computed for each element in the source sequence.</typeparam>
  3960. /// <param name="source">An observable sequence to retain distinct contiguous elements for, based on a computed key value.</param>
  3961. /// <param name="keySelector">A function to compute the comparison key for each element.</param>
  3962. /// <returns>An observable sequence only containing the distinct contiguous elements, based on a computed key value, from the source sequence.</returns>
  3963. /// <exception cref="T:System.ArgumentNullException">
  3964. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  3965. public static IQbservable<TSource> DistinctUntilChanged<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  3966. {
  3967. if (source == null)
  3968. throw new ArgumentNullException("source");
  3969. if (keySelector == null)
  3970. throw new ArgumentNullException("keySelector");
  3971. return source.Provider.CreateQuery<TSource>(
  3972. Expression.Call(
  3973. null,
  3974. #if CRIPPLED_REFLECTION
  3975. InfoOf(() => Qbservable.DistinctUntilChanged<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  3976. #else
  3977. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  3978. #endif
  3979. source.Expression,
  3980. keySelector
  3981. )
  3982. );
  3983. }
  3984. /// <summary>
  3985. /// Returns an observable sequence that contains only distinct contiguous elements according to the keySelector and the comparer.
  3986. /// </summary>
  3987. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3988. /// <typeparam name="TKey">The type of the discriminator key computed for each element in the source sequence.</typeparam>
  3989. /// <param name="source">An observable sequence to retain distinct contiguous elements for, based on a computed key value.</param>
  3990. /// <param name="keySelector">A function to compute the comparison key for each element.</param>
  3991. /// <param name="comparer">Equality comparer for computed key values.</param>
  3992. /// <returns>An observable sequence only containing the distinct contiguous elements, based on a computed key value, from the source sequence.</returns>
  3993. /// <exception cref="T:System.ArgumentNullException">
  3994. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  3995. public static IQbservable<TSource> DistinctUntilChanged<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  3996. {
  3997. if (source == null)
  3998. throw new ArgumentNullException("source");
  3999. if (keySelector == null)
  4000. throw new ArgumentNullException("keySelector");
  4001. if (comparer == null)
  4002. throw new ArgumentNullException("comparer");
  4003. return source.Provider.CreateQuery<TSource>(
  4004. Expression.Call(
  4005. null,
  4006. #if CRIPPLED_REFLECTION
  4007. InfoOf(() => Qbservable.DistinctUntilChanged<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IEqualityComparer<TKey>))),
  4008. #else
  4009. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  4010. #endif
  4011. source.Expression,
  4012. keySelector,
  4013. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  4014. )
  4015. );
  4016. }
  4017. /// <summary>
  4018. /// Invokes the observer's methods for each message in the source sequence.
  4019. /// 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.
  4020. /// </summary>
  4021. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4022. /// <param name="source">Source sequence.</param>
  4023. /// <param name="observer">Observer whose methods to invoke as part of the source sequence's observation.</param>
  4024. /// <returns>The source sequence with the side-effecting behavior applied.</returns>
  4025. /// <exception cref="T:System.ArgumentNullException">
  4026. /// <paramref name="source" /> or <paramref name="observer" /> is null.</exception>
  4027. public static IQbservable<TSource> Do<TSource>(this IQbservable<TSource> source, IObserver<TSource> observer)
  4028. {
  4029. if (source == null)
  4030. throw new ArgumentNullException("source");
  4031. if (observer == null)
  4032. throw new ArgumentNullException("observer");
  4033. return source.Provider.CreateQuery<TSource>(
  4034. Expression.Call(
  4035. null,
  4036. #if CRIPPLED_REFLECTION
  4037. InfoOf(() => Qbservable.Do<TSource>(default(IQbservable<TSource>), default(IObserver<TSource>))),
  4038. #else
  4039. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4040. #endif
  4041. source.Expression,
  4042. Expression.Constant(observer, typeof(IObserver<TSource>))
  4043. )
  4044. );
  4045. }
  4046. /// <summary>
  4047. /// Invokes an action for each element in the observable sequence, and propagates all observer messages through the result sequence.
  4048. /// 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.
  4049. /// </summary>
  4050. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4051. /// <param name="source">Source sequence.</param>
  4052. /// <param name="onNext">Action to invoke for each element in the observable sequence.</param>
  4053. /// <returns>The source sequence with the side-effecting behavior applied.</returns>
  4054. /// <exception cref="T:System.ArgumentNullException">
  4055. /// <paramref name="source" /> or <paramref name="onNext" /> is null.</exception>
  4056. public static IQbservable<TSource> Do<TSource>(this IQbservable<TSource> source, Expression<Action<TSource>> onNext)
  4057. {
  4058. if (source == null)
  4059. throw new ArgumentNullException("source");
  4060. if (onNext == null)
  4061. throw new ArgumentNullException("onNext");
  4062. return source.Provider.CreateQuery<TSource>(
  4063. Expression.Call(
  4064. null,
  4065. #if CRIPPLED_REFLECTION
  4066. InfoOf(() => Qbservable.Do<TSource>(default(IQbservable<TSource>), default(Expression<Action<TSource>>))),
  4067. #else
  4068. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4069. #endif
  4070. source.Expression,
  4071. onNext
  4072. )
  4073. );
  4074. }
  4075. /// <summary>
  4076. /// Invokes an action for each element in the observable sequence and invokes an action upon graceful termination of the observable sequence.
  4077. /// 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.
  4078. /// </summary>
  4079. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4080. /// <param name="source">Source sequence.</param>
  4081. /// <param name="onNext">Action to invoke for each element in the observable sequence.</param>
  4082. /// <param name="onCompleted">Action to invoke upon graceful termination of the observable sequence.</param>
  4083. /// <returns>The source sequence with the side-effecting behavior applied.</returns>
  4084. /// <exception cref="T:System.ArgumentNullException">
  4085. /// <paramref name="source" /> or <paramref name="onNext" /> or <paramref name="onCompleted" /> is null.</exception>
  4086. public static IQbservable<TSource> Do<TSource>(this IQbservable<TSource> source, Expression<Action<TSource>> onNext, Expression<Action> onCompleted)
  4087. {
  4088. if (source == null)
  4089. throw new ArgumentNullException("source");
  4090. if (onNext == null)
  4091. throw new ArgumentNullException("onNext");
  4092. if (onCompleted == null)
  4093. throw new ArgumentNullException("onCompleted");
  4094. return source.Provider.CreateQuery<TSource>(
  4095. Expression.Call(
  4096. null,
  4097. #if CRIPPLED_REFLECTION
  4098. InfoOf(() => Qbservable.Do<TSource>(default(IQbservable<TSource>), default(Expression<Action<TSource>>), default(Expression<Action>))),
  4099. #else
  4100. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4101. #endif
  4102. source.Expression,
  4103. onNext,
  4104. onCompleted
  4105. )
  4106. );
  4107. }
  4108. /// <summary>
  4109. /// Invokes an action for each element in the observable sequence and invokes an action upon exceptional termination of the observable sequence.
  4110. /// 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.
  4111. /// </summary>
  4112. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4113. /// <param name="source">Source sequence.</param>
  4114. /// <param name="onNext">Action to invoke for each element in the observable sequence.</param>
  4115. /// <param name="onError">Action to invoke upon exceptional termination of the observable sequence.</param>
  4116. /// <returns>The source sequence with the side-effecting behavior applied.</returns>
  4117. /// <exception cref="T:System.ArgumentNullException">
  4118. /// <paramref name="source" /> or <paramref name="onNext" /> or <paramref name="onError" /> is null.</exception>
  4119. public static IQbservable<TSource> Do<TSource>(this IQbservable<TSource> source, Expression<Action<TSource>> onNext, Expression<Action<Exception>> onError)
  4120. {
  4121. if (source == null)
  4122. throw new ArgumentNullException("source");
  4123. if (onNext == null)
  4124. throw new ArgumentNullException("onNext");
  4125. if (onError == null)
  4126. throw new ArgumentNullException("onError");
  4127. return source.Provider.CreateQuery<TSource>(
  4128. Expression.Call(
  4129. null,
  4130. #if CRIPPLED_REFLECTION
  4131. InfoOf(() => Qbservable.Do<TSource>(default(IQbservable<TSource>), default(Expression<Action<TSource>>), default(Expression<Action<Exception>>))),
  4132. #else
  4133. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4134. #endif
  4135. source.Expression,
  4136. onNext,
  4137. onError
  4138. )
  4139. );
  4140. }
  4141. /// <summary>
  4142. /// Invokes an action for each element in the observable sequence and invokes an action upon graceful or exceptional termination of the observable sequence.
  4143. /// This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
  4144. /// </summary>
  4145. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4146. /// <param name="source">Source sequence.</param>
  4147. /// <param name="onNext">Action to invoke for each element in the observable sequence.</param>
  4148. /// <param name="onError">Action to invoke upon exceptional termination of the observable sequence.</param>
  4149. /// <param name="onCompleted">Action to invoke upon graceful termination of the observable sequence.</param>
  4150. /// <returns>The source sequence with the side-effecting behavior applied.</returns>
  4151. /// <exception cref="T:System.ArgumentNullException">
  4152. /// <paramref name="source" /> or <paramref name="onNext" /> or <paramref name="onError" /> or <paramref name="onCompleted" /> is null.</exception>
  4153. public static IQbservable<TSource> Do<TSource>(this IQbservable<TSource> source, Expression<Action<TSource>> onNext, Expression<Action<Exception>> onError, Expression<Action> onCompleted)
  4154. {
  4155. if (source == null)
  4156. throw new ArgumentNullException("source");
  4157. if (onNext == null)
  4158. throw new ArgumentNullException("onNext");
  4159. if (onError == null)
  4160. throw new ArgumentNullException("onError");
  4161. if (onCompleted == null)
  4162. throw new ArgumentNullException("onCompleted");
  4163. return source.Provider.CreateQuery<TSource>(
  4164. Expression.Call(
  4165. null,
  4166. #if CRIPPLED_REFLECTION
  4167. InfoOf(() => Qbservable.Do<TSource>(default(IQbservable<TSource>), default(Expression<Action<TSource>>), default(Expression<Action<Exception>>), default(Expression<Action>))),
  4168. #else
  4169. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4170. #endif
  4171. source.Expression,
  4172. onNext,
  4173. onError,
  4174. onCompleted
  4175. )
  4176. );
  4177. }
  4178. /// <summary>
  4179. /// 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.
  4180. /// </summary>
  4181. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4182. /// <param name="source">Source to repeat as long as the <paramref name="condition" /> function evaluates to true.</param>
  4183. /// <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>
  4184. /// <returns>The observable sequence obtained by concatenating the <paramref name="source" /> sequence as long as the <paramref name="condition" /> holds.</returns>
  4185. /// <exception cref="T:System.ArgumentNullException">
  4186. /// <paramref name="source" /> or <paramref name="condition" /> is null.</exception>
  4187. public static IQbservable<TSource> DoWhile<TSource>(this IQbservable<TSource> source, Expression<Func<bool>> condition)
  4188. {
  4189. if (source == null)
  4190. throw new ArgumentNullException("source");
  4191. if (condition == null)
  4192. throw new ArgumentNullException("condition");
  4193. return source.Provider.CreateQuery<TSource>(
  4194. Expression.Call(
  4195. null,
  4196. #if CRIPPLED_REFLECTION
  4197. InfoOf(() => Qbservable.DoWhile<TSource>(default(IQbservable<TSource>), default(Expression<Func<bool>>))),
  4198. #else
  4199. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4200. #endif
  4201. source.Expression,
  4202. condition
  4203. )
  4204. );
  4205. }
  4206. /// <summary>
  4207. /// Returns the element at a specified index in a sequence.
  4208. /// </summary>
  4209. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4210. /// <param name="source">Observable sequence to return the element from.</param>
  4211. /// <param name="index">The zero-based index of the element to retrieve.</param>
  4212. /// <returns>An observable sequence that produces the element at the specified position in the source sequence.</returns>
  4213. /// <exception cref="T:System.ArgumentNullException">
  4214. /// <paramref name="source" /> is null.</exception>
  4215. /// <exception cref="T:System.ArgumentOutOfRangeException">
  4216. /// <paramref name="index" /> is less than zero.</exception>
  4217. /// <exception cref="T:System.ArgumentOutOfRangeException">(Asynchronous) <paramref name="index" /> is greater than or equal to the number of elements in the source sequence.</exception>
  4218. public static IQbservable<TSource> ElementAt<TSource>(this IQbservable<TSource> source, int index)
  4219. {
  4220. if (source == null)
  4221. throw new ArgumentNullException("source");
  4222. return source.Provider.CreateQuery<TSource>(
  4223. Expression.Call(
  4224. null,
  4225. #if CRIPPLED_REFLECTION
  4226. InfoOf(() => Qbservable.ElementAt<TSource>(default(IQbservable<TSource>), default(int))),
  4227. #else
  4228. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4229. #endif
  4230. source.Expression,
  4231. Expression.Constant(index, typeof(int))
  4232. )
  4233. );
  4234. }
  4235. /// <summary>
  4236. /// Returns the element at a specified index in a sequence or a default value if the index is out of range.
  4237. /// </summary>
  4238. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4239. /// <param name="source">Observable sequence to return the element from.</param>
  4240. /// <param name="index">The zero-based index of the element to retrieve.</param>
  4241. /// <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>
  4242. /// <exception cref="T:System.ArgumentNullException">
  4243. /// <paramref name="source" /> is null.</exception>
  4244. /// <exception cref="T:System.ArgumentOutOfRangeException">
  4245. /// <paramref name="index" /> is less than zero.</exception>
  4246. public static IQbservable<TSource> ElementAtOrDefault<TSource>(this IQbservable<TSource> source, int index)
  4247. {
  4248. if (source == null)
  4249. throw new ArgumentNullException("source");
  4250. return source.Provider.CreateQuery<TSource>(
  4251. Expression.Call(
  4252. null,
  4253. #if CRIPPLED_REFLECTION
  4254. InfoOf(() => Qbservable.ElementAtOrDefault<TSource>(default(IQbservable<TSource>), default(int))),
  4255. #else
  4256. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4257. #endif
  4258. source.Expression,
  4259. Expression.Constant(index, typeof(int))
  4260. )
  4261. );
  4262. }
  4263. /// <summary>
  4264. /// Returns an empty observable sequence.
  4265. /// </summary>
  4266. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  4267. /// <typeparam name="TResult">The type used for the IObservable&lt;T&gt; type parameter of the resulting sequence.</typeparam>
  4268. /// <returns>An observable sequence with no elements.</returns>
  4269. public static IQbservable<TResult> Empty<TResult>(this IQbservableProvider provider)
  4270. {
  4271. if (provider == null)
  4272. throw new ArgumentNullException("provider");
  4273. return provider.CreateQuery<TResult>(
  4274. Expression.Call(
  4275. null,
  4276. #if CRIPPLED_REFLECTION
  4277. InfoOf(() => Qbservable.Empty<TResult>(default(IQbservableProvider))),
  4278. #else
  4279. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4280. #endif
  4281. Expression.Constant(provider, typeof(IQbservableProvider))
  4282. )
  4283. );
  4284. }
  4285. /// <summary>
  4286. /// Returns an empty observable sequence, using the specified scheduler to send out the single OnCompleted message.
  4287. /// </summary>
  4288. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  4289. /// <typeparam name="TResult">The type used for the IObservable&lt;T&gt; type parameter of the resulting sequence.</typeparam>
  4290. /// <param name="scheduler">Scheduler to send the termination call on.</param>
  4291. /// <returns>An observable sequence with no elements.</returns>
  4292. /// <exception cref="T:System.ArgumentNullException">
  4293. /// <paramref name="scheduler" /> is null.</exception>
  4294. public static IQbservable<TResult> Empty<TResult>(this IQbservableProvider provider, IScheduler scheduler)
  4295. {
  4296. if (provider == null)
  4297. throw new ArgumentNullException("provider");
  4298. if (scheduler == null)
  4299. throw new ArgumentNullException("scheduler");
  4300. return provider.CreateQuery<TResult>(
  4301. Expression.Call(
  4302. null,
  4303. #if CRIPPLED_REFLECTION
  4304. InfoOf(() => Qbservable.Empty<TResult>(default(IQbservableProvider), default(IScheduler))),
  4305. #else
  4306. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4307. #endif
  4308. Expression.Constant(provider, typeof(IQbservableProvider)),
  4309. Expression.Constant(scheduler, typeof(IScheduler))
  4310. )
  4311. );
  4312. }
  4313. /// <summary>
  4314. /// Returns an empty observable sequence, using the specified scheduler to send out the single OnCompleted message.
  4315. /// </summary>
  4316. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  4317. /// <typeparam name="TResult">The type used for the IObservable&lt;T&gt; type parameter of the resulting sequence.</typeparam>
  4318. /// <param name="scheduler">Scheduler to send the termination call on.</param>
  4319. /// <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>
  4320. /// <returns>An observable sequence with no elements.</returns>
  4321. /// <exception cref="T:System.ArgumentNullException">
  4322. /// <paramref name="scheduler" /> is null.</exception>
  4323. public static IQbservable<TResult> Empty<TResult>(this IQbservableProvider provider, IScheduler scheduler, TResult witness)
  4324. {
  4325. if (provider == null)
  4326. throw new ArgumentNullException("provider");
  4327. if (scheduler == null)
  4328. throw new ArgumentNullException("scheduler");
  4329. return provider.CreateQuery<TResult>(
  4330. Expression.Call(
  4331. null,
  4332. #if CRIPPLED_REFLECTION
  4333. InfoOf(() => Qbservable.Empty<TResult>(default(IQbservableProvider), default(IScheduler), default(TResult))),
  4334. #else
  4335. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4336. #endif
  4337. Expression.Constant(provider, typeof(IQbservableProvider)),
  4338. Expression.Constant(scheduler, typeof(IScheduler)),
  4339. Expression.Constant(witness, typeof(TResult))
  4340. )
  4341. );
  4342. }
  4343. /// <summary>
  4344. /// Returns an empty observable sequence.
  4345. /// </summary>
  4346. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  4347. /// <typeparam name="TResult">The type used for the IObservable&lt;T&gt; type parameter of the resulting sequence.</typeparam>
  4348. /// <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>
  4349. /// <returns>An observable sequence with no elements.</returns>
  4350. public static IQbservable<TResult> Empty<TResult>(this IQbservableProvider provider, TResult witness)
  4351. {
  4352. if (provider == null)
  4353. throw new ArgumentNullException("provider");
  4354. return provider.CreateQuery<TResult>(
  4355. Expression.Call(
  4356. null,
  4357. #if CRIPPLED_REFLECTION
  4358. InfoOf(() => Qbservable.Empty<TResult>(default(IQbservableProvider), default(TResult))),
  4359. #else
  4360. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4361. #endif
  4362. Expression.Constant(provider, typeof(IQbservableProvider)),
  4363. Expression.Constant(witness, typeof(TResult))
  4364. )
  4365. );
  4366. }
  4367. /// <summary>
  4368. /// Invokes a specified action after the source observable sequence terminates gracefully or exceptionally.
  4369. /// </summary>
  4370. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4371. /// <param name="source">Source sequence.</param>
  4372. /// <param name="finallyAction">Action to invoke after the source observable sequence terminates.</param>
  4373. /// <returns>Source sequence with the action-invoking termination behavior applied.</returns>
  4374. /// <exception cref="T:System.ArgumentNullException">
  4375. /// <paramref name="source" /> or <paramref name="finallyAction" /> is null.</exception>
  4376. public static IQbservable<TSource> Finally<TSource>(this IQbservable<TSource> source, Expression<Action> finallyAction)
  4377. {
  4378. if (source == null)
  4379. throw new ArgumentNullException("source");
  4380. if (finallyAction == null)
  4381. throw new ArgumentNullException("finallyAction");
  4382. return source.Provider.CreateQuery<TSource>(
  4383. Expression.Call(
  4384. null,
  4385. #if CRIPPLED_REFLECTION
  4386. InfoOf(() => Qbservable.Finally<TSource>(default(IQbservable<TSource>), default(Expression<Action>))),
  4387. #else
  4388. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4389. #endif
  4390. source.Expression,
  4391. finallyAction
  4392. )
  4393. );
  4394. }
  4395. /// <summary>
  4396. /// Returns the first element of an observable sequence.
  4397. /// </summary>
  4398. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4399. /// <param name="source">Source observable sequence.</param>
  4400. /// <returns>Sequence containing the first element in the observable sequence.</returns>
  4401. /// <exception cref="T:System.ArgumentNullException">
  4402. /// <paramref name="source" /> is null.</exception>
  4403. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  4404. public static IQbservable<TSource> FirstAsync<TSource>(this IQbservable<TSource> source)
  4405. {
  4406. if (source == null)
  4407. throw new ArgumentNullException("source");
  4408. return source.Provider.CreateQuery<TSource>(
  4409. Expression.Call(
  4410. null,
  4411. #if CRIPPLED_REFLECTION
  4412. InfoOf(() => Qbservable.FirstAsync<TSource>(default(IQbservable<TSource>))),
  4413. #else
  4414. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4415. #endif
  4416. source.Expression
  4417. )
  4418. );
  4419. }
  4420. /// <summary>
  4421. /// Returns the first element of an observable sequence that satisfies the condition in the predicate.
  4422. /// </summary>
  4423. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4424. /// <param name="source">Source observable sequence.</param>
  4425. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  4426. /// <returns>Sequence containing the first element in the observable sequence that satisfies the condition in the predicate.</returns>
  4427. /// <exception cref="T:System.ArgumentNullException">
  4428. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  4429. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) No element satisfies the condition in the predicate. -or- The source sequence is empty.</exception>
  4430. public static IQbservable<TSource> FirstAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  4431. {
  4432. if (source == null)
  4433. throw new ArgumentNullException("source");
  4434. if (predicate == null)
  4435. throw new ArgumentNullException("predicate");
  4436. return source.Provider.CreateQuery<TSource>(
  4437. Expression.Call(
  4438. null,
  4439. #if CRIPPLED_REFLECTION
  4440. InfoOf(() => Qbservable.FirstAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  4441. #else
  4442. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4443. #endif
  4444. source.Expression,
  4445. predicate
  4446. )
  4447. );
  4448. }
  4449. /// <summary>
  4450. /// Returns the first element of an observable sequence, or a default value if no such element exists.
  4451. /// </summary>
  4452. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4453. /// <param name="source">Source observable sequence.</param>
  4454. /// <returns>Sequence containing the first element in the observable sequence, or a default value if no such element exists.</returns>
  4455. /// <exception cref="T:System.ArgumentNullException">
  4456. /// <paramref name="source" /> is null.</exception>
  4457. public static IQbservable<TSource> FirstOrDefaultAsync<TSource>(this IQbservable<TSource> source)
  4458. {
  4459. if (source == null)
  4460. throw new ArgumentNullException("source");
  4461. return source.Provider.CreateQuery<TSource>(
  4462. Expression.Call(
  4463. null,
  4464. #if CRIPPLED_REFLECTION
  4465. InfoOf(() => Qbservable.FirstOrDefaultAsync<TSource>(default(IQbservable<TSource>))),
  4466. #else
  4467. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4468. #endif
  4469. source.Expression
  4470. )
  4471. );
  4472. }
  4473. /// <summary>
  4474. /// Returns the first element of an observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.
  4475. /// </summary>
  4476. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4477. /// <param name="source">Source observable sequence.</param>
  4478. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  4479. /// <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>
  4480. /// <exception cref="T:System.ArgumentNullException">
  4481. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  4482. public static IQbservable<TSource> FirstOrDefaultAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  4483. {
  4484. if (source == null)
  4485. throw new ArgumentNullException("source");
  4486. if (predicate == null)
  4487. throw new ArgumentNullException("predicate");
  4488. return source.Provider.CreateQuery<TSource>(
  4489. Expression.Call(
  4490. null,
  4491. #if CRIPPLED_REFLECTION
  4492. InfoOf(() => Qbservable.FirstOrDefaultAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  4493. #else
  4494. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4495. #endif
  4496. source.Expression,
  4497. predicate
  4498. )
  4499. );
  4500. }
  4501. /// <summary>
  4502. /// Concatenates the observable sequences obtained by running the <paramref name="resultSelector" /> for each element in the given enumerable <paramref name="source" />.
  4503. /// </summary>
  4504. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  4505. /// <typeparam name="TSource">The type of the elements in the enumerable source sequence.</typeparam>
  4506. /// <typeparam name="TResult">The type of the elements in the observable result sequence.</typeparam>
  4507. /// <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>
  4508. /// <param name="resultSelector">Function to select an observable source for each element in the <paramref name="source" />.</param>
  4509. /// <returns>The observable sequence obtained by concatenating the sources returned by <paramref name="resultSelector" /> for each element in the <paramref name="source" />.</returns>
  4510. /// <exception cref="T:System.ArgumentNullException">
  4511. /// <paramref name="source" /> or <paramref name="resultSelector" /> is null.</exception>
  4512. public static IQbservable<TResult> For<TSource, TResult>(this IQbservableProvider provider, IEnumerable<TSource> source, Expression<Func<TSource, IObservable<TResult>>> resultSelector)
  4513. {
  4514. if (provider == null)
  4515. throw new ArgumentNullException("provider");
  4516. if (source == null)
  4517. throw new ArgumentNullException("source");
  4518. if (resultSelector == null)
  4519. throw new ArgumentNullException("resultSelector");
  4520. return provider.CreateQuery<TResult>(
  4521. Expression.Call(
  4522. null,
  4523. #if CRIPPLED_REFLECTION
  4524. InfoOf(() => Qbservable.For<TSource, TResult>(default(IQbservableProvider), default(IEnumerable<TSource>), default(Expression<Func<TSource, IObservable<TResult>>>))),
  4525. #else
  4526. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  4527. #endif
  4528. Expression.Constant(provider, typeof(IQbservableProvider)),
  4529. GetSourceExpression(source),
  4530. resultSelector
  4531. )
  4532. );
  4533. }
  4534. #if !NO_TPL
  4535. /// <summary>
  4536. /// Converts to asynchronous action into an observable sequence. Each subscription to the resulting sequence causes the action to be started.
  4537. /// </summary>
  4538. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  4539. /// <param name="actionAsync">Asynchronous action to convert.</param>
  4540. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  4541. /// <exception cref="T:System.ArgumentNullException">
  4542. /// <paramref name="actionAsync" /> is null.</exception>
  4543. public static IQbservable<Unit> FromAsync(this IQbservableProvider provider, Expression<Func<Task>> actionAsync)
  4544. {
  4545. if (provider == null)
  4546. throw new ArgumentNullException("provider");
  4547. if (actionAsync == null)
  4548. throw new ArgumentNullException("actionAsync");
  4549. return provider.CreateQuery<Unit>(
  4550. Expression.Call(
  4551. null,
  4552. #if CRIPPLED_REFLECTION
  4553. InfoOf(() => Qbservable.FromAsync(default(IQbservableProvider), default(Expression<Func<Task>>))),
  4554. #else
  4555. (MethodInfo)MethodInfo.GetCurrentMethod(),
  4556. #endif
  4557. Expression.Constant(provider, typeof(IQbservableProvider)),
  4558. actionAsync
  4559. )
  4560. );
  4561. }
  4562. #endif
  4563. #if !NO_TPL
  4564. /// <summary>
  4565. /// Converts to asynchronous action into an observable sequence. Each subscription to the resulting sequence causes the action to be started.
  4566. /// 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.
  4567. /// </summary>
  4568. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  4569. /// <param name="actionAsync">Asynchronous action to convert.</param>
  4570. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  4571. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous function will be signaled.</remarks>
  4572. /// <exception cref="T:System.ArgumentNullException">
  4573. /// <paramref name="actionAsync" /> is null.</exception>
  4574. public static IQbservable<Unit> FromAsync(this IQbservableProvider provider, Expression<Func<CancellationToken, Task>> actionAsync)
  4575. {
  4576. if (provider == null)
  4577. throw new ArgumentNullException("provider");
  4578. if (actionAsync == null)
  4579. throw new ArgumentNullException("actionAsync");
  4580. return provider.CreateQuery<Unit>(
  4581. Expression.Call(
  4582. null,
  4583. #if CRIPPLED_REFLECTION
  4584. InfoOf(() => Qbservable.FromAsync(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task>>))),
  4585. #else
  4586. (MethodInfo)MethodInfo.GetCurrentMethod(),
  4587. #endif
  4588. Expression.Constant(provider, typeof(IQbservableProvider)),
  4589. actionAsync
  4590. )
  4591. );
  4592. }
  4593. #endif
  4594. #if !NO_TPL
  4595. /// <summary>
  4596. /// Converts to asynchronous function into an observable sequence. Each subscription to the resulting sequence causes the function to be started.
  4597. /// </summary>
  4598. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  4599. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  4600. /// <param name="functionAsync">Asynchronous function to convert.</param>
  4601. /// <returns>An observable sequence exposing the result of invoking the function, or an exception.</returns>
  4602. /// <exception cref="T:System.ArgumentNullException">
  4603. /// <paramref name="functionAsync" /> is null.</exception>
  4604. public static IQbservable<TResult> FromAsync<TResult>(this IQbservableProvider provider, Expression<Func<Task<TResult>>> functionAsync)
  4605. {
  4606. if (provider == null)
  4607. throw new ArgumentNullException("provider");
  4608. if (functionAsync == null)
  4609. throw new ArgumentNullException("functionAsync");
  4610. return provider.CreateQuery<TResult>(
  4611. Expression.Call(
  4612. null,
  4613. #if CRIPPLED_REFLECTION
  4614. InfoOf(() => Qbservable.FromAsync<TResult>(default(IQbservableProvider), default(Expression<Func<Task<TResult>>>))),
  4615. #else
  4616. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4617. #endif
  4618. Expression.Constant(provider, typeof(IQbservableProvider)),
  4619. functionAsync
  4620. )
  4621. );
  4622. }
  4623. #endif
  4624. #if !NO_TPL
  4625. /// <summary>
  4626. /// Converts to asynchronous function into an observable sequence. Each subscription to the resulting sequence causes the function to be started.
  4627. /// 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.
  4628. /// </summary>
  4629. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  4630. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  4631. /// <param name="functionAsync">Asynchronous function to convert.</param>
  4632. /// <returns>An observable sequence exposing the result of invoking the function, or an exception.</returns>
  4633. /// <exception cref="T:System.ArgumentNullException">
  4634. /// <paramref name="functionAsync" /> is null.</exception>
  4635. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous function will be signaled.</remarks>
  4636. public static IQbservable<TResult> FromAsync<TResult>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<TResult>>> functionAsync)
  4637. {
  4638. if (provider == null)
  4639. throw new ArgumentNullException("provider");
  4640. if (functionAsync == null)
  4641. throw new ArgumentNullException("functionAsync");
  4642. return provider.CreateQuery<TResult>(
  4643. Expression.Call(
  4644. null,
  4645. #if CRIPPLED_REFLECTION
  4646. InfoOf(() => Qbservable.FromAsync<TResult>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<TResult>>>))),
  4647. #else
  4648. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4649. #endif
  4650. Expression.Constant(provider, typeof(IQbservableProvider)),
  4651. functionAsync
  4652. )
  4653. );
  4654. }
  4655. #endif
  4656. /// <summary>
  4657. /// Converts an Action-based .NET event to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence.
  4658. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  4659. /// </summary>
  4660. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  4661. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  4662. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  4663. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  4664. /// <exception cref="T:System.ArgumentNullException">
  4665. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  4666. /// <remarks>
  4667. /// <para>
  4668. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  4669. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  4670. /// </para>
  4671. /// <para>
  4672. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEvent, and is used to post add and remove handler invocations.
  4673. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  4674. /// </para>
  4675. /// <para>
  4676. /// If no SynchronizationContext is present at the point of calling FromEvent, add and remove handler invocations are made synchronously on the thread
  4677. /// making the Subscribe or Dispose call, respectively.
  4678. /// </para>
  4679. /// <para>
  4680. /// It's recommended to lift FromEvent calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  4681. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  4682. /// more concise and easier to understand.
  4683. /// </para>
  4684. /// </remarks>
  4685. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  4686. public static IQbservable<Unit> FromEvent(this IQbservableProvider provider, Expression<Action<Action>> addHandler, Expression<Action<Action>> removeHandler)
  4687. {
  4688. if (provider == null)
  4689. throw new ArgumentNullException("provider");
  4690. if (addHandler == null)
  4691. throw new ArgumentNullException("addHandler");
  4692. if (removeHandler == null)
  4693. throw new ArgumentNullException("removeHandler");
  4694. return provider.CreateQuery<Unit>(
  4695. Expression.Call(
  4696. null,
  4697. #if CRIPPLED_REFLECTION
  4698. InfoOf(() => Qbservable.FromEvent(default(IQbservableProvider), default(Expression<Action<Action>>), default(Expression<Action<Action>>))),
  4699. #else
  4700. (MethodInfo)MethodInfo.GetCurrentMethod(),
  4701. #endif
  4702. Expression.Constant(provider, typeof(IQbservableProvider)),
  4703. addHandler,
  4704. removeHandler
  4705. )
  4706. );
  4707. }
  4708. /// <summary>
  4709. /// Converts an Action-based .NET event to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence.
  4710. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  4711. /// </summary>
  4712. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  4713. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  4714. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  4715. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  4716. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  4717. /// <exception cref="T:System.ArgumentNullException">
  4718. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  4719. /// <remarks>
  4720. /// <para>
  4721. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  4722. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  4723. /// </para>
  4724. /// <para>
  4725. /// 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
  4726. /// accessed from the same context, as required by some UI frameworks.
  4727. /// </para>
  4728. /// <para>
  4729. /// It's recommended to lift FromEvent calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  4730. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEvent that omit the IScheduler
  4731. /// parameter. For more information, see the remarks section on those overloads.
  4732. /// </para>
  4733. /// </remarks>
  4734. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  4735. public static IQbservable<Unit> FromEvent(this IQbservableProvider provider, Expression<Action<Action>> addHandler, Expression<Action<Action>> removeHandler, IScheduler scheduler)
  4736. {
  4737. if (provider == null)
  4738. throw new ArgumentNullException("provider");
  4739. if (addHandler == null)
  4740. throw new ArgumentNullException("addHandler");
  4741. if (removeHandler == null)
  4742. throw new ArgumentNullException("removeHandler");
  4743. if (scheduler == null)
  4744. throw new ArgumentNullException("scheduler");
  4745. return provider.CreateQuery<Unit>(
  4746. Expression.Call(
  4747. null,
  4748. #if CRIPPLED_REFLECTION
  4749. InfoOf(() => Qbservable.FromEvent(default(IQbservableProvider), default(Expression<Action<Action>>), default(Expression<Action<Action>>), default(IScheduler))),
  4750. #else
  4751. (MethodInfo)MethodInfo.GetCurrentMethod(),
  4752. #endif
  4753. Expression.Constant(provider, typeof(IQbservableProvider)),
  4754. addHandler,
  4755. removeHandler,
  4756. Expression.Constant(scheduler, typeof(IScheduler))
  4757. )
  4758. );
  4759. }
  4760. /// <summary>
  4761. /// 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.
  4762. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  4763. /// </summary>
  4764. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  4765. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  4766. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  4767. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  4768. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  4769. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  4770. /// <exception cref="T:System.ArgumentNullException">
  4771. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  4772. /// <remarks>
  4773. /// <para>
  4774. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  4775. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  4776. /// </para>
  4777. /// <para>
  4778. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEvent, and is used to post add and remove handler invocations.
  4779. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  4780. /// </para>
  4781. /// <para>
  4782. /// If no SynchronizationContext is present at the point of calling FromEvent, add and remove handler invocations are made synchronously on the thread
  4783. /// making the Subscribe or Dispose call, respectively.
  4784. /// </para>
  4785. /// <para>
  4786. /// It's recommended to lift FromEvent calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  4787. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  4788. /// more concise and easier to understand.
  4789. /// </para>
  4790. /// </remarks>
  4791. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  4792. public static IQbservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)
  4793. {
  4794. if (provider == null)
  4795. throw new ArgumentNullException("provider");
  4796. if (addHandler == null)
  4797. throw new ArgumentNullException("addHandler");
  4798. if (removeHandler == null)
  4799. throw new ArgumentNullException("removeHandler");
  4800. return provider.CreateQuery<TEventArgs>(
  4801. Expression.Call(
  4802. null,
  4803. #if CRIPPLED_REFLECTION
  4804. InfoOf(() => Qbservable.FromEvent<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>))),
  4805. #else
  4806. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  4807. #endif
  4808. Expression.Constant(provider, typeof(IQbservableProvider)),
  4809. addHandler,
  4810. removeHandler
  4811. )
  4812. );
  4813. }
  4814. /// <summary>
  4815. /// 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.
  4816. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  4817. /// </summary>
  4818. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  4819. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  4820. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  4821. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  4822. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  4823. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  4824. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  4825. /// <exception cref="T:System.ArgumentNullException">
  4826. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  4827. /// <remarks>
  4828. /// <para>
  4829. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  4830. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  4831. /// </para>
  4832. /// <para>
  4833. /// 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
  4834. /// accessed from the same context, as required by some UI frameworks.
  4835. /// </para>
  4836. /// <para>
  4837. /// It's recommended to lift FromEvent calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  4838. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEvent that omit the IScheduler
  4839. /// parameter. For more information, see the remarks section on those overloads.
  4840. /// </para>
  4841. /// </remarks>
  4842. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  4843. public static IQbservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler, IScheduler scheduler)
  4844. {
  4845. if (provider == null)
  4846. throw new ArgumentNullException("provider");
  4847. if (addHandler == null)
  4848. throw new ArgumentNullException("addHandler");
  4849. if (removeHandler == null)
  4850. throw new ArgumentNullException("removeHandler");
  4851. if (scheduler == null)
  4852. throw new ArgumentNullException("scheduler");
  4853. return provider.CreateQuery<TEventArgs>(
  4854. Expression.Call(
  4855. null,
  4856. #if CRIPPLED_REFLECTION
  4857. InfoOf(() => Qbservable.FromEvent<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>), default(IScheduler))),
  4858. #else
  4859. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  4860. #endif
  4861. Expression.Constant(provider, typeof(IQbservableProvider)),
  4862. addHandler,
  4863. removeHandler,
  4864. Expression.Constant(scheduler, typeof(IScheduler))
  4865. )
  4866. );
  4867. }
  4868. /// <summary>
  4869. /// 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.
  4870. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  4871. /// </summary>
  4872. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  4873. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  4874. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  4875. /// <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>
  4876. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  4877. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  4878. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  4879. /// <exception cref="T:System.ArgumentNullException">
  4880. /// <paramref name="conversion" /> or <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  4881. /// <remarks>
  4882. /// <para>
  4883. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  4884. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  4885. /// </para>
  4886. /// <para>
  4887. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEvent, and is used to post add and remove handler invocations.
  4888. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  4889. /// </para>
  4890. /// <para>
  4891. /// If no SynchronizationContext is present at the point of calling FromEvent, add and remove handler invocations are made synchronously on the thread
  4892. /// making the Subscribe or Dispose call, respectively.
  4893. /// </para>
  4894. /// <para>
  4895. /// It's recommended to lift FromEvent calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  4896. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  4897. /// more concise and easier to understand.
  4898. /// </para>
  4899. /// </remarks>
  4900. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  4901. public static IQbservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Func<Action<TEventArgs>, TDelegate>> conversion, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)
  4902. {
  4903. if (provider == null)
  4904. throw new ArgumentNullException("provider");
  4905. if (conversion == null)
  4906. throw new ArgumentNullException("conversion");
  4907. if (addHandler == null)
  4908. throw new ArgumentNullException("addHandler");
  4909. if (removeHandler == null)
  4910. throw new ArgumentNullException("removeHandler");
  4911. return provider.CreateQuery<TEventArgs>(
  4912. Expression.Call(
  4913. null,
  4914. #if CRIPPLED_REFLECTION
  4915. InfoOf(() => Qbservable.FromEvent<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Func<Action<TEventArgs>, TDelegate>>), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>))),
  4916. #else
  4917. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  4918. #endif
  4919. Expression.Constant(provider, typeof(IQbservableProvider)),
  4920. conversion,
  4921. addHandler,
  4922. removeHandler
  4923. )
  4924. );
  4925. }
  4926. /// <summary>
  4927. /// 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.
  4928. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  4929. /// </summary>
  4930. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  4931. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  4932. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  4933. /// <param name="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>
  4934. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  4935. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  4936. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  4937. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  4938. /// <exception cref="T:System.ArgumentNullException">
  4939. /// <paramref name="conversion" /> or <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  4940. /// <remarks>
  4941. /// <para>
  4942. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  4943. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  4944. /// </para>
  4945. /// <para>
  4946. /// 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
  4947. /// accessed from the same context, as required by some UI frameworks.
  4948. /// </para>
  4949. /// <para>
  4950. /// It's recommended to lift FromEvent calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  4951. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEvent that omit the IScheduler
  4952. /// parameter. For more information, see the remarks section on those overloads.
  4953. /// </para>
  4954. /// </remarks>
  4955. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  4956. public static IQbservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Func<Action<TEventArgs>, TDelegate>> conversion, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler, IScheduler scheduler)
  4957. {
  4958. if (provider == null)
  4959. throw new ArgumentNullException("provider");
  4960. if (conversion == null)
  4961. throw new ArgumentNullException("conversion");
  4962. if (addHandler == null)
  4963. throw new ArgumentNullException("addHandler");
  4964. if (removeHandler == null)
  4965. throw new ArgumentNullException("removeHandler");
  4966. if (scheduler == null)
  4967. throw new ArgumentNullException("scheduler");
  4968. return provider.CreateQuery<TEventArgs>(
  4969. Expression.Call(
  4970. null,
  4971. #if CRIPPLED_REFLECTION
  4972. InfoOf(() => Qbservable.FromEvent<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Func<Action<TEventArgs>, TDelegate>>), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>), default(IScheduler))),
  4973. #else
  4974. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  4975. #endif
  4976. Expression.Constant(provider, typeof(IQbservableProvider)),
  4977. conversion,
  4978. addHandler,
  4979. removeHandler,
  4980. Expression.Constant(scheduler, typeof(IScheduler))
  4981. )
  4982. );
  4983. }
  4984. /// <summary>
  4985. /// Converts a generic Action-based .NET event to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence.
  4986. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  4987. /// </summary>
  4988. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  4989. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  4990. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  4991. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  4992. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  4993. /// <exception cref="T:System.ArgumentNullException">
  4994. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  4995. /// <remarks>
  4996. /// <para>
  4997. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  4998. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  4999. /// </para>
  5000. /// <para>
  5001. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEvent, and is used to post add and remove handler invocations.
  5002. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5003. /// </para>
  5004. /// <para>
  5005. /// If no SynchronizationContext is present at the point of calling FromEvent, add and remove handler invocations are made synchronously on the thread
  5006. /// making the Subscribe or Dispose call, respectively.
  5007. /// </para>
  5008. /// <para>
  5009. /// It's recommended to lift FromEvent calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5010. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5011. /// more concise and easier to understand.
  5012. /// </para>
  5013. /// </remarks>
  5014. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  5015. public static IQbservable<TEventArgs> FromEvent<TEventArgs>(this IQbservableProvider provider, Expression<Action<Action<TEventArgs>>> addHandler, Expression<Action<Action<TEventArgs>>> removeHandler)
  5016. {
  5017. if (provider == null)
  5018. throw new ArgumentNullException("provider");
  5019. if (addHandler == null)
  5020. throw new ArgumentNullException("addHandler");
  5021. if (removeHandler == null)
  5022. throw new ArgumentNullException("removeHandler");
  5023. return provider.CreateQuery<TEventArgs>(
  5024. Expression.Call(
  5025. null,
  5026. #if CRIPPLED_REFLECTION
  5027. InfoOf(() => Qbservable.FromEvent<TEventArgs>(default(IQbservableProvider), default(Expression<Action<Action<TEventArgs>>>), default(Expression<Action<Action<TEventArgs>>>))),
  5028. #else
  5029. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  5030. #endif
  5031. Expression.Constant(provider, typeof(IQbservableProvider)),
  5032. addHandler,
  5033. removeHandler
  5034. )
  5035. );
  5036. }
  5037. /// <summary>
  5038. /// Converts a generic Action-based .NET event to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5039. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  5040. /// </summary>
  5041. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5042. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5043. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5044. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5045. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5046. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  5047. /// <exception cref="T:System.ArgumentNullException">
  5048. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5049. /// <remarks>
  5050. /// <para>
  5051. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5052. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5053. /// </para>
  5054. /// <para>
  5055. /// 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
  5056. /// accessed from the same context, as required by some UI frameworks.
  5057. /// </para>
  5058. /// <para>
  5059. /// It's recommended to lift FromEvent calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5060. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEvent that omit the IScheduler
  5061. /// parameter. For more information, see the remarks section on those overloads.
  5062. /// </para>
  5063. /// </remarks>
  5064. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  5065. public static IQbservable<TEventArgs> FromEvent<TEventArgs>(this IQbservableProvider provider, Expression<Action<Action<TEventArgs>>> addHandler, Expression<Action<Action<TEventArgs>>> removeHandler, IScheduler scheduler)
  5066. {
  5067. if (provider == null)
  5068. throw new ArgumentNullException("provider");
  5069. if (addHandler == null)
  5070. throw new ArgumentNullException("addHandler");
  5071. if (removeHandler == null)
  5072. throw new ArgumentNullException("removeHandler");
  5073. if (scheduler == null)
  5074. throw new ArgumentNullException("scheduler");
  5075. return provider.CreateQuery<TEventArgs>(
  5076. Expression.Call(
  5077. null,
  5078. #if CRIPPLED_REFLECTION
  5079. InfoOf(() => Qbservable.FromEvent<TEventArgs>(default(IQbservableProvider), default(Expression<Action<Action<TEventArgs>>>), default(Expression<Action<Action<TEventArgs>>>), default(IScheduler))),
  5080. #else
  5081. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  5082. #endif
  5083. Expression.Constant(provider, typeof(IQbservableProvider)),
  5084. addHandler,
  5085. removeHandler,
  5086. Expression.Constant(scheduler, typeof(IScheduler))
  5087. )
  5088. );
  5089. }
  5090. #if !NO_EVENTARGS_CONSTRAINT
  5091. /// <summary>
  5092. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="T:System.EventHandler" />, to an observable sequence.
  5093. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5094. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5095. /// </summary>
  5096. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5097. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5098. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5099. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5100. /// <exception cref="T:System.ArgumentNullException">
  5101. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  5102. /// <remarks>
  5103. /// <para>
  5104. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5105. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5106. /// </para>
  5107. /// <para>
  5108. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  5109. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5110. /// </para>
  5111. /// <para>
  5112. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5113. /// making the Subscribe or Dispose call, respectively.
  5114. /// </para>
  5115. /// <para>
  5116. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5117. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5118. /// more concise and easier to understand.
  5119. /// </para>
  5120. /// </remarks>
  5121. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5122. public static IQbservable<EventPattern<EventArgs>> FromEventPattern(this IQbservableProvider provider, Expression<Action<EventHandler>> addHandler, Expression<Action<EventHandler>> removeHandler)
  5123. {
  5124. if (provider == null)
  5125. throw new ArgumentNullException("provider");
  5126. if (addHandler == null)
  5127. throw new ArgumentNullException("addHandler");
  5128. if (removeHandler == null)
  5129. throw new ArgumentNullException("removeHandler");
  5130. return provider.CreateQuery<EventPattern<EventArgs>>(
  5131. Expression.Call(
  5132. null,
  5133. #if CRIPPLED_REFLECTION
  5134. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Expression<Action<EventHandler>>), default(Expression<Action<EventHandler>>))),
  5135. #else
  5136. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5137. #endif
  5138. Expression.Constant(provider, typeof(IQbservableProvider)),
  5139. addHandler,
  5140. removeHandler
  5141. )
  5142. );
  5143. }
  5144. #else
  5145. /// <summary>
  5146. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="T:System.EventHandler" />, to an observable sequence.
  5147. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5148. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5149. /// </summary>
  5150. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5151. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5152. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5153. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5154. /// <exception cref="T:System.ArgumentNullException">
  5155. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  5156. /// <remarks>
  5157. /// <para>
  5158. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5159. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5160. /// </para>
  5161. /// <para>
  5162. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  5163. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5164. /// </para>
  5165. /// <para>
  5166. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5167. /// making the Subscribe or Dispose call, respectively.
  5168. /// </para>
  5169. /// <para>
  5170. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5171. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5172. /// more concise and easier to understand.
  5173. /// </para>
  5174. /// </remarks>
  5175. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5176. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, Expression<Action<EventHandler>> addHandler, Expression<Action<EventHandler>> removeHandler)
  5177. {
  5178. if (provider == null)
  5179. throw new ArgumentNullException("provider");
  5180. if (addHandler == null)
  5181. throw new ArgumentNullException("addHandler");
  5182. if (removeHandler == null)
  5183. throw new ArgumentNullException("removeHandler");
  5184. return provider.CreateQuery<EventPattern<object>>(
  5185. Expression.Call(
  5186. null,
  5187. #if CRIPPLED_REFLECTION
  5188. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Expression<Action<EventHandler>>), default(Expression<Action<EventHandler>>))),
  5189. #else
  5190. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5191. #endif
  5192. Expression.Constant(provider, typeof(IQbservableProvider)),
  5193. addHandler,
  5194. removeHandler
  5195. )
  5196. );
  5197. }
  5198. #endif
  5199. #if !NO_EVENTARGS_CONSTRAINT
  5200. /// <summary>
  5201. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="T:System.EventHandler" />, to an observable sequence.
  5202. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5203. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5204. /// </summary>
  5205. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5206. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5207. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5208. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5209. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5210. /// <exception cref="T:System.ArgumentNullException">
  5211. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5212. /// <remarks>
  5213. /// <para>
  5214. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5215. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5216. /// </para>
  5217. /// <para>
  5218. /// 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
  5219. /// accessed from the same context, as required by some UI frameworks.
  5220. /// </para>
  5221. /// <para>
  5222. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5223. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5224. /// parameter. For more information, see the remarks section on those overloads.
  5225. /// </para>
  5226. /// </remarks>
  5227. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5228. public static IQbservable<EventPattern<EventArgs>> FromEventPattern(this IQbservableProvider provider, Expression<Action<EventHandler>> addHandler, Expression<Action<EventHandler>> removeHandler, IScheduler scheduler)
  5229. {
  5230. if (provider == null)
  5231. throw new ArgumentNullException("provider");
  5232. if (addHandler == null)
  5233. throw new ArgumentNullException("addHandler");
  5234. if (removeHandler == null)
  5235. throw new ArgumentNullException("removeHandler");
  5236. if (scheduler == null)
  5237. throw new ArgumentNullException("scheduler");
  5238. return provider.CreateQuery<EventPattern<EventArgs>>(
  5239. Expression.Call(
  5240. null,
  5241. #if CRIPPLED_REFLECTION
  5242. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Expression<Action<EventHandler>>), default(Expression<Action<EventHandler>>), default(IScheduler))),
  5243. #else
  5244. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5245. #endif
  5246. Expression.Constant(provider, typeof(IQbservableProvider)),
  5247. addHandler,
  5248. removeHandler,
  5249. Expression.Constant(scheduler, typeof(IScheduler))
  5250. )
  5251. );
  5252. }
  5253. #else
  5254. /// <summary>
  5255. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="T:System.EventHandler" />, to an observable sequence.
  5256. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5257. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5258. /// </summary>
  5259. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5260. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5261. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5262. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5263. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5264. /// <exception cref="T:System.ArgumentNullException">
  5265. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5266. /// <remarks>
  5267. /// <para>
  5268. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5269. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5270. /// </para>
  5271. /// <para>
  5272. /// 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
  5273. /// accessed from the same context, as required by some UI frameworks.
  5274. /// </para>
  5275. /// <para>
  5276. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5277. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5278. /// parameter. For more information, see the remarks section on those overloads.
  5279. /// </para>
  5280. /// </remarks>
  5281. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5282. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, Expression<Action<EventHandler>> addHandler, Expression<Action<EventHandler>> removeHandler, IScheduler scheduler)
  5283. {
  5284. if (provider == null)
  5285. throw new ArgumentNullException("provider");
  5286. if (addHandler == null)
  5287. throw new ArgumentNullException("addHandler");
  5288. if (removeHandler == null)
  5289. throw new ArgumentNullException("removeHandler");
  5290. if (scheduler == null)
  5291. throw new ArgumentNullException("scheduler");
  5292. return provider.CreateQuery<EventPattern<object>>(
  5293. Expression.Call(
  5294. null,
  5295. #if CRIPPLED_REFLECTION
  5296. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Expression<Action<EventHandler>>), default(Expression<Action<EventHandler>>), default(IScheduler))),
  5297. #else
  5298. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5299. #endif
  5300. Expression.Constant(provider, typeof(IQbservableProvider)),
  5301. addHandler,
  5302. removeHandler,
  5303. Expression.Constant(scheduler, typeof(IScheduler))
  5304. )
  5305. );
  5306. }
  5307. #endif
  5308. #if !NO_EVENTARGS_CONSTRAINT
  5309. /// <summary>
  5310. /// Converts an instance .NET event, conforming to the standard .NET event pattern with an <see cref="T:System.EventArgs" /> parameter, to an observable sequence.
  5311. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5312. /// Reflection is used to discover the event based on the target object type and the specified event name.
  5313. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5314. /// </summary>
  5315. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5316. /// <param name="target">Object instance that exposes the event to convert.</param>
  5317. /// <param name="eventName">Name of the event to convert.</param>
  5318. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5319. /// <exception cref="T:System.ArgumentNullException">
  5320. /// <paramref name="target" /> or <paramref name="eventName" /> is null.</exception>
  5321. /// <exception cref="T:System.InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5322. /// <remarks>
  5323. /// <para>
  5324. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5325. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5326. /// </para>
  5327. /// <para>
  5328. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  5329. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5330. /// </para>
  5331. /// <para>
  5332. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5333. /// making the Subscribe or Dispose call, respectively.
  5334. /// </para>
  5335. /// <para>
  5336. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5337. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5338. /// more concise and easier to understand.
  5339. /// </para>
  5340. /// </remarks>
  5341. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5342. public static IQbservable<EventPattern<EventArgs>> FromEventPattern(this IQbservableProvider provider, object target, string eventName)
  5343. {
  5344. if (provider == null)
  5345. throw new ArgumentNullException("provider");
  5346. if (target == null)
  5347. throw new ArgumentNullException("target");
  5348. if (eventName == null)
  5349. throw new ArgumentNullException("eventName");
  5350. return provider.CreateQuery<EventPattern<EventArgs>>(
  5351. Expression.Call(
  5352. null,
  5353. #if CRIPPLED_REFLECTION
  5354. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(object), default(string))),
  5355. #else
  5356. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5357. #endif
  5358. Expression.Constant(provider, typeof(IQbservableProvider)),
  5359. Expression.Constant(target, typeof(object)),
  5360. Expression.Constant(eventName, typeof(string))
  5361. )
  5362. );
  5363. }
  5364. #else
  5365. /// <summary>
  5366. /// Converts an instance .NET event, conforming to the standard .NET event pattern with an <see cref="T:System.EventArgs" /> parameter, to an observable sequence.
  5367. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5368. /// Reflection is used to discover the event based on the target object type and the specified event name.
  5369. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5370. /// </summary>
  5371. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5372. /// <param name="target">Object instance that exposes the event to convert.</param>
  5373. /// <param name="eventName">Name of the event to convert.</param>
  5374. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5375. /// <exception cref="T:System.ArgumentNullException">
  5376. /// <paramref name="target" /> or <paramref name="eventName" /> is null.</exception>
  5377. /// <exception cref="T:System.InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5378. /// <remarks>
  5379. /// <para>
  5380. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5381. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5382. /// </para>
  5383. /// <para>
  5384. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  5385. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5386. /// </para>
  5387. /// <para>
  5388. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5389. /// making the Subscribe or Dispose call, respectively.
  5390. /// </para>
  5391. /// <para>
  5392. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5393. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5394. /// more concise and easier to understand.
  5395. /// </para>
  5396. /// </remarks>
  5397. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5398. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, object target, string eventName)
  5399. {
  5400. if (provider == null)
  5401. throw new ArgumentNullException("provider");
  5402. if (target == null)
  5403. throw new ArgumentNullException("target");
  5404. if (eventName == null)
  5405. throw new ArgumentNullException("eventName");
  5406. return provider.CreateQuery<EventPattern<object>>(
  5407. Expression.Call(
  5408. null,
  5409. #if CRIPPLED_REFLECTION
  5410. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(object), default(string))),
  5411. #else
  5412. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5413. #endif
  5414. Expression.Constant(provider, typeof(IQbservableProvider)),
  5415. Expression.Constant(target, typeof(object)),
  5416. Expression.Constant(eventName, typeof(string))
  5417. )
  5418. );
  5419. }
  5420. #endif
  5421. #if !NO_EVENTARGS_CONSTRAINT
  5422. /// <summary>
  5423. /// Converts an instance .NET event, conforming to the standard .NET event pattern with an <see cref="T:System.EventArgs" /> parameter, to an observable sequence.
  5424. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5425. /// Reflection is used to discover the event based on the target object type and the specified event name.
  5426. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5427. /// </summary>
  5428. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5429. /// <param name="target">Object instance that exposes the event to convert.</param>
  5430. /// <param name="eventName">Name of the event to convert.</param>
  5431. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5432. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5433. /// <exception cref="T:System.ArgumentNullException">
  5434. /// <paramref name="target" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  5435. /// <exception cref="T:System.InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5436. /// <remarks>
  5437. /// <para>
  5438. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5439. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5440. /// </para>
  5441. /// <para>
  5442. /// 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
  5443. /// accessed from the same context, as required by some UI frameworks.
  5444. /// </para>
  5445. /// <para>
  5446. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5447. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5448. /// parameter. For more information, see the remarks section on those overloads.
  5449. /// </para>
  5450. /// </remarks>
  5451. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5452. public static IQbservable<EventPattern<EventArgs>> FromEventPattern(this IQbservableProvider provider, object target, string eventName, IScheduler scheduler)
  5453. {
  5454. if (provider == null)
  5455. throw new ArgumentNullException("provider");
  5456. if (target == null)
  5457. throw new ArgumentNullException("target");
  5458. if (eventName == null)
  5459. throw new ArgumentNullException("eventName");
  5460. if (scheduler == null)
  5461. throw new ArgumentNullException("scheduler");
  5462. return provider.CreateQuery<EventPattern<EventArgs>>(
  5463. Expression.Call(
  5464. null,
  5465. #if CRIPPLED_REFLECTION
  5466. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(object), default(string), default(IScheduler))),
  5467. #else
  5468. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5469. #endif
  5470. Expression.Constant(provider, typeof(IQbservableProvider)),
  5471. Expression.Constant(target, typeof(object)),
  5472. Expression.Constant(eventName, typeof(string)),
  5473. Expression.Constant(scheduler, typeof(IScheduler))
  5474. )
  5475. );
  5476. }
  5477. #else
  5478. /// <summary>
  5479. /// Converts an instance .NET event, conforming to the standard .NET event pattern with an <see cref="T:System.EventArgs" /> parameter, to an observable sequence.
  5480. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5481. /// Reflection is used to discover the event based on the target object type and the specified event name.
  5482. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5483. /// </summary>
  5484. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5485. /// <param name="target">Object instance that exposes the event to convert.</param>
  5486. /// <param name="eventName">Name of the event to convert.</param>
  5487. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5488. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5489. /// <exception cref="T:System.ArgumentNullException">
  5490. /// <paramref name="target" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  5491. /// <exception cref="T:System.InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5492. /// <remarks>
  5493. /// <para>
  5494. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5495. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5496. /// </para>
  5497. /// <para>
  5498. /// 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
  5499. /// accessed from the same context, as required by some UI frameworks.
  5500. /// </para>
  5501. /// <para>
  5502. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5503. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5504. /// parameter. For more information, see the remarks section on those overloads.
  5505. /// </para>
  5506. /// </remarks>
  5507. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5508. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, object target, string eventName, IScheduler scheduler)
  5509. {
  5510. if (provider == null)
  5511. throw new ArgumentNullException("provider");
  5512. if (target == null)
  5513. throw new ArgumentNullException("target");
  5514. if (eventName == null)
  5515. throw new ArgumentNullException("eventName");
  5516. if (scheduler == null)
  5517. throw new ArgumentNullException("scheduler");
  5518. return provider.CreateQuery<EventPattern<object>>(
  5519. Expression.Call(
  5520. null,
  5521. #if CRIPPLED_REFLECTION
  5522. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(object), default(string), default(IScheduler))),
  5523. #else
  5524. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5525. #endif
  5526. Expression.Constant(provider, typeof(IQbservableProvider)),
  5527. Expression.Constant(target, typeof(object)),
  5528. Expression.Constant(eventName, typeof(string)),
  5529. Expression.Constant(scheduler, typeof(IScheduler))
  5530. )
  5531. );
  5532. }
  5533. #endif
  5534. #if !NO_EVENTARGS_CONSTRAINT
  5535. /// <summary>
  5536. /// Converts a static .NET event, conforming to the standard .NET event pattern with an <see cref="T:System.EventArgs" /> parameter, to an observable sequence.
  5537. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5538. /// Reflection is used to discover the event based on the specified type and the specified event name.
  5539. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5540. /// </summary>
  5541. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5542. /// <param name="type">Type that exposes the static event to convert.</param>
  5543. /// <param name="eventName">Name of the event to convert.</param>
  5544. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5545. /// <exception cref="T:System.ArgumentNullException">
  5546. /// <paramref name="type" /> or <paramref name="eventName" /> is null.</exception>
  5547. /// <exception cref="T:System.InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5548. /// <remarks>
  5549. /// <para>
  5550. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5551. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5552. /// </para>
  5553. /// <para>
  5554. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  5555. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5556. /// </para>
  5557. /// <para>
  5558. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5559. /// making the Subscribe or Dispose call, respectively.
  5560. /// </para>
  5561. /// <para>
  5562. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5563. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5564. /// more concise and easier to understand.
  5565. /// </para>
  5566. /// </remarks>
  5567. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5568. public static IQbservable<EventPattern<EventArgs>> FromEventPattern(this IQbservableProvider provider, Type type, string eventName)
  5569. {
  5570. if (provider == null)
  5571. throw new ArgumentNullException("provider");
  5572. if (type == null)
  5573. throw new ArgumentNullException("type");
  5574. if (eventName == null)
  5575. throw new ArgumentNullException("eventName");
  5576. return provider.CreateQuery<EventPattern<EventArgs>>(
  5577. Expression.Call(
  5578. null,
  5579. #if CRIPPLED_REFLECTION
  5580. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Type), default(string))),
  5581. #else
  5582. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5583. #endif
  5584. Expression.Constant(provider, typeof(IQbservableProvider)),
  5585. Expression.Constant(type, typeof(Type)),
  5586. Expression.Constant(eventName, typeof(string))
  5587. )
  5588. );
  5589. }
  5590. #else
  5591. /// <summary>
  5592. /// Converts a static .NET event, conforming to the standard .NET event pattern with an <see cref="T:System.EventArgs" /> parameter, to an observable sequence.
  5593. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5594. /// Reflection is used to discover the event based on the specified type and the specified event name.
  5595. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5596. /// </summary>
  5597. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5598. /// <param name="type">Type that exposes the static event to convert.</param>
  5599. /// <param name="eventName">Name of the event to convert.</param>
  5600. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5601. /// <exception cref="T:System.ArgumentNullException">
  5602. /// <paramref name="type" /> or <paramref name="eventName" /> is null.</exception>
  5603. /// <exception cref="T:System.InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5604. /// <remarks>
  5605. /// <para>
  5606. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5607. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5608. /// </para>
  5609. /// <para>
  5610. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  5611. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5612. /// </para>
  5613. /// <para>
  5614. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5615. /// making the Subscribe or Dispose call, respectively.
  5616. /// </para>
  5617. /// <para>
  5618. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5619. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5620. /// more concise and easier to understand.
  5621. /// </para>
  5622. /// </remarks>
  5623. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5624. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, Type type, string eventName)
  5625. {
  5626. if (provider == null)
  5627. throw new ArgumentNullException("provider");
  5628. if (type == null)
  5629. throw new ArgumentNullException("type");
  5630. if (eventName == null)
  5631. throw new ArgumentNullException("eventName");
  5632. return provider.CreateQuery<EventPattern<object>>(
  5633. Expression.Call(
  5634. null,
  5635. #if CRIPPLED_REFLECTION
  5636. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Type), default(string))),
  5637. #else
  5638. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5639. #endif
  5640. Expression.Constant(provider, typeof(IQbservableProvider)),
  5641. Expression.Constant(type, typeof(Type)),
  5642. Expression.Constant(eventName, typeof(string))
  5643. )
  5644. );
  5645. }
  5646. #endif
  5647. #if !NO_EVENTARGS_CONSTRAINT
  5648. /// <summary>
  5649. /// Converts a static .NET event, conforming to the standard .NET event pattern with an <see cref="T:System.EventArgs" /> parameter, to an observable sequence.
  5650. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5651. /// Reflection is used to discover the event based on the specified type and the specified event name.
  5652. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5653. /// </summary>
  5654. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5655. /// <param name="type">Type that exposes the static event to convert.</param>
  5656. /// <param name="eventName">Name of the event to convert.</param>
  5657. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5658. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5659. /// <exception cref="T:System.ArgumentNullException">
  5660. /// <paramref name="type" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  5661. /// <exception cref="T:System.InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5662. /// <remarks>
  5663. /// <para>
  5664. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5665. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5666. /// </para>
  5667. /// <para>
  5668. /// 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
  5669. /// accessed from the same context, as required by some UI frameworks.
  5670. /// </para>
  5671. /// <para>
  5672. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5673. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5674. /// parameter. For more information, see the remarks section on those overloads.
  5675. /// </para>
  5676. /// </remarks>
  5677. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5678. public static IQbservable<EventPattern<EventArgs>> FromEventPattern(this IQbservableProvider provider, Type type, string eventName, IScheduler scheduler)
  5679. {
  5680. if (provider == null)
  5681. throw new ArgumentNullException("provider");
  5682. if (type == null)
  5683. throw new ArgumentNullException("type");
  5684. if (eventName == null)
  5685. throw new ArgumentNullException("eventName");
  5686. if (scheduler == null)
  5687. throw new ArgumentNullException("scheduler");
  5688. return provider.CreateQuery<EventPattern<EventArgs>>(
  5689. Expression.Call(
  5690. null,
  5691. #if CRIPPLED_REFLECTION
  5692. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Type), default(string), default(IScheduler))),
  5693. #else
  5694. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5695. #endif
  5696. Expression.Constant(provider, typeof(IQbservableProvider)),
  5697. Expression.Constant(type, typeof(Type)),
  5698. Expression.Constant(eventName, typeof(string)),
  5699. Expression.Constant(scheduler, typeof(IScheduler))
  5700. )
  5701. );
  5702. }
  5703. #else
  5704. /// <summary>
  5705. /// Converts a static .NET event, conforming to the standard .NET event pattern with an <see cref="T:System.EventArgs" /> parameter, to an observable sequence.
  5706. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5707. /// Reflection is used to discover the event based on the specified type and the specified event name.
  5708. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5709. /// </summary>
  5710. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5711. /// <param name="type">Type that exposes the static event to convert.</param>
  5712. /// <param name="eventName">Name of the event to convert.</param>
  5713. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5714. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5715. /// <exception cref="T:System.ArgumentNullException">
  5716. /// <paramref name="type" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  5717. /// <exception cref="T:System.InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5718. /// <remarks>
  5719. /// <para>
  5720. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5721. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5722. /// </para>
  5723. /// <para>
  5724. /// 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
  5725. /// accessed from the same context, as required by some UI frameworks.
  5726. /// </para>
  5727. /// <para>
  5728. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5729. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5730. /// parameter. For more information, see the remarks section on those overloads.
  5731. /// </para>
  5732. /// </remarks>
  5733. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5734. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, Type type, string eventName, IScheduler scheduler)
  5735. {
  5736. if (provider == null)
  5737. throw new ArgumentNullException("provider");
  5738. if (type == null)
  5739. throw new ArgumentNullException("type");
  5740. if (eventName == null)
  5741. throw new ArgumentNullException("eventName");
  5742. if (scheduler == null)
  5743. throw new ArgumentNullException("scheduler");
  5744. return provider.CreateQuery<EventPattern<object>>(
  5745. Expression.Call(
  5746. null,
  5747. #if CRIPPLED_REFLECTION
  5748. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Type), default(string), default(IScheduler))),
  5749. #else
  5750. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5751. #endif
  5752. Expression.Constant(provider, typeof(IQbservableProvider)),
  5753. Expression.Constant(type, typeof(Type)),
  5754. Expression.Constant(eventName, typeof(string)),
  5755. Expression.Constant(scheduler, typeof(IScheduler))
  5756. )
  5757. );
  5758. }
  5759. #endif
  5760. /// <summary>
  5761. /// Converts a .NET event, conforming to the standard .NET event pattern based on a supplied event delegate type, to an observable sequence.
  5762. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5763. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5764. /// </summary>
  5765. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5766. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5767. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5768. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5769. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5770. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5771. /// <exception cref="T:System.ArgumentNullException">
  5772. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  5773. /// <remarks>
  5774. /// <para>
  5775. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5776. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5777. /// </para>
  5778. /// <para>
  5779. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  5780. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5781. /// </para>
  5782. /// <para>
  5783. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5784. /// making the Subscribe or Dispose call, respectively.
  5785. /// </para>
  5786. /// <para>
  5787. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5788. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5789. /// more concise and easier to understand.
  5790. /// </para>
  5791. /// </remarks>
  5792. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5793. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)
  5794. #if !NO_EVENTARGS_CONSTRAINT
  5795. where TEventArgs : EventArgs
  5796. #endif
  5797. {
  5798. if (provider == null)
  5799. throw new ArgumentNullException("provider");
  5800. if (addHandler == null)
  5801. throw new ArgumentNullException("addHandler");
  5802. if (removeHandler == null)
  5803. throw new ArgumentNullException("removeHandler");
  5804. return provider.CreateQuery<EventPattern<TEventArgs>>(
  5805. Expression.Call(
  5806. null,
  5807. #if CRIPPLED_REFLECTION
  5808. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>))),
  5809. #else
  5810. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  5811. #endif
  5812. Expression.Constant(provider, typeof(IQbservableProvider)),
  5813. addHandler,
  5814. removeHandler
  5815. )
  5816. );
  5817. }
  5818. /// <summary>
  5819. /// Converts a .NET event, conforming to the standard .NET event pattern based on a supplied event delegate type, to an observable sequence.
  5820. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5821. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5822. /// </summary>
  5823. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5824. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5825. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5826. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5827. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5828. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5829. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5830. /// <exception cref="T:System.ArgumentNullException">
  5831. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5832. /// <remarks>
  5833. /// <para>
  5834. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5835. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5836. /// </para>
  5837. /// <para>
  5838. /// 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
  5839. /// accessed from the same context, as required by some UI frameworks.
  5840. /// </para>
  5841. /// <para>
  5842. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5843. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5844. /// parameter. For more information, see the remarks section on those overloads.
  5845. /// </para>
  5846. /// </remarks>
  5847. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5848. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler, IScheduler scheduler)
  5849. #if !NO_EVENTARGS_CONSTRAINT
  5850. where TEventArgs : EventArgs
  5851. #endif
  5852. {
  5853. if (provider == null)
  5854. throw new ArgumentNullException("provider");
  5855. if (addHandler == null)
  5856. throw new ArgumentNullException("addHandler");
  5857. if (removeHandler == null)
  5858. throw new ArgumentNullException("removeHandler");
  5859. if (scheduler == null)
  5860. throw new ArgumentNullException("scheduler");
  5861. return provider.CreateQuery<EventPattern<TEventArgs>>(
  5862. Expression.Call(
  5863. null,
  5864. #if CRIPPLED_REFLECTION
  5865. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>), default(IScheduler))),
  5866. #else
  5867. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  5868. #endif
  5869. Expression.Constant(provider, typeof(IQbservableProvider)),
  5870. addHandler,
  5871. removeHandler,
  5872. Expression.Constant(scheduler, typeof(IScheduler))
  5873. )
  5874. );
  5875. }
  5876. /// <summary>
  5877. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="T:System.EventHandler`1" />, to an observable sequence.
  5878. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5879. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5880. /// </summary>
  5881. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5882. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5883. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5884. /// <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>
  5885. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5886. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5887. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5888. /// <exception cref="T:System.ArgumentNullException">
  5889. /// <paramref name="conversion" /> or <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  5890. /// <remarks>
  5891. /// <para>
  5892. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5893. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5894. /// </para>
  5895. /// <para>
  5896. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  5897. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5898. /// </para>
  5899. /// <para>
  5900. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5901. /// making the Subscribe or Dispose call, respectively.
  5902. /// </para>
  5903. /// <para>
  5904. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5905. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5906. /// more concise and easier to understand.
  5907. /// </para>
  5908. /// </remarks>
  5909. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5910. 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)
  5911. #if !NO_EVENTARGS_CONSTRAINT
  5912. where TEventArgs : EventArgs
  5913. #endif
  5914. {
  5915. if (provider == null)
  5916. throw new ArgumentNullException("provider");
  5917. if (conversion == null)
  5918. throw new ArgumentNullException("conversion");
  5919. if (addHandler == null)
  5920. throw new ArgumentNullException("addHandler");
  5921. if (removeHandler == null)
  5922. throw new ArgumentNullException("removeHandler");
  5923. return provider.CreateQuery<EventPattern<TEventArgs>>(
  5924. Expression.Call(
  5925. null,
  5926. #if CRIPPLED_REFLECTION
  5927. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Func<EventHandler<TEventArgs>, TDelegate>>), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>))),
  5928. #else
  5929. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  5930. #endif
  5931. Expression.Constant(provider, typeof(IQbservableProvider)),
  5932. conversion,
  5933. addHandler,
  5934. removeHandler
  5935. )
  5936. );
  5937. }
  5938. /// <summary>
  5939. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="T:System.EventHandler`1" />, to an observable sequence.
  5940. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5941. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5942. /// </summary>
  5943. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5944. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5945. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5946. /// <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>
  5947. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5948. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5949. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5950. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5951. /// <exception cref="T:System.ArgumentNullException">
  5952. /// <paramref name="conversion" /> or <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</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. /// 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
  5960. /// accessed from the same context, as required by some UI frameworks.
  5961. /// </para>
  5962. /// <para>
  5963. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5964. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5965. /// parameter. For more information, see the remarks section on those overloads.
  5966. /// </para>
  5967. /// </remarks>
  5968. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5969. 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)
  5970. #if !NO_EVENTARGS_CONSTRAINT
  5971. where TEventArgs : EventArgs
  5972. #endif
  5973. {
  5974. if (provider == null)
  5975. throw new ArgumentNullException("provider");
  5976. if (conversion == null)
  5977. throw new ArgumentNullException("conversion");
  5978. if (addHandler == null)
  5979. throw new ArgumentNullException("addHandler");
  5980. if (removeHandler == null)
  5981. throw new ArgumentNullException("removeHandler");
  5982. if (scheduler == null)
  5983. throw new ArgumentNullException("scheduler");
  5984. return provider.CreateQuery<EventPattern<TEventArgs>>(
  5985. Expression.Call(
  5986. null,
  5987. #if CRIPPLED_REFLECTION
  5988. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Func<EventHandler<TEventArgs>, TDelegate>>), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>), default(IScheduler))),
  5989. #else
  5990. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  5991. #endif
  5992. Expression.Constant(provider, typeof(IQbservableProvider)),
  5993. conversion,
  5994. addHandler,
  5995. removeHandler,
  5996. Expression.Constant(scheduler, typeof(IScheduler))
  5997. )
  5998. );
  5999. }
  6000. /// <summary>
  6001. /// 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.
  6002. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6003. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6004. /// </summary>
  6005. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6006. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  6007. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  6008. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6009. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  6010. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  6011. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6012. /// <exception cref="T:System.ArgumentNullException">
  6013. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  6014. /// <remarks>
  6015. /// <para>
  6016. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6017. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6018. /// </para>
  6019. /// <para>
  6020. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  6021. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  6022. /// </para>
  6023. /// <para>
  6024. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  6025. /// making the Subscribe or Dispose call, respectively.
  6026. /// </para>
  6027. /// <para>
  6028. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  6029. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  6030. /// more concise and easier to understand.
  6031. /// </para>
  6032. /// </remarks>
  6033. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6034. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TDelegate, TSender, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)
  6035. #if !NO_EVENTARGS_CONSTRAINT
  6036. where TEventArgs : EventArgs
  6037. #endif
  6038. {
  6039. if (provider == null)
  6040. throw new ArgumentNullException("provider");
  6041. if (addHandler == null)
  6042. throw new ArgumentNullException("addHandler");
  6043. if (removeHandler == null)
  6044. throw new ArgumentNullException("removeHandler");
  6045. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  6046. Expression.Call(
  6047. null,
  6048. #if CRIPPLED_REFLECTION
  6049. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TSender, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>))),
  6050. #else
  6051. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TSender), typeof(TEventArgs)),
  6052. #endif
  6053. Expression.Constant(provider, typeof(IQbservableProvider)),
  6054. addHandler,
  6055. removeHandler
  6056. )
  6057. );
  6058. }
  6059. /// <summary>
  6060. /// 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.
  6061. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6062. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6063. /// </summary>
  6064. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6065. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  6066. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  6067. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6068. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  6069. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  6070. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  6071. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6072. /// <exception cref="T:System.ArgumentNullException">
  6073. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  6074. /// <remarks>
  6075. /// <para>
  6076. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6077. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6078. /// </para>
  6079. /// <para>
  6080. /// 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
  6081. /// accessed from the same context, as required by some UI frameworks.
  6082. /// </para>
  6083. /// <para>
  6084. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  6085. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  6086. /// parameter. For more information, see the remarks section on those overloads.
  6087. /// </para>
  6088. /// </remarks>
  6089. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6090. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TDelegate, TSender, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler, IScheduler scheduler)
  6091. #if !NO_EVENTARGS_CONSTRAINT
  6092. where TEventArgs : EventArgs
  6093. #endif
  6094. {
  6095. if (provider == null)
  6096. throw new ArgumentNullException("provider");
  6097. if (addHandler == null)
  6098. throw new ArgumentNullException("addHandler");
  6099. if (removeHandler == null)
  6100. throw new ArgumentNullException("removeHandler");
  6101. if (scheduler == null)
  6102. throw new ArgumentNullException("scheduler");
  6103. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  6104. Expression.Call(
  6105. null,
  6106. #if CRIPPLED_REFLECTION
  6107. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TSender, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>), default(IScheduler))),
  6108. #else
  6109. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TSender), typeof(TEventArgs)),
  6110. #endif
  6111. Expression.Constant(provider, typeof(IQbservableProvider)),
  6112. addHandler,
  6113. removeHandler,
  6114. Expression.Constant(scheduler, typeof(IScheduler))
  6115. )
  6116. );
  6117. }
  6118. /// <summary>
  6119. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="T:System.EventHandler`1" />, to an observable sequence.
  6120. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6121. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6122. /// </summary>
  6123. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6124. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6125. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  6126. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  6127. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6128. /// <remarks>
  6129. /// <para>
  6130. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6131. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6132. /// </para>
  6133. /// <para>
  6134. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  6135. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  6136. /// </para>
  6137. /// <para>
  6138. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  6139. /// making the Subscribe or Dispose call, respectively.
  6140. /// </para>
  6141. /// <para>
  6142. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  6143. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  6144. /// more concise and easier to understand.
  6145. /// </para>
  6146. /// </remarks>
  6147. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6148. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, Expression<Action<EventHandler<TEventArgs>>> addHandler, Expression<Action<EventHandler<TEventArgs>>> removeHandler)
  6149. #if !NO_EVENTARGS_CONSTRAINT
  6150. where TEventArgs : EventArgs
  6151. #endif
  6152. {
  6153. if (provider == null)
  6154. throw new ArgumentNullException("provider");
  6155. if (addHandler == null)
  6156. throw new ArgumentNullException("addHandler");
  6157. if (removeHandler == null)
  6158. throw new ArgumentNullException("removeHandler");
  6159. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6160. Expression.Call(
  6161. null,
  6162. #if CRIPPLED_REFLECTION
  6163. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(Expression<Action<EventHandler<TEventArgs>>>), default(Expression<Action<EventHandler<TEventArgs>>>))),
  6164. #else
  6165. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  6166. #endif
  6167. Expression.Constant(provider, typeof(IQbservableProvider)),
  6168. addHandler,
  6169. removeHandler
  6170. )
  6171. );
  6172. }
  6173. /// <summary>
  6174. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="T:System.EventHandler`1" />, to an observable sequence.
  6175. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6176. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6177. /// </summary>
  6178. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6179. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6180. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  6181. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  6182. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  6183. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6184. /// <remarks>
  6185. /// <para>
  6186. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6187. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6188. /// </para>
  6189. /// <para>
  6190. /// 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
  6191. /// accessed from the same context, as required by some UI frameworks.
  6192. /// </para>
  6193. /// <para>
  6194. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  6195. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  6196. /// parameter. For more information, see the remarks section on those overloads.
  6197. /// </para>
  6198. /// </remarks>
  6199. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6200. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, Expression<Action<EventHandler<TEventArgs>>> addHandler, Expression<Action<EventHandler<TEventArgs>>> removeHandler, IScheduler scheduler)
  6201. #if !NO_EVENTARGS_CONSTRAINT
  6202. where TEventArgs : EventArgs
  6203. #endif
  6204. {
  6205. if (provider == null)
  6206. throw new ArgumentNullException("provider");
  6207. if (addHandler == null)
  6208. throw new ArgumentNullException("addHandler");
  6209. if (removeHandler == null)
  6210. throw new ArgumentNullException("removeHandler");
  6211. if (scheduler == null)
  6212. throw new ArgumentNullException("scheduler");
  6213. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6214. Expression.Call(
  6215. null,
  6216. #if CRIPPLED_REFLECTION
  6217. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(Expression<Action<EventHandler<TEventArgs>>>), default(Expression<Action<EventHandler<TEventArgs>>>), default(IScheduler))),
  6218. #else
  6219. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  6220. #endif
  6221. Expression.Constant(provider, typeof(IQbservableProvider)),
  6222. addHandler,
  6223. removeHandler,
  6224. Expression.Constant(scheduler, typeof(IScheduler))
  6225. )
  6226. );
  6227. }
  6228. /// <summary>
  6229. /// Converts an instance .NET event, conforming to the standard .NET event pattern with strongly typed event arguments, to an observable sequence.
  6230. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6231. /// Reflection is used to discover the event based on the target object type and the specified event name.
  6232. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6233. /// </summary>
  6234. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6235. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6236. /// <param name="target">Object instance that exposes the event to convert.</param>
  6237. /// <param name="eventName">Name of the event to convert.</param>
  6238. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6239. /// <exception cref="T:System.ArgumentNullException">
  6240. /// <paramref name="target" /> or <paramref name="eventName" /> is null.</exception>
  6241. /// <exception cref="T:System.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>
  6242. /// <remarks>
  6243. /// <para>
  6244. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6245. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6246. /// </para>
  6247. /// <para>
  6248. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  6249. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  6250. /// </para>
  6251. /// <para>
  6252. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  6253. /// making the Subscribe or Dispose call, respectively.
  6254. /// </para>
  6255. /// <para>
  6256. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  6257. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  6258. /// more concise and easier to understand.
  6259. /// </para>
  6260. /// </remarks>
  6261. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6262. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, object target, string eventName)
  6263. #if !NO_EVENTARGS_CONSTRAINT
  6264. where TEventArgs : EventArgs
  6265. #endif
  6266. {
  6267. if (provider == null)
  6268. throw new ArgumentNullException("provider");
  6269. if (target == null)
  6270. throw new ArgumentNullException("target");
  6271. if (eventName == null)
  6272. throw new ArgumentNullException("eventName");
  6273. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6274. Expression.Call(
  6275. null,
  6276. #if CRIPPLED_REFLECTION
  6277. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(object), default(string))),
  6278. #else
  6279. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  6280. #endif
  6281. Expression.Constant(provider, typeof(IQbservableProvider)),
  6282. Expression.Constant(target, typeof(object)),
  6283. Expression.Constant(eventName, typeof(string))
  6284. )
  6285. );
  6286. }
  6287. /// <summary>
  6288. /// Converts an instance .NET event, conforming to the standard .NET event pattern with strongly typed event arguments, to an observable sequence.
  6289. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6290. /// Reflection is used to discover the event based on the target object type and the specified event name.
  6291. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6292. /// </summary>
  6293. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6294. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6295. /// <param name="target">Object instance that exposes the event to convert.</param>
  6296. /// <param name="eventName">Name of the event to convert.</param>
  6297. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  6298. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6299. /// <exception cref="T:System.ArgumentNullException">
  6300. /// <paramref name="target" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  6301. /// <exception cref="T:System.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>
  6302. /// <remarks>
  6303. /// <para>
  6304. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6305. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6306. /// </para>
  6307. /// <para>
  6308. /// 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
  6309. /// accessed from the same context, as required by some UI frameworks.
  6310. /// </para>
  6311. /// <para>
  6312. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  6313. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  6314. /// parameter. For more information, see the remarks section on those overloads.
  6315. /// </para>
  6316. /// </remarks>
  6317. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6318. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, object target, string eventName, IScheduler scheduler)
  6319. #if !NO_EVENTARGS_CONSTRAINT
  6320. where TEventArgs : EventArgs
  6321. #endif
  6322. {
  6323. if (provider == null)
  6324. throw new ArgumentNullException("provider");
  6325. if (target == null)
  6326. throw new ArgumentNullException("target");
  6327. if (eventName == null)
  6328. throw new ArgumentNullException("eventName");
  6329. if (scheduler == null)
  6330. throw new ArgumentNullException("scheduler");
  6331. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6332. Expression.Call(
  6333. null,
  6334. #if CRIPPLED_REFLECTION
  6335. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(object), default(string), default(IScheduler))),
  6336. #else
  6337. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  6338. #endif
  6339. Expression.Constant(provider, typeof(IQbservableProvider)),
  6340. Expression.Constant(target, typeof(object)),
  6341. Expression.Constant(eventName, typeof(string)),
  6342. Expression.Constant(scheduler, typeof(IScheduler))
  6343. )
  6344. );
  6345. }
  6346. /// <summary>
  6347. /// Converts a static .NET event, conforming to the standard .NET event pattern with strongly typed event arguments, to an observable sequence.
  6348. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6349. /// Reflection is used to discover the event based on the specified type and the specified event name.
  6350. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6351. /// </summary>
  6352. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6353. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6354. /// <param name="type">Type that exposes the static event to convert.</param>
  6355. /// <param name="eventName">Name of the event to convert.</param>
  6356. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6357. /// <exception cref="T:System.ArgumentNullException">
  6358. /// <paramref name="type" /> or <paramref name="eventName" /> is null.</exception>
  6359. /// <exception cref="T:System.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>
  6360. /// <remarks>
  6361. /// <para>
  6362. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6363. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6364. /// </para>
  6365. /// <para>
  6366. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  6367. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  6368. /// </para>
  6369. /// <para>
  6370. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  6371. /// making the Subscribe or Dispose call, respectively.
  6372. /// </para>
  6373. /// <para>
  6374. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  6375. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  6376. /// more concise and easier to understand.
  6377. /// </para>
  6378. /// </remarks>
  6379. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6380. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, Type type, string eventName)
  6381. #if !NO_EVENTARGS_CONSTRAINT
  6382. where TEventArgs : EventArgs
  6383. #endif
  6384. {
  6385. if (provider == null)
  6386. throw new ArgumentNullException("provider");
  6387. if (type == null)
  6388. throw new ArgumentNullException("type");
  6389. if (eventName == null)
  6390. throw new ArgumentNullException("eventName");
  6391. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6392. Expression.Call(
  6393. null,
  6394. #if CRIPPLED_REFLECTION
  6395. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(Type), default(string))),
  6396. #else
  6397. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  6398. #endif
  6399. Expression.Constant(provider, typeof(IQbservableProvider)),
  6400. Expression.Constant(type, typeof(Type)),
  6401. Expression.Constant(eventName, typeof(string))
  6402. )
  6403. );
  6404. }
  6405. /// <summary>
  6406. /// Converts a static .NET event, conforming to the standard .NET event pattern with strongly typed event arguments, to an observable sequence.
  6407. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6408. /// Reflection is used to discover the event based on the specified type and the specified event name.
  6409. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6410. /// </summary>
  6411. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6412. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6413. /// <param name="type">Type that exposes the static event to convert.</param>
  6414. /// <param name="eventName">Name of the event to convert.</param>
  6415. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  6416. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6417. /// <exception cref="T:System.ArgumentNullException">
  6418. /// <paramref name="type" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  6419. /// <exception cref="T:System.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>
  6420. /// <remarks>
  6421. /// <para>
  6422. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6423. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6424. /// </para>
  6425. /// <para>
  6426. /// 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
  6427. /// accessed from the same context, as required by some UI frameworks.
  6428. /// </para>
  6429. /// <para>
  6430. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  6431. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  6432. /// parameter. For more information, see the remarks section on those overloads.
  6433. /// </para>
  6434. /// </remarks>
  6435. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6436. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, Type type, string eventName, IScheduler scheduler)
  6437. #if !NO_EVENTARGS_CONSTRAINT
  6438. where TEventArgs : EventArgs
  6439. #endif
  6440. {
  6441. if (provider == null)
  6442. throw new ArgumentNullException("provider");
  6443. if (type == null)
  6444. throw new ArgumentNullException("type");
  6445. if (eventName == null)
  6446. throw new ArgumentNullException("eventName");
  6447. if (scheduler == null)
  6448. throw new ArgumentNullException("scheduler");
  6449. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6450. Expression.Call(
  6451. null,
  6452. #if CRIPPLED_REFLECTION
  6453. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(Type), default(string), default(IScheduler))),
  6454. #else
  6455. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  6456. #endif
  6457. Expression.Constant(provider, typeof(IQbservableProvider)),
  6458. Expression.Constant(type, typeof(Type)),
  6459. Expression.Constant(eventName, typeof(string)),
  6460. Expression.Constant(scheduler, typeof(IScheduler))
  6461. )
  6462. );
  6463. }
  6464. /// <summary>
  6465. /// 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.
  6466. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6467. /// Reflection is used to discover the event based on the target object type and the specified event name.
  6468. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6469. /// </summary>
  6470. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6471. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  6472. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6473. /// <param name="target">Object instance that exposes the event to convert.</param>
  6474. /// <param name="eventName">Name of the event to convert.</param>
  6475. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6476. /// <exception cref="T:System.ArgumentNullException">
  6477. /// <paramref name="target" /> or <paramref name="eventName" /> is null.</exception>
  6478. /// <exception cref="T:System.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>
  6479. /// <remarks>
  6480. /// <para>
  6481. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6482. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6483. /// </para>
  6484. /// <para>
  6485. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  6486. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  6487. /// </para>
  6488. /// <para>
  6489. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  6490. /// making the Subscribe or Dispose call, respectively.
  6491. /// </para>
  6492. /// <para>
  6493. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  6494. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  6495. /// more concise and easier to understand.
  6496. /// </para>
  6497. /// </remarks>
  6498. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6499. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(this IQbservableProvider provider, object target, string eventName)
  6500. #if !NO_EVENTARGS_CONSTRAINT
  6501. where TEventArgs : EventArgs
  6502. #endif
  6503. {
  6504. if (provider == null)
  6505. throw new ArgumentNullException("provider");
  6506. if (target == null)
  6507. throw new ArgumentNullException("target");
  6508. if (eventName == null)
  6509. throw new ArgumentNullException("eventName");
  6510. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  6511. Expression.Call(
  6512. null,
  6513. #if CRIPPLED_REFLECTION
  6514. InfoOf(() => Qbservable.FromEventPattern<TSender, TEventArgs>(default(IQbservableProvider), default(object), default(string))),
  6515. #else
  6516. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSender), typeof(TEventArgs)),
  6517. #endif
  6518. Expression.Constant(provider, typeof(IQbservableProvider)),
  6519. Expression.Constant(target, typeof(object)),
  6520. Expression.Constant(eventName, typeof(string))
  6521. )
  6522. );
  6523. }
  6524. /// <summary>
  6525. /// 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.
  6526. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6527. /// Reflection is used to discover the event based on the target object type and the specified event name.
  6528. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6529. /// </summary>
  6530. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6531. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  6532. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6533. /// <param name="target">Object instance that exposes the event to convert.</param>
  6534. /// <param name="eventName">Name of the event to convert.</param>
  6535. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  6536. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6537. /// <exception cref="T:System.ArgumentNullException">
  6538. /// <paramref name="target" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  6539. /// <exception cref="T:System.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>
  6540. /// <remarks>
  6541. /// <para>
  6542. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6543. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6544. /// </para>
  6545. /// <para>
  6546. /// 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
  6547. /// accessed from the same context, as required by some UI frameworks.
  6548. /// </para>
  6549. /// <para>
  6550. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  6551. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  6552. /// parameter. For more information, see the remarks section on those overloads.
  6553. /// </para>
  6554. /// </remarks>
  6555. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6556. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(this IQbservableProvider provider, object target, string eventName, IScheduler scheduler)
  6557. #if !NO_EVENTARGS_CONSTRAINT
  6558. where TEventArgs : EventArgs
  6559. #endif
  6560. {
  6561. if (provider == null)
  6562. throw new ArgumentNullException("provider");
  6563. if (target == null)
  6564. throw new ArgumentNullException("target");
  6565. if (eventName == null)
  6566. throw new ArgumentNullException("eventName");
  6567. if (scheduler == null)
  6568. throw new ArgumentNullException("scheduler");
  6569. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  6570. Expression.Call(
  6571. null,
  6572. #if CRIPPLED_REFLECTION
  6573. InfoOf(() => Qbservable.FromEventPattern<TSender, TEventArgs>(default(IQbservableProvider), default(object), default(string), default(IScheduler))),
  6574. #else
  6575. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSender), typeof(TEventArgs)),
  6576. #endif
  6577. Expression.Constant(provider, typeof(IQbservableProvider)),
  6578. Expression.Constant(target, typeof(object)),
  6579. Expression.Constant(eventName, typeof(string)),
  6580. Expression.Constant(scheduler, typeof(IScheduler))
  6581. )
  6582. );
  6583. }
  6584. /// <summary>
  6585. /// 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.
  6586. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6587. /// Reflection is used to discover the event based on the specified type and the specified event name.
  6588. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6589. /// </summary>
  6590. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6591. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  6592. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6593. /// <param name="type">Type that exposes the static event to convert.</param>
  6594. /// <param name="eventName">Name of the event to convert.</param>
  6595. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6596. /// <exception cref="T:System.ArgumentNullException">
  6597. /// <paramref name="type" /> or <paramref name="eventName" /> is null.</exception>
  6598. /// <exception cref="T:System.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>
  6599. /// <remarks>
  6600. /// <para>
  6601. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6602. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6603. /// </para>
  6604. /// <para>
  6605. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  6606. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  6607. /// </para>
  6608. /// <para>
  6609. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  6610. /// making the Subscribe or Dispose call, respectively.
  6611. /// </para>
  6612. /// <para>
  6613. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  6614. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  6615. /// more concise and easier to understand.
  6616. /// </para>
  6617. /// </remarks>
  6618. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6619. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(this IQbservableProvider provider, Type type, string eventName)
  6620. #if !NO_EVENTARGS_CONSTRAINT
  6621. where TEventArgs : EventArgs
  6622. #endif
  6623. {
  6624. if (provider == null)
  6625. throw new ArgumentNullException("provider");
  6626. if (type == null)
  6627. throw new ArgumentNullException("type");
  6628. if (eventName == null)
  6629. throw new ArgumentNullException("eventName");
  6630. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  6631. Expression.Call(
  6632. null,
  6633. #if CRIPPLED_REFLECTION
  6634. InfoOf(() => Qbservable.FromEventPattern<TSender, TEventArgs>(default(IQbservableProvider), default(Type), default(string))),
  6635. #else
  6636. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSender), typeof(TEventArgs)),
  6637. #endif
  6638. Expression.Constant(provider, typeof(IQbservableProvider)),
  6639. Expression.Constant(type, typeof(Type)),
  6640. Expression.Constant(eventName, typeof(string))
  6641. )
  6642. );
  6643. }
  6644. /// <summary>
  6645. /// 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.
  6646. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6647. /// Reflection is used to discover the event based on the specified type and the specified event name.
  6648. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6649. /// </summary>
  6650. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6651. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  6652. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6653. /// <param name="type">Type that exposes the static event to convert.</param>
  6654. /// <param name="eventName">Name of the event to convert.</param>
  6655. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  6656. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6657. /// <exception cref="T:System.ArgumentNullException">
  6658. /// <paramref name="type" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  6659. /// <exception cref="T:System.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>
  6660. /// <remarks>
  6661. /// <para>
  6662. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6663. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6664. /// </para>
  6665. /// <para>
  6666. /// 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
  6667. /// accessed from the same context, as required by some UI frameworks.
  6668. /// </para>
  6669. /// <para>
  6670. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  6671. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  6672. /// parameter. For more information, see the remarks section on those overloads.
  6673. /// </para>
  6674. /// </remarks>
  6675. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6676. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(this IQbservableProvider provider, Type type, string eventName, IScheduler scheduler)
  6677. #if !NO_EVENTARGS_CONSTRAINT
  6678. where TEventArgs : EventArgs
  6679. #endif
  6680. {
  6681. if (provider == null)
  6682. throw new ArgumentNullException("provider");
  6683. if (type == null)
  6684. throw new ArgumentNullException("type");
  6685. if (eventName == null)
  6686. throw new ArgumentNullException("eventName");
  6687. if (scheduler == null)
  6688. throw new ArgumentNullException("scheduler");
  6689. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  6690. Expression.Call(
  6691. null,
  6692. #if CRIPPLED_REFLECTION
  6693. InfoOf(() => Qbservable.FromEventPattern<TSender, TEventArgs>(default(IQbservableProvider), default(Type), default(string), default(IScheduler))),
  6694. #else
  6695. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSender), typeof(TEventArgs)),
  6696. #endif
  6697. Expression.Constant(provider, typeof(IQbservableProvider)),
  6698. Expression.Constant(type, typeof(Type)),
  6699. Expression.Constant(eventName, typeof(string)),
  6700. Expression.Constant(scheduler, typeof(IScheduler))
  6701. )
  6702. );
  6703. }
  6704. /// <summary>
  6705. /// Generates an observable sequence by running a state-driven loop producing the sequence's elements.
  6706. /// </summary>
  6707. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6708. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6709. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6710. /// <param name="initialState">Initial state.</param>
  6711. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6712. /// <param name="iterate">Iteration step function.</param>
  6713. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6714. /// <returns>The generated sequence.</returns>
  6715. /// <exception cref="T:System.ArgumentNullException">
  6716. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> is null.</exception>
  6717. 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)
  6718. {
  6719. if (provider == null)
  6720. throw new ArgumentNullException("provider");
  6721. if (condition == null)
  6722. throw new ArgumentNullException("condition");
  6723. if (iterate == null)
  6724. throw new ArgumentNullException("iterate");
  6725. if (resultSelector == null)
  6726. throw new ArgumentNullException("resultSelector");
  6727. return provider.CreateQuery<TResult>(
  6728. Expression.Call(
  6729. null,
  6730. #if CRIPPLED_REFLECTION
  6731. InfoOf(() => Qbservable.Generate<TState, TResult>(default(IQbservableProvider), default(TState), default(Expression<Func<TState, bool>>), default(Expression<Func<TState, TState>>), default(Expression<Func<TState, TResult>>))),
  6732. #else
  6733. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6734. #endif
  6735. Expression.Constant(provider, typeof(IQbservableProvider)),
  6736. Expression.Constant(initialState, typeof(TState)),
  6737. condition,
  6738. iterate,
  6739. resultSelector
  6740. )
  6741. );
  6742. }
  6743. /// <summary>
  6744. /// Generates an observable sequence by running a state-driven loop producing the sequence's elements, using the specified scheduler to send out observer messages.
  6745. /// </summary>
  6746. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6747. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6748. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6749. /// <param name="initialState">Initial state.</param>
  6750. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6751. /// <param name="iterate">Iteration step function.</param>
  6752. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6753. /// <param name="scheduler">Scheduler on which to run the generator loop.</param>
  6754. /// <returns>The generated sequence.</returns>
  6755. /// <exception cref="T:System.ArgumentNullException">
  6756. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> or <paramref name="scheduler" /> is null.</exception>
  6757. 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)
  6758. {
  6759. if (provider == null)
  6760. throw new ArgumentNullException("provider");
  6761. if (condition == null)
  6762. throw new ArgumentNullException("condition");
  6763. if (iterate == null)
  6764. throw new ArgumentNullException("iterate");
  6765. if (resultSelector == null)
  6766. throw new ArgumentNullException("resultSelector");
  6767. if (scheduler == null)
  6768. throw new ArgumentNullException("scheduler");
  6769. return provider.CreateQuery<TResult>(
  6770. Expression.Call(
  6771. null,
  6772. #if CRIPPLED_REFLECTION
  6773. 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))),
  6774. #else
  6775. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6776. #endif
  6777. Expression.Constant(provider, typeof(IQbservableProvider)),
  6778. Expression.Constant(initialState, typeof(TState)),
  6779. condition,
  6780. iterate,
  6781. resultSelector,
  6782. Expression.Constant(scheduler, typeof(IScheduler))
  6783. )
  6784. );
  6785. }
  6786. /// <summary>
  6787. /// Generates an observable sequence by running a state-driven and temporal loop producing the sequence's elements.
  6788. /// </summary>
  6789. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6790. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6791. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6792. /// <param name="initialState">Initial state.</param>
  6793. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6794. /// <param name="iterate">Iteration step function.</param>
  6795. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6796. /// <param name="timeSelector">Time selector function to control the speed of values being produced each iteration.</param>
  6797. /// <returns>The generated sequence.</returns>
  6798. /// <exception cref="T:System.ArgumentNullException">
  6799. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> or <paramref name="timeSelector" /> is null.</exception>
  6800. 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)
  6801. {
  6802. if (provider == null)
  6803. throw new ArgumentNullException("provider");
  6804. if (condition == null)
  6805. throw new ArgumentNullException("condition");
  6806. if (iterate == null)
  6807. throw new ArgumentNullException("iterate");
  6808. if (resultSelector == null)
  6809. throw new ArgumentNullException("resultSelector");
  6810. if (timeSelector == null)
  6811. throw new ArgumentNullException("timeSelector");
  6812. return provider.CreateQuery<TResult>(
  6813. Expression.Call(
  6814. null,
  6815. #if CRIPPLED_REFLECTION
  6816. 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>>))),
  6817. #else
  6818. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6819. #endif
  6820. Expression.Constant(provider, typeof(IQbservableProvider)),
  6821. Expression.Constant(initialState, typeof(TState)),
  6822. condition,
  6823. iterate,
  6824. resultSelector,
  6825. timeSelector
  6826. )
  6827. );
  6828. }
  6829. /// <summary>
  6830. /// Generates an observable sequence by running a state-driven and temporal loop producing the sequence's elements.
  6831. /// </summary>
  6832. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6833. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6834. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6835. /// <param name="initialState">Initial state.</param>
  6836. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6837. /// <param name="iterate">Iteration step function.</param>
  6838. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6839. /// <param name="timeSelector">Time selector function to control the speed of values being produced each iteration.</param>
  6840. /// <returns>The generated sequence.</returns>
  6841. /// <exception cref="T:System.ArgumentNullException">
  6842. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> or <paramref name="timeSelector" /> is null.</exception>
  6843. 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)
  6844. {
  6845. if (provider == null)
  6846. throw new ArgumentNullException("provider");
  6847. if (condition == null)
  6848. throw new ArgumentNullException("condition");
  6849. if (iterate == null)
  6850. throw new ArgumentNullException("iterate");
  6851. if (resultSelector == null)
  6852. throw new ArgumentNullException("resultSelector");
  6853. if (timeSelector == null)
  6854. throw new ArgumentNullException("timeSelector");
  6855. return provider.CreateQuery<TResult>(
  6856. Expression.Call(
  6857. null,
  6858. #if CRIPPLED_REFLECTION
  6859. 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>>))),
  6860. #else
  6861. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6862. #endif
  6863. Expression.Constant(provider, typeof(IQbservableProvider)),
  6864. Expression.Constant(initialState, typeof(TState)),
  6865. condition,
  6866. iterate,
  6867. resultSelector,
  6868. timeSelector
  6869. )
  6870. );
  6871. }
  6872. /// <summary>
  6873. /// 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.
  6874. /// </summary>
  6875. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6876. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6877. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6878. /// <param name="initialState">Initial state.</param>
  6879. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6880. /// <param name="iterate">Iteration step function.</param>
  6881. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6882. /// <param name="timeSelector">Time selector function to control the speed of values being produced each iteration.</param>
  6883. /// <param name="scheduler">Scheduler on which to run the generator loop.</param>
  6884. /// <returns>The generated sequence.</returns>
  6885. /// <exception cref="T:System.ArgumentNullException">
  6886. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> or <paramref name="timeSelector" /> or <paramref name="scheduler" /> is null.</exception>
  6887. 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)
  6888. {
  6889. if (provider == null)
  6890. throw new ArgumentNullException("provider");
  6891. if (condition == null)
  6892. throw new ArgumentNullException("condition");
  6893. if (iterate == null)
  6894. throw new ArgumentNullException("iterate");
  6895. if (resultSelector == null)
  6896. throw new ArgumentNullException("resultSelector");
  6897. if (timeSelector == null)
  6898. throw new ArgumentNullException("timeSelector");
  6899. if (scheduler == null)
  6900. throw new ArgumentNullException("scheduler");
  6901. return provider.CreateQuery<TResult>(
  6902. Expression.Call(
  6903. null,
  6904. #if CRIPPLED_REFLECTION
  6905. 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))),
  6906. #else
  6907. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6908. #endif
  6909. Expression.Constant(provider, typeof(IQbservableProvider)),
  6910. Expression.Constant(initialState, typeof(TState)),
  6911. condition,
  6912. iterate,
  6913. resultSelector,
  6914. timeSelector,
  6915. Expression.Constant(scheduler, typeof(IScheduler))
  6916. )
  6917. );
  6918. }
  6919. /// <summary>
  6920. /// 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.
  6921. /// </summary>
  6922. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6923. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6924. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6925. /// <param name="initialState">Initial state.</param>
  6926. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6927. /// <param name="iterate">Iteration step function.</param>
  6928. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6929. /// <param name="timeSelector">Time selector function to control the speed of values being produced each iteration.</param>
  6930. /// <param name="scheduler">Scheduler on which to run the generator loop.</param>
  6931. /// <returns>The generated sequence.</returns>
  6932. /// <exception cref="T:System.ArgumentNullException">
  6933. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> or <paramref name="timeSelector" /> or <paramref name="scheduler" /> is null.</exception>
  6934. 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)
  6935. {
  6936. if (provider == null)
  6937. throw new ArgumentNullException("provider");
  6938. if (condition == null)
  6939. throw new ArgumentNullException("condition");
  6940. if (iterate == null)
  6941. throw new ArgumentNullException("iterate");
  6942. if (resultSelector == null)
  6943. throw new ArgumentNullException("resultSelector");
  6944. if (timeSelector == null)
  6945. throw new ArgumentNullException("timeSelector");
  6946. if (scheduler == null)
  6947. throw new ArgumentNullException("scheduler");
  6948. return provider.CreateQuery<TResult>(
  6949. Expression.Call(
  6950. null,
  6951. #if CRIPPLED_REFLECTION
  6952. 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))),
  6953. #else
  6954. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6955. #endif
  6956. Expression.Constant(provider, typeof(IQbservableProvider)),
  6957. Expression.Constant(initialState, typeof(TState)),
  6958. condition,
  6959. iterate,
  6960. resultSelector,
  6961. timeSelector,
  6962. Expression.Constant(scheduler, typeof(IScheduler))
  6963. )
  6964. );
  6965. }
  6966. /// <summary>
  6967. /// Groups the elements of an observable sequence according to a specified key selector function.
  6968. /// </summary>
  6969. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  6970. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  6971. /// <param name="source">An observable sequence whose elements to group.</param>
  6972. /// <param name="keySelector">A function to extract the key for each element.</param>
  6973. /// <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>
  6974. /// <exception cref="T:System.ArgumentNullException">
  6975. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  6976. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  6977. {
  6978. if (source == null)
  6979. throw new ArgumentNullException("source");
  6980. if (keySelector == null)
  6981. throw new ArgumentNullException("keySelector");
  6982. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  6983. Expression.Call(
  6984. null,
  6985. #if CRIPPLED_REFLECTION
  6986. InfoOf(() => Qbservable.GroupBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  6987. #else
  6988. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  6989. #endif
  6990. source.Expression,
  6991. keySelector
  6992. )
  6993. );
  6994. }
  6995. /// <summary>
  6996. /// Groups the elements of an observable sequence according to a specified key selector function and comparer.
  6997. /// </summary>
  6998. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  6999. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7000. /// <param name="source">An observable sequence whose elements to group.</param>
  7001. /// <param name="keySelector">A function to extract the key for each element.</param>
  7002. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7003. /// <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>
  7004. /// <exception cref="T:System.ArgumentNullException">
  7005. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  7006. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  7007. {
  7008. if (source == null)
  7009. throw new ArgumentNullException("source");
  7010. if (keySelector == null)
  7011. throw new ArgumentNullException("keySelector");
  7012. if (comparer == null)
  7013. throw new ArgumentNullException("comparer");
  7014. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7015. Expression.Call(
  7016. null,
  7017. #if CRIPPLED_REFLECTION
  7018. InfoOf(() => Qbservable.GroupBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IEqualityComparer<TKey>))),
  7019. #else
  7020. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  7021. #endif
  7022. source.Expression,
  7023. keySelector,
  7024. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7025. )
  7026. );
  7027. }
  7028. /// <summary>
  7029. /// Groups the elements of an observable sequence and selects the resulting elements by using a specified function.
  7030. /// </summary>
  7031. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7032. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7033. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7034. /// <param name="source">An observable sequence whose elements to group.</param>
  7035. /// <param name="keySelector">A function to extract the key for each element.</param>
  7036. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7037. /// <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>
  7038. /// <exception cref="T:System.ArgumentNullException">
  7039. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> is null.</exception>
  7040. public static IQbservable<IGroupedObservable<TKey, TElement>> GroupBy<TSource, TKey, TElement>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector)
  7041. {
  7042. if (source == null)
  7043. throw new ArgumentNullException("source");
  7044. if (keySelector == null)
  7045. throw new ArgumentNullException("keySelector");
  7046. if (elementSelector == null)
  7047. throw new ArgumentNullException("elementSelector");
  7048. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7049. Expression.Call(
  7050. null,
  7051. #if CRIPPLED_REFLECTION
  7052. InfoOf(() => Qbservable.GroupBy<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>))),
  7053. #else
  7054. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  7055. #endif
  7056. source.Expression,
  7057. keySelector,
  7058. elementSelector
  7059. )
  7060. );
  7061. }
  7062. /// <summary>
  7063. /// 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.
  7064. /// </summary>
  7065. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7066. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7067. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7068. /// <param name="source">An observable sequence whose elements to group.</param>
  7069. /// <param name="keySelector">A function to extract the key for each element.</param>
  7070. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7071. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7072. /// <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>
  7073. /// <exception cref="T:System.ArgumentNullException">
  7074. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="comparer" /> is null.</exception>
  7075. 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)
  7076. {
  7077. if (source == null)
  7078. throw new ArgumentNullException("source");
  7079. if (keySelector == null)
  7080. throw new ArgumentNullException("keySelector");
  7081. if (elementSelector == null)
  7082. throw new ArgumentNullException("elementSelector");
  7083. if (comparer == null)
  7084. throw new ArgumentNullException("comparer");
  7085. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7086. Expression.Call(
  7087. null,
  7088. #if CRIPPLED_REFLECTION
  7089. InfoOf(() => Qbservable.GroupBy<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(IEqualityComparer<TKey>))),
  7090. #else
  7091. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  7092. #endif
  7093. source.Expression,
  7094. keySelector,
  7095. elementSelector,
  7096. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7097. )
  7098. );
  7099. }
  7100. /// <summary>
  7101. /// Groups the elements of an observable sequence according to a specified key selector function.
  7102. /// 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
  7103. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7104. /// </summary>
  7105. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7106. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7107. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7108. /// <param name="source">An observable sequence whose elements to group.</param>
  7109. /// <param name="keySelector">A function to extract the key for each element.</param>
  7110. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7111. /// <returns>
  7112. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7113. /// 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.
  7114. /// </returns>
  7115. /// <exception cref="T:System.ArgumentNullException">
  7116. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="durationSelector" /> is null.</exception>
  7117. 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)
  7118. {
  7119. if (source == null)
  7120. throw new ArgumentNullException("source");
  7121. if (keySelector == null)
  7122. throw new ArgumentNullException("keySelector");
  7123. if (durationSelector == null)
  7124. throw new ArgumentNullException("durationSelector");
  7125. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7126. Expression.Call(
  7127. null,
  7128. #if CRIPPLED_REFLECTION
  7129. InfoOf(() => Qbservable.GroupByUntil<TSource, TKey, TDuration>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<IGroupedObservable<TKey, TSource>, IObservable<TDuration>>>))),
  7130. #else
  7131. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TDuration)),
  7132. #endif
  7133. source.Expression,
  7134. keySelector,
  7135. durationSelector
  7136. )
  7137. );
  7138. }
  7139. /// <summary>
  7140. /// Groups the elements of an observable sequence according to a specified key selector function and comparer.
  7141. /// 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
  7142. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7143. /// </summary>
  7144. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7145. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7146. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7147. /// <param name="source">An observable sequence whose elements to group.</param>
  7148. /// <param name="keySelector">A function to extract the key for each element.</param>
  7149. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7150. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7151. /// <returns>
  7152. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7153. /// 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.
  7154. /// </returns>
  7155. /// <exception cref="T:System.ArgumentNullException">
  7156. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="durationSelector" /> or <paramref name="comparer" /> is null.</exception>
  7157. 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)
  7158. {
  7159. if (source == null)
  7160. throw new ArgumentNullException("source");
  7161. if (keySelector == null)
  7162. throw new ArgumentNullException("keySelector");
  7163. if (durationSelector == null)
  7164. throw new ArgumentNullException("durationSelector");
  7165. if (comparer == null)
  7166. throw new ArgumentNullException("comparer");
  7167. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7168. Expression.Call(
  7169. null,
  7170. #if CRIPPLED_REFLECTION
  7171. 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>))),
  7172. #else
  7173. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TDuration)),
  7174. #endif
  7175. source.Expression,
  7176. keySelector,
  7177. durationSelector,
  7178. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7179. )
  7180. );
  7181. }
  7182. /// <summary>
  7183. /// Groups the elements of an observable sequence according to a specified key selector function and selects the resulting elements by using a specified function.
  7184. /// 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
  7185. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7186. /// </summary>
  7187. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7188. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7189. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7190. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7191. /// <param name="source">An observable sequence whose elements to group.</param>
  7192. /// <param name="keySelector">A function to extract the key for each element.</param>
  7193. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7194. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7195. /// <returns>
  7196. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7197. /// 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.
  7198. /// </returns>
  7199. /// <exception cref="T:System.ArgumentNullException">
  7200. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="durationSelector" /> is null.</exception>
  7201. 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)
  7202. {
  7203. if (source == null)
  7204. throw new ArgumentNullException("source");
  7205. if (keySelector == null)
  7206. throw new ArgumentNullException("keySelector");
  7207. if (elementSelector == null)
  7208. throw new ArgumentNullException("elementSelector");
  7209. if (durationSelector == null)
  7210. throw new ArgumentNullException("durationSelector");
  7211. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7212. Expression.Call(
  7213. null,
  7214. #if CRIPPLED_REFLECTION
  7215. 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>>>))),
  7216. #else
  7217. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TDuration)),
  7218. #endif
  7219. source.Expression,
  7220. keySelector,
  7221. elementSelector,
  7222. durationSelector
  7223. )
  7224. );
  7225. }
  7226. /// <summary>
  7227. /// 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.
  7228. /// 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
  7229. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7230. /// </summary>
  7231. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7232. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7233. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7234. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7235. /// <param name="source">An observable sequence whose elements to group.</param>
  7236. /// <param name="keySelector">A function to extract the key for each element.</param>
  7237. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7238. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7239. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7240. /// <returns>
  7241. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7242. /// 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.
  7243. /// </returns>
  7244. /// <exception cref="T:System.ArgumentNullException">
  7245. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="durationSelector" /> or <paramref name="comparer" /> is null.</exception>
  7246. 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)
  7247. {
  7248. if (source == null)
  7249. throw new ArgumentNullException("source");
  7250. if (keySelector == null)
  7251. throw new ArgumentNullException("keySelector");
  7252. if (elementSelector == null)
  7253. throw new ArgumentNullException("elementSelector");
  7254. if (durationSelector == null)
  7255. throw new ArgumentNullException("durationSelector");
  7256. if (comparer == null)
  7257. throw new ArgumentNullException("comparer");
  7258. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7259. Expression.Call(
  7260. null,
  7261. #if CRIPPLED_REFLECTION
  7262. 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>))),
  7263. #else
  7264. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TDuration)),
  7265. #endif
  7266. source.Expression,
  7267. keySelector,
  7268. elementSelector,
  7269. durationSelector,
  7270. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7271. )
  7272. );
  7273. }
  7274. /// <summary>
  7275. /// Correlates the elements of two sequences based on overlapping durations, and groups the results.
  7276. /// </summary>
  7277. /// <typeparam name="TLeft">The type of the elements in the left source sequence.</typeparam>
  7278. /// <typeparam name="TRight">The type of the elements in the right source sequence.</typeparam>
  7279. /// <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>
  7280. /// <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>
  7281. /// <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>
  7282. /// <param name="left">The left observable sequence to join elements for.</param>
  7283. /// <param name="right">The right observable sequence to join elements for.</param>
  7284. /// <param name="leftDurationSelector">A function to select the duration of each element of the left observable sequence, used to determine overlap.</param>
  7285. /// <param name="rightDurationSelector">A function to select the duration of each element of the right observable sequence, used to determine overlap.</param>
  7286. /// <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>
  7287. /// <returns>An observable sequence that contains result elements computed from source elements that have an overlapping duration.</returns>
  7288. /// <exception cref="T:System.ArgumentNullException">
  7289. /// <paramref name="left" /> or <paramref name="right" /> or <paramref name="leftDurationSelector" /> or <paramref name="rightDurationSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  7290. 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)
  7291. {
  7292. if (left == null)
  7293. throw new ArgumentNullException("left");
  7294. if (right == null)
  7295. throw new ArgumentNullException("right");
  7296. if (leftDurationSelector == null)
  7297. throw new ArgumentNullException("leftDurationSelector");
  7298. if (rightDurationSelector == null)
  7299. throw new ArgumentNullException("rightDurationSelector");
  7300. if (resultSelector == null)
  7301. throw new ArgumentNullException("resultSelector");
  7302. return left.Provider.CreateQuery<TResult>(
  7303. Expression.Call(
  7304. null,
  7305. #if CRIPPLED_REFLECTION
  7306. 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>>))),
  7307. #else
  7308. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TLeft), typeof(TRight), typeof(TLeftDuration), typeof(TRightDuration), typeof(TResult)),
  7309. #endif
  7310. left.Expression,
  7311. GetSourceExpression(right),
  7312. leftDurationSelector,
  7313. rightDurationSelector,
  7314. resultSelector
  7315. )
  7316. );
  7317. }
  7318. /// <summary>
  7319. /// If the specified <paramref name="condition" /> evaluates true, select the <paramref name="thenSource" /> sequence. Otherwise, return an empty sequence.
  7320. /// </summary>
  7321. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  7322. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  7323. /// <param name="condition">Condition evaluated to decide which sequence to return.</param>
  7324. /// <param name="thenSource">Sequence returned in case <paramref name="condition" /> evaluates true.</param>
  7325. /// <returns>
  7326. /// <paramref name="thenSource" /> if <paramref name="condition" /> evaluates true; an empty sequence otherwise.</returns>
  7327. /// <exception cref="T:System.ArgumentNullException">
  7328. /// <paramref name="condition" /> or <paramref name="thenSource" /> is null.</exception>
  7329. public static IQbservable<TResult> If<TResult>(this IQbservableProvider provider, Expression<Func<bool>> condition, IObservable<TResult> thenSource)
  7330. {
  7331. if (provider == null)
  7332. throw new ArgumentNullException("provider");
  7333. if (condition == null)
  7334. throw new ArgumentNullException("condition");
  7335. if (thenSource == null)
  7336. throw new ArgumentNullException("thenSource");
  7337. return provider.CreateQuery<TResult>(
  7338. Expression.Call(
  7339. null,
  7340. #if CRIPPLED_REFLECTION
  7341. InfoOf(() => Qbservable.If<TResult>(default(IQbservableProvider), default(Expression<Func<bool>>), default(IObservable<TResult>))),
  7342. #else
  7343. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  7344. #endif
  7345. Expression.Constant(provider, typeof(IQbservableProvider)),
  7346. condition,
  7347. GetSourceExpression(thenSource)
  7348. )
  7349. );
  7350. }
  7351. /// <summary>
  7352. /// If the specified <paramref name="condition" /> evaluates true, select the <paramref name="thenSource" /> sequence. Otherwise, select the <paramref name="elseSource" /> sequence.
  7353. /// </summary>
  7354. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  7355. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  7356. /// <param name="condition">Condition evaluated to decide which sequence to return.</param>
  7357. /// <param name="thenSource">Sequence returned in case <paramref name="condition" /> evaluates true.</param>
  7358. /// <param name="elseSource">Sequence returned in case <paramref name="condition" /> evaluates false.</param>
  7359. /// <returns>
  7360. /// <paramref name="thenSource" /> if <paramref name="condition" /> evaluates true; <paramref name="elseSource" /> otherwise.</returns>
  7361. /// <exception cref="T:System.ArgumentNullException">
  7362. /// <paramref name="condition" /> or <paramref name="thenSource" /> or <paramref name="elseSource" /> is null.</exception>
  7363. public static IQbservable<TResult> If<TResult>(this IQbservableProvider provider, Expression<Func<bool>> condition, IObservable<TResult> thenSource, IObservable<TResult> elseSource)
  7364. {
  7365. if (provider == null)
  7366. throw new ArgumentNullException("provider");
  7367. if (condition == null)
  7368. throw new ArgumentNullException("condition");
  7369. if (thenSource == null)
  7370. throw new ArgumentNullException("thenSource");
  7371. if (elseSource == null)
  7372. throw new ArgumentNullException("elseSource");
  7373. return provider.CreateQuery<TResult>(
  7374. Expression.Call(
  7375. null,
  7376. #if CRIPPLED_REFLECTION
  7377. InfoOf(() => Qbservable.If<TResult>(default(IQbservableProvider), default(Expression<Func<bool>>), default(IObservable<TResult>), default(IObservable<TResult>))),
  7378. #else
  7379. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  7380. #endif
  7381. Expression.Constant(provider, typeof(IQbservableProvider)),
  7382. condition,
  7383. GetSourceExpression(thenSource),
  7384. GetSourceExpression(elseSource)
  7385. )
  7386. );
  7387. }
  7388. /// <summary>
  7389. /// If the specified <paramref name="condition" /> evaluates true, select the <paramref name="thenSource" /> sequence. Otherwise, return an empty sequence generated on the specified scheduler.
  7390. /// </summary>
  7391. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  7392. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  7393. /// <param name="condition">Condition evaluated to decide which sequence to return.</param>
  7394. /// <param name="thenSource">Sequence returned in case <paramref name="condition" /> evaluates true.</param>
  7395. /// <param name="scheduler">Scheduler to generate an empty sequence on in case <paramref name="condition" /> evaluates false.</param>
  7396. /// <returns>
  7397. /// <paramref name="thenSource" /> if <paramref name="condition" /> evaluates true; an empty sequence otherwise.</returns>
  7398. /// <exception cref="T:System.ArgumentNullException">
  7399. /// <paramref name="condition" /> or <paramref name="thenSource" /> or <paramref name="scheduler" /> is null.</exception>
  7400. public static IQbservable<TResult> If<TResult>(this IQbservableProvider provider, Expression<Func<bool>> condition, IObservable<TResult> thenSource, IScheduler scheduler)
  7401. {
  7402. if (provider == null)
  7403. throw new ArgumentNullException("provider");
  7404. if (condition == null)
  7405. throw new ArgumentNullException("condition");
  7406. if (thenSource == null)
  7407. throw new ArgumentNullException("thenSource");
  7408. if (scheduler == null)
  7409. throw new ArgumentNullException("scheduler");
  7410. return provider.CreateQuery<TResult>(
  7411. Expression.Call(
  7412. null,
  7413. #if CRIPPLED_REFLECTION
  7414. InfoOf(() => Qbservable.If<TResult>(default(IQbservableProvider), default(Expression<Func<bool>>), default(IObservable<TResult>), default(IScheduler))),
  7415. #else
  7416. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  7417. #endif
  7418. Expression.Constant(provider, typeof(IQbservableProvider)),
  7419. condition,
  7420. GetSourceExpression(thenSource),
  7421. Expression.Constant(scheduler, typeof(IScheduler))
  7422. )
  7423. );
  7424. }
  7425. /// <summary>
  7426. /// Ignores all elements in an observable sequence leaving only the termination messages.
  7427. /// </summary>
  7428. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7429. /// <param name="source">Source sequence.</param>
  7430. /// <returns>An empty observable sequence that signals termination, successful or exceptional, of the source sequence.</returns>
  7431. /// <exception cref="T:System.ArgumentNullException">
  7432. /// <paramref name="source" /> is null.</exception>
  7433. public static IQbservable<TSource> IgnoreElements<TSource>(this IQbservable<TSource> source)
  7434. {
  7435. if (source == null)
  7436. throw new ArgumentNullException("source");
  7437. return source.Provider.CreateQuery<TSource>(
  7438. Expression.Call(
  7439. null,
  7440. #if CRIPPLED_REFLECTION
  7441. InfoOf(() => Qbservable.IgnoreElements<TSource>(default(IQbservable<TSource>))),
  7442. #else
  7443. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7444. #endif
  7445. source.Expression
  7446. )
  7447. );
  7448. }
  7449. /// <summary>
  7450. /// Returns an observable sequence that produces a value after each period.
  7451. /// </summary>
  7452. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  7453. /// <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>
  7454. /// <returns>An observable sequence that produces a value after each period.</returns>
  7455. /// <exception cref="T:System.ArgumentOutOfRangeException">
  7456. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  7457. /// <remarks>
  7458. /// Intervals are measured between the start of subsequent notifications, not between the end of the previous and the start of the next notification.
  7459. /// If the observer takes longer than the interval period to handle the message, the subsequent notification will be delivered immediately after the
  7460. /// 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
  7461. /// <see cref="M:System.Reactive.Linq.Observable.Generate``2(``0,System.Func{``0,System.Boolean},System.Func{``0,``0},System.Func{``0,``1},System.Func{``0,System.TimeSpan})" />
  7462. /// operator instead.
  7463. /// </remarks>
  7464. public static IQbservable<long> Interval(this IQbservableProvider provider, TimeSpan period)
  7465. {
  7466. if (provider == null)
  7467. throw new ArgumentNullException("provider");
  7468. return provider.CreateQuery<long>(
  7469. Expression.Call(
  7470. null,
  7471. #if CRIPPLED_REFLECTION
  7472. InfoOf(() => Qbservable.Interval(default(IQbservableProvider), default(TimeSpan))),
  7473. #else
  7474. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7475. #endif
  7476. Expression.Constant(provider, typeof(IQbservableProvider)),
  7477. Expression.Constant(period, typeof(TimeSpan))
  7478. )
  7479. );
  7480. }
  7481. /// <summary>
  7482. /// Returns an observable sequence that produces a value after each period, using the specified scheduler to run timers and to send out observer messages.
  7483. /// </summary>
  7484. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  7485. /// <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>
  7486. /// <param name="scheduler">Scheduler to run the timer on.</param>
  7487. /// <returns>An observable sequence that produces a value after each period.</returns>
  7488. /// <exception cref="T:System.ArgumentOutOfRangeException">
  7489. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  7490. /// <exception cref="T:System.ArgumentNullException">
  7491. /// <paramref name="scheduler" /> is null.</exception>
  7492. /// <remarks>
  7493. /// Intervals are measured between the start of subsequent notifications, not between the end of the previous and the start of the next notification.
  7494. /// If the observer takes longer than the interval period to handle the message, the subsequent notification will be delivered immediately after the
  7495. /// 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
  7496. /// <see cref="M:System.Reactive.Linq.Observable.Generate``2(``0,System.Func{``0,System.Boolean},System.Func{``0,``0},System.Func{``0,``1},System.Func{``0,System.TimeSpan},System.Reactive.Concurrency.IScheduler)" />
  7497. /// operator instead.
  7498. /// </remarks>
  7499. public static IQbservable<long> Interval(this IQbservableProvider provider, TimeSpan period, IScheduler scheduler)
  7500. {
  7501. if (provider == null)
  7502. throw new ArgumentNullException("provider");
  7503. if (scheduler == null)
  7504. throw new ArgumentNullException("scheduler");
  7505. return provider.CreateQuery<long>(
  7506. Expression.Call(
  7507. null,
  7508. #if CRIPPLED_REFLECTION
  7509. InfoOf(() => Qbservable.Interval(default(IQbservableProvider), default(TimeSpan), default(IScheduler))),
  7510. #else
  7511. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7512. #endif
  7513. Expression.Constant(provider, typeof(IQbservableProvider)),
  7514. Expression.Constant(period, typeof(TimeSpan)),
  7515. Expression.Constant(scheduler, typeof(IScheduler))
  7516. )
  7517. );
  7518. }
  7519. /// <summary>
  7520. /// Determines whether an observable sequence is empty.
  7521. /// </summary>
  7522. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7523. /// <param name="source">An observable sequence to check for emptiness.</param>
  7524. /// <returns>An observable sequence containing a single element determining whether the source sequence is empty.</returns>
  7525. /// <exception cref="T:System.ArgumentNullException">
  7526. /// <paramref name="source" /> is null.</exception>
  7527. public static IQbservable<bool> IsEmpty<TSource>(this IQbservable<TSource> source)
  7528. {
  7529. if (source == null)
  7530. throw new ArgumentNullException("source");
  7531. return source.Provider.CreateQuery<bool>(
  7532. Expression.Call(
  7533. null,
  7534. #if CRIPPLED_REFLECTION
  7535. InfoOf(() => Qbservable.IsEmpty<TSource>(default(IQbservable<TSource>))),
  7536. #else
  7537. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7538. #endif
  7539. source.Expression
  7540. )
  7541. );
  7542. }
  7543. /// <summary>
  7544. /// Correlates the elements of two sequences based on overlapping durations.
  7545. /// </summary>
  7546. /// <typeparam name="TLeft">The type of the elements in the left source sequence.</typeparam>
  7547. /// <typeparam name="TRight">The type of the elements in the right source sequence.</typeparam>
  7548. /// <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>
  7549. /// <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>
  7550. /// <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>
  7551. /// <param name="left">The left observable sequence to join elements for.</param>
  7552. /// <param name="right">The right observable sequence to join elements for.</param>
  7553. /// <param name="leftDurationSelector">A function to select the duration of each element of the left observable sequence, used to determine overlap.</param>
  7554. /// <param name="rightDurationSelector">A function to select the duration of each element of the right observable sequence, used to determine overlap.</param>
  7555. /// <param name="resultSelector">A function invoked to compute a result element for any two overlapping elements of the left and right observable sequences.</param>
  7556. /// <returns>An observable sequence that contains result elements computed from source elements that have an overlapping duration.</returns>
  7557. /// <exception cref="T:System.ArgumentNullException">
  7558. /// <paramref name="left" /> or <paramref name="right" /> or <paramref name="leftDurationSelector" /> or <paramref name="rightDurationSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  7559. 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)
  7560. {
  7561. if (left == null)
  7562. throw new ArgumentNullException("left");
  7563. if (right == null)
  7564. throw new ArgumentNullException("right");
  7565. if (leftDurationSelector == null)
  7566. throw new ArgumentNullException("leftDurationSelector");
  7567. if (rightDurationSelector == null)
  7568. throw new ArgumentNullException("rightDurationSelector");
  7569. if (resultSelector == null)
  7570. throw new ArgumentNullException("resultSelector");
  7571. return left.Provider.CreateQuery<TResult>(
  7572. Expression.Call(
  7573. null,
  7574. #if CRIPPLED_REFLECTION
  7575. 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>>))),
  7576. #else
  7577. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TLeft), typeof(TRight), typeof(TLeftDuration), typeof(TRightDuration), typeof(TResult)),
  7578. #endif
  7579. left.Expression,
  7580. GetSourceExpression(right),
  7581. leftDurationSelector,
  7582. rightDurationSelector,
  7583. resultSelector
  7584. )
  7585. );
  7586. }
  7587. /// <summary>
  7588. /// Returns the last element of an observable sequence.
  7589. /// </summary>
  7590. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7591. /// <param name="source">Source observable sequence.</param>
  7592. /// <returns>Sequence containing the last element in the observable sequence.</returns>
  7593. /// <exception cref="T:System.ArgumentNullException">
  7594. /// <paramref name="source" /> is null.</exception>
  7595. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  7596. public static IQbservable<TSource> LastAsync<TSource>(this IQbservable<TSource> source)
  7597. {
  7598. if (source == null)
  7599. throw new ArgumentNullException("source");
  7600. return source.Provider.CreateQuery<TSource>(
  7601. Expression.Call(
  7602. null,
  7603. #if CRIPPLED_REFLECTION
  7604. InfoOf(() => Qbservable.LastAsync<TSource>(default(IQbservable<TSource>))),
  7605. #else
  7606. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7607. #endif
  7608. source.Expression
  7609. )
  7610. );
  7611. }
  7612. /// <summary>
  7613. /// Returns the last element of an observable sequence that satisfies the condition in the predicate.
  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. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  7618. /// <returns>Sequence containing the last element in the observable sequence that satisfies the condition in the predicate.</returns>
  7619. /// <exception cref="T:System.ArgumentNullException">
  7620. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  7621. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) No element satisfies the condition in the predicate. -or- The source sequence is empty.</exception>
  7622. public static IQbservable<TSource> LastAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  7623. {
  7624. if (source == null)
  7625. throw new ArgumentNullException("source");
  7626. if (predicate == null)
  7627. throw new ArgumentNullException("predicate");
  7628. return source.Provider.CreateQuery<TSource>(
  7629. Expression.Call(
  7630. null,
  7631. #if CRIPPLED_REFLECTION
  7632. InfoOf(() => Qbservable.LastAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  7633. #else
  7634. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7635. #endif
  7636. source.Expression,
  7637. predicate
  7638. )
  7639. );
  7640. }
  7641. /// <summary>
  7642. /// Returns the last element of an observable sequence, or a default value if no such element exists.
  7643. /// </summary>
  7644. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7645. /// <param name="source">Source observable sequence.</param>
  7646. /// <returns>Sequence containing the last element in the observable sequence, or a default value if no such element exists.</returns>
  7647. /// <exception cref="T:System.ArgumentNullException">
  7648. /// <paramref name="source" /> is null.</exception>
  7649. public static IQbservable<TSource> LastOrDefaultAsync<TSource>(this IQbservable<TSource> source)
  7650. {
  7651. if (source == null)
  7652. throw new ArgumentNullException("source");
  7653. return source.Provider.CreateQuery<TSource>(
  7654. Expression.Call(
  7655. null,
  7656. #if CRIPPLED_REFLECTION
  7657. InfoOf(() => Qbservable.LastOrDefaultAsync<TSource>(default(IQbservable<TSource>))),
  7658. #else
  7659. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7660. #endif
  7661. source.Expression
  7662. )
  7663. );
  7664. }
  7665. /// <summary>
  7666. /// Returns the last element of an observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.
  7667. /// </summary>
  7668. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7669. /// <param name="source">Source observable sequence.</param>
  7670. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  7671. /// <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>
  7672. /// <exception cref="T:System.ArgumentNullException">
  7673. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  7674. public static IQbservable<TSource> LastOrDefaultAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  7675. {
  7676. if (source == null)
  7677. throw new ArgumentNullException("source");
  7678. if (predicate == null)
  7679. throw new ArgumentNullException("predicate");
  7680. return source.Provider.CreateQuery<TSource>(
  7681. Expression.Call(
  7682. null,
  7683. #if CRIPPLED_REFLECTION
  7684. InfoOf(() => Qbservable.LastOrDefaultAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  7685. #else
  7686. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7687. #endif
  7688. source.Expression,
  7689. predicate
  7690. )
  7691. );
  7692. }
  7693. /// <summary>
  7694. /// Returns an enumerable sequence whose enumeration returns the latest observed element in the source observable sequence.
  7695. /// Enumerators on the resulting sequence will never produce the same element repeatedly, and will block until the next element becomes available.
  7696. /// </summary>
  7697. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7698. /// <param name="source">Source observable sequence.</param>
  7699. /// <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>
  7700. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  7701. public static IQueryable<TSource> Latest<TSource>(this IQbservable<TSource> source)
  7702. {
  7703. if (source == null)
  7704. throw new ArgumentNullException("source");
  7705. return ((IQueryProvider)source.Provider).CreateQuery<TSource>(
  7706. Expression.Call(
  7707. null,
  7708. #if CRIPPLED_REFLECTION
  7709. InfoOf(() => Qbservable.Latest<TSource>(default(IQbservable<TSource>))),
  7710. #else
  7711. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7712. #endif
  7713. source.Expression
  7714. )
  7715. );
  7716. }
  7717. /// <summary>
  7718. /// Returns an observable sequence containing an <see cref="T:System.Int64" /> that represents the total number of elements in an observable sequence.
  7719. /// </summary>
  7720. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7721. /// <param name="source">An observable sequence that contains elements to be counted.</param>
  7722. /// <returns>An observable sequence containing a single element with the number of elements in the input sequence.</returns>
  7723. /// <exception cref="T:System.ArgumentNullException">
  7724. /// <paramref name="source" /> is null.</exception>
  7725. /// <exception cref="T:System.OverflowException">(Asynchronous) The number of elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue" />.</exception>
  7726. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  7727. public static IQbservable<long> LongCount<TSource>(this IQbservable<TSource> source)
  7728. {
  7729. if (source == null)
  7730. throw new ArgumentNullException("source");
  7731. return source.Provider.CreateQuery<long>(
  7732. Expression.Call(
  7733. null,
  7734. #if CRIPPLED_REFLECTION
  7735. InfoOf(() => Qbservable.LongCount<TSource>(default(IQbservable<TSource>))),
  7736. #else
  7737. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7738. #endif
  7739. source.Expression
  7740. )
  7741. );
  7742. }
  7743. /// <summary>
  7744. /// Returns an observable sequence containing an <see cref="T:System.Int64" /> that represents how many elements in the specified observable sequence satisfy a condition.
  7745. /// </summary>
  7746. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7747. /// <param name="source">An observable sequence that contains elements to be counted.</param>
  7748. /// <param name="predicate">A function to test each element for a condition.</param>
  7749. /// <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>
  7750. /// <exception cref="T:System.ArgumentNullException">
  7751. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  7752. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  7753. public static IQbservable<long> LongCount<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  7754. {
  7755. if (source == null)
  7756. throw new ArgumentNullException("source");
  7757. if (predicate == null)
  7758. throw new ArgumentNullException("predicate");
  7759. return source.Provider.CreateQuery<long>(
  7760. Expression.Call(
  7761. null,
  7762. #if CRIPPLED_REFLECTION
  7763. InfoOf(() => Qbservable.LongCount<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  7764. #else
  7765. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7766. #endif
  7767. source.Expression,
  7768. predicate
  7769. )
  7770. );
  7771. }
  7772. /// <summary>
  7773. /// Materializes the implicit notifications of an observable sequence as explicit notification values.
  7774. /// </summary>
  7775. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7776. /// <param name="source">An observable sequence to get notification values for.</param>
  7777. /// <returns>An observable sequence containing the materialized notification values from the source sequence.</returns>
  7778. /// <exception cref="T:System.ArgumentNullException">
  7779. /// <paramref name="source" /> is null.</exception>
  7780. public static IQbservable<Notification<TSource>> Materialize<TSource>(this IQbservable<TSource> source)
  7781. {
  7782. if (source == null)
  7783. throw new ArgumentNullException("source");
  7784. return source.Provider.CreateQuery<Notification<TSource>>(
  7785. Expression.Call(
  7786. null,
  7787. #if CRIPPLED_REFLECTION
  7788. InfoOf(() => Qbservable.Materialize<TSource>(default(IQbservable<TSource>))),
  7789. #else
  7790. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7791. #endif
  7792. source.Expression
  7793. )
  7794. );
  7795. }
  7796. /// <summary>
  7797. /// Returns the maximum value in an observable sequence of <see cref="T:System.Decimal" /> values.
  7798. /// </summary>
  7799. /// <param name="source">A sequence of <see cref="T:System.Decimal" /> values to determine the maximum value of.</param>
  7800. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  7801. /// <exception cref="T:System.ArgumentNullException">
  7802. /// <paramref name="source" /> is null.</exception>
  7803. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  7804. public static IQbservable<decimal> Max(this IQbservable<decimal> source)
  7805. {
  7806. if (source == null)
  7807. throw new ArgumentNullException("source");
  7808. return source.Provider.CreateQuery<decimal>(
  7809. Expression.Call(
  7810. null,
  7811. #if CRIPPLED_REFLECTION
  7812. InfoOf(() => Qbservable.Max(default(IQbservable<decimal>))),
  7813. #else
  7814. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7815. #endif
  7816. source.Expression
  7817. )
  7818. );
  7819. }
  7820. /// <summary>
  7821. /// Returns the maximum value in an observable sequence of <see cref="T:System.Double" /> values.
  7822. /// </summary>
  7823. /// <param name="source">A sequence of <see cref="T:System.Double" /> values to determine the maximum value of.</param>
  7824. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  7825. /// <exception cref="T:System.ArgumentNullException">
  7826. /// <paramref name="source" /> is null.</exception>
  7827. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  7828. public static IQbservable<double> Max(this IQbservable<double> source)
  7829. {
  7830. if (source == null)
  7831. throw new ArgumentNullException("source");
  7832. return source.Provider.CreateQuery<double>(
  7833. Expression.Call(
  7834. null,
  7835. #if CRIPPLED_REFLECTION
  7836. InfoOf(() => Qbservable.Max(default(IQbservable<double>))),
  7837. #else
  7838. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7839. #endif
  7840. source.Expression
  7841. )
  7842. );
  7843. }
  7844. /// <summary>
  7845. /// Returns the maximum value in an observable sequence of <see cref="T:System.Int32" /> values.
  7846. /// </summary>
  7847. /// <param name="source">A sequence of <see cref="T:System.Int32" /> values to determine the maximum value of.</param>
  7848. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  7849. /// <exception cref="T:System.ArgumentNullException">
  7850. /// <paramref name="source" /> is null.</exception>
  7851. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  7852. public static IQbservable<int> Max(this IQbservable<int> source)
  7853. {
  7854. if (source == null)
  7855. throw new ArgumentNullException("source");
  7856. return source.Provider.CreateQuery<int>(
  7857. Expression.Call(
  7858. null,
  7859. #if CRIPPLED_REFLECTION
  7860. InfoOf(() => Qbservable.Max(default(IQbservable<int>))),
  7861. #else
  7862. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7863. #endif
  7864. source.Expression
  7865. )
  7866. );
  7867. }
  7868. /// <summary>
  7869. /// Returns the maximum value in an observable sequence of <see cref="T:System.Int64" /> values.
  7870. /// </summary>
  7871. /// <param name="source">A sequence of <see cref="T:System.Int64" /> values to determine the maximum value of.</param>
  7872. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  7873. /// <exception cref="T:System.ArgumentNullException">
  7874. /// <paramref name="source" /> is null.</exception>
  7875. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  7876. public static IQbservable<long> Max(this IQbservable<long> source)
  7877. {
  7878. if (source == null)
  7879. throw new ArgumentNullException("source");
  7880. return source.Provider.CreateQuery<long>(
  7881. Expression.Call(
  7882. null,
  7883. #if CRIPPLED_REFLECTION
  7884. InfoOf(() => Qbservable.Max(default(IQbservable<long>))),
  7885. #else
  7886. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7887. #endif
  7888. source.Expression
  7889. )
  7890. );
  7891. }
  7892. /// <summary>
  7893. /// Returns the maximum value in an observable sequence of nullable <see cref="T:System.Decimal" /> values.
  7894. /// </summary>
  7895. /// <param name="source">A sequence of nullable <see cref="T:System.Decimal" /> values to determine the maximum value of.</param>
  7896. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  7897. /// <exception cref="T:System.ArgumentNullException">
  7898. /// <paramref name="source" /> is null.</exception>
  7899. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  7900. public static IQbservable<decimal?> Max(this IQbservable<decimal?> source)
  7901. {
  7902. if (source == null)
  7903. throw new ArgumentNullException("source");
  7904. return source.Provider.CreateQuery<decimal?>(
  7905. Expression.Call(
  7906. null,
  7907. #if CRIPPLED_REFLECTION
  7908. InfoOf(() => Qbservable.Max(default(IQbservable<decimal?>))),
  7909. #else
  7910. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7911. #endif
  7912. source.Expression
  7913. )
  7914. );
  7915. }
  7916. /// <summary>
  7917. /// Returns the maximum value in an observable sequence of nullable <see cref="T:System.Double" /> values.
  7918. /// </summary>
  7919. /// <param name="source">A sequence of nullable <see cref="T:System.Double" /> values to determine the maximum value of.</param>
  7920. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  7921. /// <exception cref="T:System.ArgumentNullException">
  7922. /// <paramref name="source" /> is null.</exception>
  7923. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  7924. public static IQbservable<double?> Max(this IQbservable<double?> source)
  7925. {
  7926. if (source == null)
  7927. throw new ArgumentNullException("source");
  7928. return source.Provider.CreateQuery<double?>(
  7929. Expression.Call(
  7930. null,
  7931. #if CRIPPLED_REFLECTION
  7932. InfoOf(() => Qbservable.Max(default(IQbservable<double?>))),
  7933. #else
  7934. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7935. #endif
  7936. source.Expression
  7937. )
  7938. );
  7939. }
  7940. /// <summary>
  7941. /// Returns the maximum value in an observable sequence of nullable <see cref="T:System.Int32" /> values.
  7942. /// </summary>
  7943. /// <param name="source">A sequence of nullable <see cref="T:System.Int32" /> values to determine the maximum value of.</param>
  7944. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  7945. /// <exception cref="T:System.ArgumentNullException">
  7946. /// <paramref name="source" /> is null.</exception>
  7947. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  7948. public static IQbservable<int?> Max(this IQbservable<int?> source)
  7949. {
  7950. if (source == null)
  7951. throw new ArgumentNullException("source");
  7952. return source.Provider.CreateQuery<int?>(
  7953. Expression.Call(
  7954. null,
  7955. #if CRIPPLED_REFLECTION
  7956. InfoOf(() => Qbservable.Max(default(IQbservable<int?>))),
  7957. #else
  7958. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7959. #endif
  7960. source.Expression
  7961. )
  7962. );
  7963. }
  7964. /// <summary>
  7965. /// Returns the maximum value in an observable sequence of nullable <see cref="T:System.Int64" /> values.
  7966. /// </summary>
  7967. /// <param name="source">A sequence of nullable <see cref="T:System.Int64" /> values to determine the maximum value of.</param>
  7968. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  7969. /// <exception cref="T:System.ArgumentNullException">
  7970. /// <paramref name="source" /> is null.</exception>
  7971. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  7972. public static IQbservable<long?> Max(this IQbservable<long?> source)
  7973. {
  7974. if (source == null)
  7975. throw new ArgumentNullException("source");
  7976. return source.Provider.CreateQuery<long?>(
  7977. Expression.Call(
  7978. null,
  7979. #if CRIPPLED_REFLECTION
  7980. InfoOf(() => Qbservable.Max(default(IQbservable<long?>))),
  7981. #else
  7982. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7983. #endif
  7984. source.Expression
  7985. )
  7986. );
  7987. }
  7988. /// <summary>
  7989. /// Returns the maximum value in an observable sequence of nullable <see cref="T:System.Single" /> values.
  7990. /// </summary>
  7991. /// <param name="source">A sequence of nullable <see cref="T:System.Single" /> values to determine the maximum value of.</param>
  7992. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  7993. /// <exception cref="T:System.ArgumentNullException">
  7994. /// <paramref name="source" /> is null.</exception>
  7995. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  7996. public static IQbservable<float?> Max(this IQbservable<float?> source)
  7997. {
  7998. if (source == null)
  7999. throw new ArgumentNullException("source");
  8000. return source.Provider.CreateQuery<float?>(
  8001. Expression.Call(
  8002. null,
  8003. #if CRIPPLED_REFLECTION
  8004. InfoOf(() => Qbservable.Max(default(IQbservable<float?>))),
  8005. #else
  8006. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8007. #endif
  8008. source.Expression
  8009. )
  8010. );
  8011. }
  8012. /// <summary>
  8013. /// Returns the maximum value in an observable sequence of <see cref="T:System.Single" /> values.
  8014. /// </summary>
  8015. /// <param name="source">A sequence of <see cref="T:System.Single" /> values to determine the maximum value of.</param>
  8016. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8017. /// <exception cref="T:System.ArgumentNullException">
  8018. /// <paramref name="source" /> is null.</exception>
  8019. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8020. public static IQbservable<float> Max(this IQbservable<float> source)
  8021. {
  8022. if (source == null)
  8023. throw new ArgumentNullException("source");
  8024. return source.Provider.CreateQuery<float>(
  8025. Expression.Call(
  8026. null,
  8027. #if CRIPPLED_REFLECTION
  8028. InfoOf(() => Qbservable.Max(default(IQbservable<float>))),
  8029. #else
  8030. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8031. #endif
  8032. source.Expression
  8033. )
  8034. );
  8035. }
  8036. /// <summary>
  8037. /// Returns the maximum element in an observable sequence.
  8038. /// </summary>
  8039. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8040. /// <param name="source">An observable sequence to determine the maximum element of.</param>
  8041. /// <returns>An observable sequence containing a single element with the maximum element in the source sequence.</returns>
  8042. /// <exception cref="T:System.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<TSource> Max<TSource>(this IQbservable<TSource> source)
  8046. {
  8047. if (source == null)
  8048. throw new ArgumentNullException("source");
  8049. return source.Provider.CreateQuery<TSource>(
  8050. Expression.Call(
  8051. null,
  8052. #if CRIPPLED_REFLECTION
  8053. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>))),
  8054. #else
  8055. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8056. #endif
  8057. source.Expression
  8058. )
  8059. );
  8060. }
  8061. /// <summary>
  8062. /// Returns the maximum value in an observable sequence according to the specified comparer.
  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. /// <param name="comparer">Comparer used to compare elements.</param>
  8067. /// <returns>An observable sequence containing a single element with the maximum element in the source sequence.</returns>
  8068. /// <exception cref="T:System.ArgumentNullException">
  8069. /// <paramref name="source" /> or <paramref name="comparer" /> is null.</exception>
  8070. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8071. public static IQbservable<TSource> Max<TSource>(this IQbservable<TSource> source, IComparer<TSource> comparer)
  8072. {
  8073. if (source == null)
  8074. throw new ArgumentNullException("source");
  8075. if (comparer == null)
  8076. throw new ArgumentNullException("comparer");
  8077. return source.Provider.CreateQuery<TSource>(
  8078. Expression.Call(
  8079. null,
  8080. #if CRIPPLED_REFLECTION
  8081. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(IComparer<TSource>))),
  8082. #else
  8083. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8084. #endif
  8085. source.Expression,
  8086. Expression.Constant(comparer, typeof(IComparer<TSource>))
  8087. )
  8088. );
  8089. }
  8090. /// <summary>
  8091. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="T:System.Int32" /> value.
  8092. /// </summary>
  8093. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8094. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8095. /// <param name="selector">A transform function to apply to each element.</param>
  8096. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable&lt;System.Int32&gt;" /> that corresponds to the maximum value in the source sequence.</returns>
  8097. /// <exception cref="T:System.ArgumentNullException">
  8098. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8099. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8100. public static IQbservable<int?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int?>> selector)
  8101. {
  8102. if (source == null)
  8103. throw new ArgumentNullException("source");
  8104. if (selector == null)
  8105. throw new ArgumentNullException("selector");
  8106. return source.Provider.CreateQuery<int?>(
  8107. Expression.Call(
  8108. null,
  8109. #if CRIPPLED_REFLECTION
  8110. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int?>>))),
  8111. #else
  8112. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8113. #endif
  8114. source.Expression,
  8115. selector
  8116. )
  8117. );
  8118. }
  8119. /// <summary>
  8120. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="T:System.Int64" /> value.
  8121. /// </summary>
  8122. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8123. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8124. /// <param name="selector">A transform function to apply to each element.</param>
  8125. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable&lt;System.Int64&gt;" /> that corresponds to the maximum value in the source sequence.</returns>
  8126. /// <exception cref="T:System.ArgumentNullException">
  8127. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8128. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8129. public static IQbservable<long?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long?>> selector)
  8130. {
  8131. if (source == null)
  8132. throw new ArgumentNullException("source");
  8133. if (selector == null)
  8134. throw new ArgumentNullException("selector");
  8135. return source.Provider.CreateQuery<long?>(
  8136. Expression.Call(
  8137. null,
  8138. #if CRIPPLED_REFLECTION
  8139. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long?>>))),
  8140. #else
  8141. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8142. #endif
  8143. source.Expression,
  8144. selector
  8145. )
  8146. );
  8147. }
  8148. /// <summary>
  8149. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="T:System.Double" /> value.
  8150. /// </summary>
  8151. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8152. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8153. /// <param name="selector">A transform function to apply to each element.</param>
  8154. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Double" /> that corresponds to the maximum value in the source sequence.</returns>
  8155. /// <exception cref="T:System.ArgumentNullException">
  8156. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8157. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8158. public static IQbservable<double> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double>> selector)
  8159. {
  8160. if (source == null)
  8161. throw new ArgumentNullException("source");
  8162. if (selector == null)
  8163. throw new ArgumentNullException("selector");
  8164. return source.Provider.CreateQuery<double>(
  8165. Expression.Call(
  8166. null,
  8167. #if CRIPPLED_REFLECTION
  8168. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double>>))),
  8169. #else
  8170. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8171. #endif
  8172. source.Expression,
  8173. selector
  8174. )
  8175. );
  8176. }
  8177. /// <summary>
  8178. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="T:System.Single" /> value.
  8179. /// </summary>
  8180. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8181. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8182. /// <param name="selector">A transform function to apply to each element.</param>
  8183. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Single" /> that corresponds to the maximum value in the source sequence.</returns>
  8184. /// <exception cref="T:System.ArgumentNullException">
  8185. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8186. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8187. public static IQbservable<float> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float>> selector)
  8188. {
  8189. if (source == null)
  8190. throw new ArgumentNullException("source");
  8191. if (selector == null)
  8192. throw new ArgumentNullException("selector");
  8193. return source.Provider.CreateQuery<float>(
  8194. Expression.Call(
  8195. null,
  8196. #if CRIPPLED_REFLECTION
  8197. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float>>))),
  8198. #else
  8199. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8200. #endif
  8201. source.Expression,
  8202. selector
  8203. )
  8204. );
  8205. }
  8206. /// <summary>
  8207. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="T:System.Decimal" /> value.
  8208. /// </summary>
  8209. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8210. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8211. /// <param name="selector">A transform function to apply to each element.</param>
  8212. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Decimal" /> that corresponds to the maximum value in the source sequence.</returns>
  8213. /// <exception cref="T:System.ArgumentNullException">
  8214. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8215. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8216. public static IQbservable<decimal> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal>> selector)
  8217. {
  8218. if (source == null)
  8219. throw new ArgumentNullException("source");
  8220. if (selector == null)
  8221. throw new ArgumentNullException("selector");
  8222. return source.Provider.CreateQuery<decimal>(
  8223. Expression.Call(
  8224. null,
  8225. #if CRIPPLED_REFLECTION
  8226. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal>>))),
  8227. #else
  8228. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8229. #endif
  8230. source.Expression,
  8231. selector
  8232. )
  8233. );
  8234. }
  8235. /// <summary>
  8236. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="T:System.Int32" /> value.
  8237. /// </summary>
  8238. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8239. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8240. /// <param name="selector">A transform function to apply to each element.</param>
  8241. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Int32" /> that corresponds to the maximum value in the source sequence.</returns>
  8242. /// <exception cref="T:System.ArgumentNullException">
  8243. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8244. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8245. public static IQbservable<int> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int>> selector)
  8246. {
  8247. if (source == null)
  8248. throw new ArgumentNullException("source");
  8249. if (selector == null)
  8250. throw new ArgumentNullException("selector");
  8251. return source.Provider.CreateQuery<int>(
  8252. Expression.Call(
  8253. null,
  8254. #if CRIPPLED_REFLECTION
  8255. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int>>))),
  8256. #else
  8257. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8258. #endif
  8259. source.Expression,
  8260. selector
  8261. )
  8262. );
  8263. }
  8264. /// <summary>
  8265. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="T:System.Int64" /> value.
  8266. /// </summary>
  8267. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8268. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8269. /// <param name="selector">A transform function to apply to each element.</param>
  8270. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Int64" /> that corresponds to the maximum value in the source sequence.</returns>
  8271. /// <exception cref="T:System.ArgumentNullException">
  8272. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8273. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8274. public static IQbservable<long> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long>> selector)
  8275. {
  8276. if (source == null)
  8277. throw new ArgumentNullException("source");
  8278. if (selector == null)
  8279. throw new ArgumentNullException("selector");
  8280. return source.Provider.CreateQuery<long>(
  8281. Expression.Call(
  8282. null,
  8283. #if CRIPPLED_REFLECTION
  8284. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long>>))),
  8285. #else
  8286. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8287. #endif
  8288. source.Expression,
  8289. selector
  8290. )
  8291. );
  8292. }
  8293. /// <summary>
  8294. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="T:System.Double" /> value.
  8295. /// </summary>
  8296. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8297. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8298. /// <param name="selector">A transform function to apply to each element.</param>
  8299. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable&lt;System.Double&gt;" /> that corresponds to the maximum value in the source sequence.</returns>
  8300. /// <exception cref="T:System.ArgumentNullException">
  8301. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8302. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8303. public static IQbservable<double?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double?>> selector)
  8304. {
  8305. if (source == null)
  8306. throw new ArgumentNullException("source");
  8307. if (selector == null)
  8308. throw new ArgumentNullException("selector");
  8309. return source.Provider.CreateQuery<double?>(
  8310. Expression.Call(
  8311. null,
  8312. #if CRIPPLED_REFLECTION
  8313. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double?>>))),
  8314. #else
  8315. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8316. #endif
  8317. source.Expression,
  8318. selector
  8319. )
  8320. );
  8321. }
  8322. /// <summary>
  8323. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="T:System.Single" /> value.
  8324. /// </summary>
  8325. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8326. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8327. /// <param name="selector">A transform function to apply to each element.</param>
  8328. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable&lt;System.Single&gt;" /> that corresponds to the maximum value in the source sequence.</returns>
  8329. /// <exception cref="T:System.ArgumentNullException">
  8330. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8331. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8332. public static IQbservable<float?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float?>> selector)
  8333. {
  8334. if (source == null)
  8335. throw new ArgumentNullException("source");
  8336. if (selector == null)
  8337. throw new ArgumentNullException("selector");
  8338. return source.Provider.CreateQuery<float?>(
  8339. Expression.Call(
  8340. null,
  8341. #if CRIPPLED_REFLECTION
  8342. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float?>>))),
  8343. #else
  8344. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8345. #endif
  8346. source.Expression,
  8347. selector
  8348. )
  8349. );
  8350. }
  8351. /// <summary>
  8352. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="T:System.Decimal" /> value.
  8353. /// </summary>
  8354. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8355. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8356. /// <param name="selector">A transform function to apply to each element.</param>
  8357. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable&lt;System.Decimal&gt;" /> that corresponds to the maximum value in the source sequence.</returns>
  8358. /// <exception cref="T:System.ArgumentNullException">
  8359. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8360. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8361. public static IQbservable<decimal?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal?>> selector)
  8362. {
  8363. if (source == null)
  8364. throw new ArgumentNullException("source");
  8365. if (selector == null)
  8366. throw new ArgumentNullException("selector");
  8367. return source.Provider.CreateQuery<decimal?>(
  8368. Expression.Call(
  8369. null,
  8370. #if CRIPPLED_REFLECTION
  8371. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal?>>))),
  8372. #else
  8373. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8374. #endif
  8375. source.Expression,
  8376. selector
  8377. )
  8378. );
  8379. }
  8380. /// <summary>
  8381. /// Invokes a transform function on each element of a sequence and returns the maximum value.
  8382. /// </summary>
  8383. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8384. /// <typeparam name="TResult">The type of the objects derived from the elements in the source sequence to determine the maximum of.</typeparam>
  8385. /// <param name="source">An observable sequence to determine the mimimum element of.</param>
  8386. /// <param name="selector">A transform function to apply to each element.</param>
  8387. /// <returns>An observable sequence containing a single element with the value that corresponds to the maximum element in the source sequence.</returns>
  8388. /// <exception cref="T:System.ArgumentNullException">
  8389. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8390. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8391. public static IQbservable<TResult> Max<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector)
  8392. {
  8393. if (source == null)
  8394. throw new ArgumentNullException("source");
  8395. if (selector == null)
  8396. throw new ArgumentNullException("selector");
  8397. return source.Provider.CreateQuery<TResult>(
  8398. Expression.Call(
  8399. null,
  8400. #if CRIPPLED_REFLECTION
  8401. InfoOf(() => Qbservable.Max<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>))),
  8402. #else
  8403. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  8404. #endif
  8405. source.Expression,
  8406. selector
  8407. )
  8408. );
  8409. }
  8410. /// <summary>
  8411. /// Invokes a transform function on each element of a sequence and returns the maximum value according to the specified comparer.
  8412. /// </summary>
  8413. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8414. /// <typeparam name="TResult">The type of the objects derived from the elements in the source sequence to determine the maximum of.</typeparam>
  8415. /// <param name="source">An observable sequence to determine the mimimum element of.</param>
  8416. /// <param name="selector">A transform function to apply to each element.</param>
  8417. /// <param name="comparer">Comparer used to compare elements.</param>
  8418. /// <returns>An observable sequence containing a single element with the value that corresponds to the maximum element in the source sequence.</returns>
  8419. /// <exception cref="T:System.ArgumentNullException">
  8420. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="comparer" /> is null.</exception>
  8421. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8422. public static IQbservable<TResult> Max<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector, IComparer<TResult> comparer)
  8423. {
  8424. if (source == null)
  8425. throw new ArgumentNullException("source");
  8426. if (selector == null)
  8427. throw new ArgumentNullException("selector");
  8428. if (comparer == null)
  8429. throw new ArgumentNullException("comparer");
  8430. return source.Provider.CreateQuery<TResult>(
  8431. Expression.Call(
  8432. null,
  8433. #if CRIPPLED_REFLECTION
  8434. InfoOf(() => Qbservable.Max<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>), default(IComparer<TResult>))),
  8435. #else
  8436. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  8437. #endif
  8438. source.Expression,
  8439. selector,
  8440. Expression.Constant(comparer, typeof(IComparer<TResult>))
  8441. )
  8442. );
  8443. }
  8444. /// <summary>
  8445. /// Returns the elements in an observable sequence with the maximum key value.
  8446. /// </summary>
  8447. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8448. /// <typeparam name="TKey">The type of the key computed for each element in the source sequence.</typeparam>
  8449. /// <param name="source">An observable sequence to get the maximum elements for.</param>
  8450. /// <param name="keySelector">Key selector function.</param>
  8451. /// <returns>An observable sequence containing a list of zero or more elements that have a maximum key value.</returns>
  8452. /// <exception cref="T:System.ArgumentNullException">
  8453. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  8454. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8455. public static IQbservable<IList<TSource>> MaxBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  8456. {
  8457. if (source == null)
  8458. throw new ArgumentNullException("source");
  8459. if (keySelector == null)
  8460. throw new ArgumentNullException("keySelector");
  8461. return source.Provider.CreateQuery<IList<TSource>>(
  8462. Expression.Call(
  8463. null,
  8464. #if CRIPPLED_REFLECTION
  8465. InfoOf(() => Qbservable.MaxBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  8466. #else
  8467. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  8468. #endif
  8469. source.Expression,
  8470. keySelector
  8471. )
  8472. );
  8473. }
  8474. /// <summary>
  8475. /// Returns the elements in an observable sequence with the maximum key value according to the specified comparer.
  8476. /// </summary>
  8477. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8478. /// <typeparam name="TKey">The type of the key computed for each element in the source sequence.</typeparam>
  8479. /// <param name="source">An observable sequence to get the maximum elements for.</param>
  8480. /// <param name="keySelector">Key selector function.</param>
  8481. /// <param name="comparer">Comparer used to compare key values.</param>
  8482. /// <returns>An observable sequence containing a list of zero or more elements that have a maximum key value.</returns>
  8483. /// <exception cref="T:System.ArgumentNullException">
  8484. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  8485. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8486. public static IQbservable<IList<TSource>> MaxBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer)
  8487. {
  8488. if (source == null)
  8489. throw new ArgumentNullException("source");
  8490. if (keySelector == null)
  8491. throw new ArgumentNullException("keySelector");
  8492. if (comparer == null)
  8493. throw new ArgumentNullException("comparer");
  8494. return source.Provider.CreateQuery<IList<TSource>>(
  8495. Expression.Call(
  8496. null,
  8497. #if CRIPPLED_REFLECTION
  8498. InfoOf(() => Qbservable.MaxBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IComparer<TKey>))),
  8499. #else
  8500. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  8501. #endif
  8502. source.Expression,
  8503. keySelector,
  8504. Expression.Constant(comparer, typeof(IComparer<TKey>))
  8505. )
  8506. );
  8507. }
  8508. /// <summary>
  8509. /// Merges elements from two observable sequences into a single observable sequence.
  8510. /// </summary>
  8511. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8512. /// <param name="first">First observable sequence.</param>
  8513. /// <param name="second">Second observable sequence.</param>
  8514. /// <returns>The observable sequence that merges the elements of the given sequences.</returns>
  8515. /// <exception cref="T:System.ArgumentNullException">
  8516. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  8517. public static IQbservable<TSource> Merge<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  8518. {
  8519. if (first == null)
  8520. throw new ArgumentNullException("first");
  8521. if (second == null)
  8522. throw new ArgumentNullException("second");
  8523. return first.Provider.CreateQuery<TSource>(
  8524. Expression.Call(
  8525. null,
  8526. #if CRIPPLED_REFLECTION
  8527. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  8528. #else
  8529. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8530. #endif
  8531. first.Expression,
  8532. GetSourceExpression(second)
  8533. )
  8534. );
  8535. }
  8536. /// <summary>
  8537. /// Merges elements from two observable sequences into a single observable sequence, using the specified scheduler for enumeration of and subscription to the sources.
  8538. /// </summary>
  8539. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8540. /// <param name="first">First observable sequence.</param>
  8541. /// <param name="second">Second observable sequence.</param>
  8542. /// <param name="scheduler">Scheduler used to introduce concurrency for making subscriptions to the given sequences.</param>
  8543. /// <returns>The observable sequence that merges the elements of the given sequences.</returns>
  8544. /// <exception cref="T:System.ArgumentNullException">
  8545. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="scheduler" /> is null.</exception>
  8546. public static IQbservable<TSource> Merge<TSource>(this IQbservable<TSource> first, IObservable<TSource> second, IScheduler scheduler)
  8547. {
  8548. if (first == null)
  8549. throw new ArgumentNullException("first");
  8550. if (second == null)
  8551. throw new ArgumentNullException("second");
  8552. if (scheduler == null)
  8553. throw new ArgumentNullException("scheduler");
  8554. return first.Provider.CreateQuery<TSource>(
  8555. Expression.Call(
  8556. null,
  8557. #if CRIPPLED_REFLECTION
  8558. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>), default(IScheduler))),
  8559. #else
  8560. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8561. #endif
  8562. first.Expression,
  8563. GetSourceExpression(second),
  8564. Expression.Constant(scheduler, typeof(IScheduler))
  8565. )
  8566. );
  8567. }
  8568. /// <summary>
  8569. /// 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.
  8570. /// </summary>
  8571. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  8572. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8573. /// <param name="sources">Observable sequences.</param>
  8574. /// <param name="scheduler">Scheduler to run the enumeration of the sequence of sources on.</param>
  8575. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  8576. /// <exception cref="T:System.ArgumentNullException">
  8577. /// <paramref name="scheduler" /> or <paramref name="sources" /> is null.</exception>
  8578. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IScheduler scheduler, params IObservable<TSource>[] sources)
  8579. {
  8580. if (provider == null)
  8581. throw new ArgumentNullException("provider");
  8582. if (scheduler == null)
  8583. throw new ArgumentNullException("scheduler");
  8584. if (sources == null)
  8585. throw new ArgumentNullException("sources");
  8586. return provider.CreateQuery<TSource>(
  8587. Expression.Call(
  8588. null,
  8589. #if CRIPPLED_REFLECTION
  8590. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IScheduler), default(IObservable<TSource>[]))),
  8591. #else
  8592. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8593. #endif
  8594. Expression.Constant(provider, typeof(IQbservableProvider)),
  8595. Expression.Constant(scheduler, typeof(IScheduler)),
  8596. GetSourceExpression(sources)
  8597. )
  8598. );
  8599. }
  8600. /// <summary>
  8601. /// Merges elements from all inner observable sequences into a single observable sequence.
  8602. /// </summary>
  8603. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8604. /// <param name="sources">Observable sequence of inner observable sequences.</param>
  8605. /// <returns>The observable sequence that merges the elements of the inner sequences.</returns>
  8606. /// <exception cref="T:System.ArgumentNullException">
  8607. /// <paramref name="sources" /> is null.</exception>
  8608. public static IQbservable<TSource> Merge<TSource>(this IQbservable<IObservable<TSource>> sources)
  8609. {
  8610. if (sources == null)
  8611. throw new ArgumentNullException("sources");
  8612. return sources.Provider.CreateQuery<TSource>(
  8613. Expression.Call(
  8614. null,
  8615. #if CRIPPLED_REFLECTION
  8616. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<IObservable<TSource>>))),
  8617. #else
  8618. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8619. #endif
  8620. sources.Expression
  8621. )
  8622. );
  8623. }
  8624. #if !NO_TPL
  8625. /// <summary>
  8626. /// Merges results from all source tasks into a single observable sequence.
  8627. /// </summary>
  8628. /// <typeparam name="TSource">The type of the results produced by the source tasks.</typeparam>
  8629. /// <param name="sources">Observable sequence of tasks.</param>
  8630. /// <returns>The observable sequence that merges the results of the source tasks.</returns>
  8631. /// <exception cref="T:System.ArgumentNullException">
  8632. /// <paramref name="sources" /> is null.</exception>
  8633. /// <remarks>If the tasks support cancellation, consider manual conversion of the tasks using <see cref="M:System.Reactive.Linq.Observable.FromAsync``1(System.Func{System.Threading.CancellationToken,System.Threading.Tasks.Task{``0}})" />, followed by a merge operation using <see cref="M:System.Reactive.Linq.Observable.Merge``1(System.IObservable{System.IObservable{``0}})" />.</remarks>
  8634. public static IQbservable<TSource> Merge<TSource>(this IQbservable<Task<TSource>> sources)
  8635. {
  8636. if (sources == null)
  8637. throw new ArgumentNullException("sources");
  8638. return sources.Provider.CreateQuery<TSource>(
  8639. Expression.Call(
  8640. null,
  8641. #if CRIPPLED_REFLECTION
  8642. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<Task<TSource>>))),
  8643. #else
  8644. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8645. #endif
  8646. sources.Expression
  8647. )
  8648. );
  8649. }
  8650. #endif
  8651. /// <summary>
  8652. /// Merges elements from all of the specified observable sequences into a single observable sequence.
  8653. /// </summary>
  8654. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  8655. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8656. /// <param name="sources">Observable sequences.</param>
  8657. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  8658. /// <exception cref="T:System.ArgumentNullException">
  8659. /// <paramref name="sources" /> is null.</exception>
  8660. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  8661. {
  8662. if (provider == null)
  8663. throw new ArgumentNullException("provider");
  8664. if (sources == null)
  8665. throw new ArgumentNullException("sources");
  8666. return provider.CreateQuery<TSource>(
  8667. Expression.Call(
  8668. null,
  8669. #if CRIPPLED_REFLECTION
  8670. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  8671. #else
  8672. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8673. #endif
  8674. Expression.Constant(provider, typeof(IQbservableProvider)),
  8675. GetSourceExpression(sources)
  8676. )
  8677. );
  8678. }
  8679. /// <summary>
  8680. /// Merges elements from all observable sequences in the given enumerable sequence into a single observable sequence.
  8681. /// </summary>
  8682. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  8683. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8684. /// <param name="sources">Enumerable sequence of observable sequences.</param>
  8685. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  8686. /// <exception cref="T:System.ArgumentNullException">
  8687. /// <paramref name="sources" /> is null.</exception>
  8688. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  8689. {
  8690. if (provider == null)
  8691. throw new ArgumentNullException("provider");
  8692. if (sources == null)
  8693. throw new ArgumentNullException("sources");
  8694. return provider.CreateQuery<TSource>(
  8695. Expression.Call(
  8696. null,
  8697. #if CRIPPLED_REFLECTION
  8698. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  8699. #else
  8700. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8701. #endif
  8702. Expression.Constant(provider, typeof(IQbservableProvider)),
  8703. GetSourceExpression(sources)
  8704. )
  8705. );
  8706. }
  8707. /// <summary>
  8708. /// Merges elements from all inner observable sequences into a single observable sequence, limiting the number of concurrent subscriptions to inner sequences.
  8709. /// </summary>
  8710. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8711. /// <param name="sources">Observable sequence of inner observable sequences.</param>
  8712. /// <param name="maxConcurrent">Maximum number of inner observable sequences being subscribed to concurrently.</param>
  8713. /// <returns>The observable sequence that merges the elements of the inner sequences.</returns>
  8714. /// <exception cref="T:System.ArgumentNullException">
  8715. /// <paramref name="sources" /> is null.</exception>
  8716. /// <exception cref="T:System.ArgumentOutOfRangeException">
  8717. /// <paramref name="maxConcurrent" /> is less than or equal to zero.</exception>
  8718. public static IQbservable<TSource> Merge<TSource>(this IQbservable<IObservable<TSource>> sources, int maxConcurrent)
  8719. {
  8720. if (sources == null)
  8721. throw new ArgumentNullException("sources");
  8722. return sources.Provider.CreateQuery<TSource>(
  8723. Expression.Call(
  8724. null,
  8725. #if CRIPPLED_REFLECTION
  8726. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<IObservable<TSource>>), default(int))),
  8727. #else
  8728. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8729. #endif
  8730. sources.Expression,
  8731. Expression.Constant(maxConcurrent, typeof(int))
  8732. )
  8733. );
  8734. }
  8735. /// <summary>
  8736. /// 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.
  8737. /// </summary>
  8738. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  8739. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8740. /// <param name="sources">Enumerable sequence of observable sequences.</param>
  8741. /// <param name="maxConcurrent">Maximum number of observable sequences being subscribed to concurrently.</param>
  8742. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  8743. /// <exception cref="T:System.ArgumentNullException">
  8744. /// <paramref name="sources" /> is null.</exception>
  8745. /// <exception cref="T:System.ArgumentOutOfRangeException">
  8746. /// <paramref name="maxConcurrent" /> is less than or equal to zero.</exception>
  8747. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, int maxConcurrent)
  8748. {
  8749. if (provider == null)
  8750. throw new ArgumentNullException("provider");
  8751. if (sources == null)
  8752. throw new ArgumentNullException("sources");
  8753. return provider.CreateQuery<TSource>(
  8754. Expression.Call(
  8755. null,
  8756. #if CRIPPLED_REFLECTION
  8757. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(int))),
  8758. #else
  8759. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8760. #endif
  8761. Expression.Constant(provider, typeof(IQbservableProvider)),
  8762. GetSourceExpression(sources),
  8763. Expression.Constant(maxConcurrent, typeof(int))
  8764. )
  8765. );
  8766. }
  8767. /// <summary>
  8768. /// 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.
  8769. /// </summary>
  8770. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  8771. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8772. /// <param name="sources">Enumerable sequence of observable sequences.</param>
  8773. /// <param name="maxConcurrent">Maximum number of observable sequences being subscribed to concurrently.</param>
  8774. /// <param name="scheduler">Scheduler to run the enumeration of the sequence of sources on.</param>
  8775. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  8776. /// <exception cref="T:System.ArgumentNullException">
  8777. /// <paramref name="sources" /> or <paramref name="scheduler" /> is null.</exception>
  8778. /// <exception cref="T:System.ArgumentOutOfRangeException">
  8779. /// <paramref name="maxConcurrent" /> is less than or equal to zero.</exception>
  8780. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, int maxConcurrent, IScheduler scheduler)
  8781. {
  8782. if (provider == null)
  8783. throw new ArgumentNullException("provider");
  8784. if (sources == null)
  8785. throw new ArgumentNullException("sources");
  8786. if (scheduler == null)
  8787. throw new ArgumentNullException("scheduler");
  8788. return provider.CreateQuery<TSource>(
  8789. Expression.Call(
  8790. null,
  8791. #if CRIPPLED_REFLECTION
  8792. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(int), default(IScheduler))),
  8793. #else
  8794. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8795. #endif
  8796. Expression.Constant(provider, typeof(IQbservableProvider)),
  8797. GetSourceExpression(sources),
  8798. Expression.Constant(maxConcurrent, typeof(int)),
  8799. Expression.Constant(scheduler, typeof(IScheduler))
  8800. )
  8801. );
  8802. }
  8803. /// <summary>
  8804. /// 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.
  8805. /// </summary>
  8806. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  8807. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8808. /// <param name="sources">Enumerable sequence of observable sequences.</param>
  8809. /// <param name="scheduler">Scheduler to run the enumeration of the sequence of sources on.</param>
  8810. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  8811. /// <exception cref="T:System.ArgumentNullException">
  8812. /// <paramref name="sources" /> or <paramref name="scheduler" /> is null.</exception>
  8813. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, IScheduler scheduler)
  8814. {
  8815. if (provider == null)
  8816. throw new ArgumentNullException("provider");
  8817. if (sources == null)
  8818. throw new ArgumentNullException("sources");
  8819. if (scheduler == null)
  8820. throw new ArgumentNullException("scheduler");
  8821. return provider.CreateQuery<TSource>(
  8822. Expression.Call(
  8823. null,
  8824. #if CRIPPLED_REFLECTION
  8825. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(IScheduler))),
  8826. #else
  8827. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8828. #endif
  8829. Expression.Constant(provider, typeof(IQbservableProvider)),
  8830. GetSourceExpression(sources),
  8831. Expression.Constant(scheduler, typeof(IScheduler))
  8832. )
  8833. );
  8834. }
  8835. /// <summary>
  8836. /// Returns the minimum value in an observable sequence of <see cref="T:System.Decimal" /> values.
  8837. /// </summary>
  8838. /// <param name="source">A sequence of <see cref="T:System.Decimal" /> values to determine the minimum value of.</param>
  8839. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  8840. /// <exception cref="T:System.ArgumentNullException">
  8841. /// <paramref name="source" /> is null.</exception>
  8842. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8843. public static IQbservable<decimal> Min(this IQbservable<decimal> source)
  8844. {
  8845. if (source == null)
  8846. throw new ArgumentNullException("source");
  8847. return source.Provider.CreateQuery<decimal>(
  8848. Expression.Call(
  8849. null,
  8850. #if CRIPPLED_REFLECTION
  8851. InfoOf(() => Qbservable.Min(default(IQbservable<decimal>))),
  8852. #else
  8853. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8854. #endif
  8855. source.Expression
  8856. )
  8857. );
  8858. }
  8859. /// <summary>
  8860. /// Returns the minimum value in an observable sequence of <see cref="T:System.Double" /> values.
  8861. /// </summary>
  8862. /// <param name="source">A sequence of <see cref="T:System.Double" /> values to determine the minimum value of.</param>
  8863. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  8864. /// <exception cref="T:System.ArgumentNullException">
  8865. /// <paramref name="source" /> is null.</exception>
  8866. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8867. public static IQbservable<double> Min(this IQbservable<double> source)
  8868. {
  8869. if (source == null)
  8870. throw new ArgumentNullException("source");
  8871. return source.Provider.CreateQuery<double>(
  8872. Expression.Call(
  8873. null,
  8874. #if CRIPPLED_REFLECTION
  8875. InfoOf(() => Qbservable.Min(default(IQbservable<double>))),
  8876. #else
  8877. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8878. #endif
  8879. source.Expression
  8880. )
  8881. );
  8882. }
  8883. /// <summary>
  8884. /// Returns the minimum value in an observable sequence of <see cref="T:System.Int32" /> values.
  8885. /// </summary>
  8886. /// <param name="source">A sequence of <see cref="T:System.Int32" /> values to determine the minimum value of.</param>
  8887. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  8888. /// <exception cref="T:System.ArgumentNullException">
  8889. /// <paramref name="source" /> is null.</exception>
  8890. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8891. public static IQbservable<int> Min(this IQbservable<int> source)
  8892. {
  8893. if (source == null)
  8894. throw new ArgumentNullException("source");
  8895. return source.Provider.CreateQuery<int>(
  8896. Expression.Call(
  8897. null,
  8898. #if CRIPPLED_REFLECTION
  8899. InfoOf(() => Qbservable.Min(default(IQbservable<int>))),
  8900. #else
  8901. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8902. #endif
  8903. source.Expression
  8904. )
  8905. );
  8906. }
  8907. /// <summary>
  8908. /// Returns the minimum value in an observable sequence of <see cref="T:System.Int64" /> values.
  8909. /// </summary>
  8910. /// <param name="source">A sequence of <see cref="T:System.Int64" /> values to determine the minimum value of.</param>
  8911. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  8912. /// <exception cref="T:System.ArgumentNullException">
  8913. /// <paramref name="source" /> is null.</exception>
  8914. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8915. public static IQbservable<long> Min(this IQbservable<long> source)
  8916. {
  8917. if (source == null)
  8918. throw new ArgumentNullException("source");
  8919. return source.Provider.CreateQuery<long>(
  8920. Expression.Call(
  8921. null,
  8922. #if CRIPPLED_REFLECTION
  8923. InfoOf(() => Qbservable.Min(default(IQbservable<long>))),
  8924. #else
  8925. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8926. #endif
  8927. source.Expression
  8928. )
  8929. );
  8930. }
  8931. /// <summary>
  8932. /// Returns the minimum value in an observable sequence of nullable <see cref="T:System.Decimal" /> values.
  8933. /// </summary>
  8934. /// <param name="source">A sequence of nullable <see cref="T:System.Decimal" /> values to determine the minimum value of.</param>
  8935. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  8936. /// <exception cref="T:System.ArgumentNullException">
  8937. /// <paramref name="source" /> is null.</exception>
  8938. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8939. public static IQbservable<decimal?> Min(this IQbservable<decimal?> source)
  8940. {
  8941. if (source == null)
  8942. throw new ArgumentNullException("source");
  8943. return source.Provider.CreateQuery<decimal?>(
  8944. Expression.Call(
  8945. null,
  8946. #if CRIPPLED_REFLECTION
  8947. InfoOf(() => Qbservable.Min(default(IQbservable<decimal?>))),
  8948. #else
  8949. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8950. #endif
  8951. source.Expression
  8952. )
  8953. );
  8954. }
  8955. /// <summary>
  8956. /// Returns the minimum value in an observable sequence of nullable <see cref="T:System.Double" /> values.
  8957. /// </summary>
  8958. /// <param name="source">A sequence of nullable <see cref="T:System.Double" /> values to determine the minimum value of.</param>
  8959. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  8960. /// <exception cref="T:System.ArgumentNullException">
  8961. /// <paramref name="source" /> is null.</exception>
  8962. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8963. public static IQbservable<double?> Min(this IQbservable<double?> source)
  8964. {
  8965. if (source == null)
  8966. throw new ArgumentNullException("source");
  8967. return source.Provider.CreateQuery<double?>(
  8968. Expression.Call(
  8969. null,
  8970. #if CRIPPLED_REFLECTION
  8971. InfoOf(() => Qbservable.Min(default(IQbservable<double?>))),
  8972. #else
  8973. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8974. #endif
  8975. source.Expression
  8976. )
  8977. );
  8978. }
  8979. /// <summary>
  8980. /// Returns the minimum value in an observable sequence of nullable <see cref="T:System.Int32" /> values.
  8981. /// </summary>
  8982. /// <param name="source">A sequence of nullable <see cref="T:System.Int32" /> values to determine the minimum value of.</param>
  8983. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  8984. /// <exception cref="T:System.ArgumentNullException">
  8985. /// <paramref name="source" /> is null.</exception>
  8986. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8987. public static IQbservable<int?> Min(this IQbservable<int?> source)
  8988. {
  8989. if (source == null)
  8990. throw new ArgumentNullException("source");
  8991. return source.Provider.CreateQuery<int?>(
  8992. Expression.Call(
  8993. null,
  8994. #if CRIPPLED_REFLECTION
  8995. InfoOf(() => Qbservable.Min(default(IQbservable<int?>))),
  8996. #else
  8997. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8998. #endif
  8999. source.Expression
  9000. )
  9001. );
  9002. }
  9003. /// <summary>
  9004. /// Returns the minimum value in an observable sequence of nullable <see cref="T:System.Int64" /> values.
  9005. /// </summary>
  9006. /// <param name="source">A sequence of nullable <see cref="T:System.Int64" /> values to determine the minimum value of.</param>
  9007. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9008. /// <exception cref="T:System.ArgumentNullException">
  9009. /// <paramref name="source" /> is null.</exception>
  9010. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9011. public static IQbservable<long?> Min(this IQbservable<long?> source)
  9012. {
  9013. if (source == null)
  9014. throw new ArgumentNullException("source");
  9015. return source.Provider.CreateQuery<long?>(
  9016. Expression.Call(
  9017. null,
  9018. #if CRIPPLED_REFLECTION
  9019. InfoOf(() => Qbservable.Min(default(IQbservable<long?>))),
  9020. #else
  9021. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9022. #endif
  9023. source.Expression
  9024. )
  9025. );
  9026. }
  9027. /// <summary>
  9028. /// Returns the minimum value in an observable sequence of nullable <see cref="T:System.Single" /> values.
  9029. /// </summary>
  9030. /// <param name="source">A sequence of nullable <see cref="T:System.Single" /> values to determine the minimum value of.</param>
  9031. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9032. /// <exception cref="T:System.ArgumentNullException">
  9033. /// <paramref name="source" /> is null.</exception>
  9034. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9035. public static IQbservable<float?> Min(this IQbservable<float?> source)
  9036. {
  9037. if (source == null)
  9038. throw new ArgumentNullException("source");
  9039. return source.Provider.CreateQuery<float?>(
  9040. Expression.Call(
  9041. null,
  9042. #if CRIPPLED_REFLECTION
  9043. InfoOf(() => Qbservable.Min(default(IQbservable<float?>))),
  9044. #else
  9045. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9046. #endif
  9047. source.Expression
  9048. )
  9049. );
  9050. }
  9051. /// <summary>
  9052. /// Returns the minimum value in an observable sequence of <see cref="T:System.Single" /> values.
  9053. /// </summary>
  9054. /// <param name="source">A sequence of <see cref="T:System.Single" /> values to determine the minimum value of.</param>
  9055. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9056. /// <exception cref="T:System.ArgumentNullException">
  9057. /// <paramref name="source" /> is null.</exception>
  9058. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9059. public static IQbservable<float> Min(this IQbservable<float> source)
  9060. {
  9061. if (source == null)
  9062. throw new ArgumentNullException("source");
  9063. return source.Provider.CreateQuery<float>(
  9064. Expression.Call(
  9065. null,
  9066. #if CRIPPLED_REFLECTION
  9067. InfoOf(() => Qbservable.Min(default(IQbservable<float>))),
  9068. #else
  9069. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9070. #endif
  9071. source.Expression
  9072. )
  9073. );
  9074. }
  9075. /// <summary>
  9076. /// Returns the minimum element in an observable sequence.
  9077. /// </summary>
  9078. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9079. /// <param name="source">An observable sequence to determine the mimimum element of.</param>
  9080. /// <returns>An observable sequence containing a single element with the minimum element in the source sequence.</returns>
  9081. /// <exception cref="T:System.ArgumentNullException">
  9082. /// <paramref name="source" /> is null.</exception>
  9083. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9084. public static IQbservable<TSource> Min<TSource>(this IQbservable<TSource> source)
  9085. {
  9086. if (source == null)
  9087. throw new ArgumentNullException("source");
  9088. return source.Provider.CreateQuery<TSource>(
  9089. Expression.Call(
  9090. null,
  9091. #if CRIPPLED_REFLECTION
  9092. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>))),
  9093. #else
  9094. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9095. #endif
  9096. source.Expression
  9097. )
  9098. );
  9099. }
  9100. /// <summary>
  9101. /// Returns the minimum element in an observable sequence according to the specified comparer.
  9102. /// </summary>
  9103. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9104. /// <param name="source">An observable sequence to determine the mimimum element of.</param>
  9105. /// <param name="comparer">Comparer used to compare elements.</param>
  9106. /// <returns>An observable sequence containing a single element with the minimum element in the source sequence.</returns>
  9107. /// <exception cref="T:System.ArgumentNullException">
  9108. /// <paramref name="source" /> or <paramref name="comparer" /> is null.</exception>
  9109. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9110. public static IQbservable<TSource> Min<TSource>(this IQbservable<TSource> source, IComparer<TSource> comparer)
  9111. {
  9112. if (source == null)
  9113. throw new ArgumentNullException("source");
  9114. if (comparer == null)
  9115. throw new ArgumentNullException("comparer");
  9116. return source.Provider.CreateQuery<TSource>(
  9117. Expression.Call(
  9118. null,
  9119. #if CRIPPLED_REFLECTION
  9120. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(IComparer<TSource>))),
  9121. #else
  9122. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9123. #endif
  9124. source.Expression,
  9125. Expression.Constant(comparer, typeof(IComparer<TSource>))
  9126. )
  9127. );
  9128. }
  9129. /// <summary>
  9130. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="T:System.Double" /> value.
  9131. /// </summary>
  9132. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9133. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9134. /// <param name="selector">A transform function to apply to each element.</param>
  9135. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Double" /> that corresponds to the minimum value in the source sequence.</returns>
  9136. /// <exception cref="T:System.ArgumentNullException">
  9137. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9138. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9139. public static IQbservable<double> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double>> selector)
  9140. {
  9141. if (source == null)
  9142. throw new ArgumentNullException("source");
  9143. if (selector == null)
  9144. throw new ArgumentNullException("selector");
  9145. return source.Provider.CreateQuery<double>(
  9146. Expression.Call(
  9147. null,
  9148. #if CRIPPLED_REFLECTION
  9149. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double>>))),
  9150. #else
  9151. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9152. #endif
  9153. source.Expression,
  9154. selector
  9155. )
  9156. );
  9157. }
  9158. /// <summary>
  9159. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="T:System.Single" /> value.
  9160. /// </summary>
  9161. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9162. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9163. /// <param name="selector">A transform function to apply to each element.</param>
  9164. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Single" /> that corresponds to the minimum value in the source sequence.</returns>
  9165. /// <exception cref="T:System.ArgumentNullException">
  9166. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9167. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9168. public static IQbservable<float> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float>> selector)
  9169. {
  9170. if (source == null)
  9171. throw new ArgumentNullException("source");
  9172. if (selector == null)
  9173. throw new ArgumentNullException("selector");
  9174. return source.Provider.CreateQuery<float>(
  9175. Expression.Call(
  9176. null,
  9177. #if CRIPPLED_REFLECTION
  9178. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float>>))),
  9179. #else
  9180. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9181. #endif
  9182. source.Expression,
  9183. selector
  9184. )
  9185. );
  9186. }
  9187. /// <summary>
  9188. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="T:System.Decimal" /> value.
  9189. /// </summary>
  9190. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9191. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9192. /// <param name="selector">A transform function to apply to each element.</param>
  9193. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Decimal" /> that corresponds to the minimum value in the source sequence.</returns>
  9194. /// <exception cref="T:System.ArgumentNullException">
  9195. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9196. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9197. public static IQbservable<decimal> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal>> selector)
  9198. {
  9199. if (source == null)
  9200. throw new ArgumentNullException("source");
  9201. if (selector == null)
  9202. throw new ArgumentNullException("selector");
  9203. return source.Provider.CreateQuery<decimal>(
  9204. Expression.Call(
  9205. null,
  9206. #if CRIPPLED_REFLECTION
  9207. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal>>))),
  9208. #else
  9209. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9210. #endif
  9211. source.Expression,
  9212. selector
  9213. )
  9214. );
  9215. }
  9216. /// <summary>
  9217. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="T:System.Int32" /> value.
  9218. /// </summary>
  9219. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9220. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9221. /// <param name="selector">A transform function to apply to each element.</param>
  9222. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Int32" /> that corresponds to the minimum value in the source sequence.</returns>
  9223. /// <exception cref="T:System.ArgumentNullException">
  9224. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9225. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9226. public static IQbservable<int> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int>> selector)
  9227. {
  9228. if (source == null)
  9229. throw new ArgumentNullException("source");
  9230. if (selector == null)
  9231. throw new ArgumentNullException("selector");
  9232. return source.Provider.CreateQuery<int>(
  9233. Expression.Call(
  9234. null,
  9235. #if CRIPPLED_REFLECTION
  9236. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int>>))),
  9237. #else
  9238. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9239. #endif
  9240. source.Expression,
  9241. selector
  9242. )
  9243. );
  9244. }
  9245. /// <summary>
  9246. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="T:System.Int64" /> value.
  9247. /// </summary>
  9248. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9249. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9250. /// <param name="selector">A transform function to apply to each element.</param>
  9251. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Int64" /> that corresponds to the minimum value in the source sequence.</returns>
  9252. /// <exception cref="T:System.ArgumentNullException">
  9253. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9254. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9255. public static IQbservable<long> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long>> selector)
  9256. {
  9257. if (source == null)
  9258. throw new ArgumentNullException("source");
  9259. if (selector == null)
  9260. throw new ArgumentNullException("selector");
  9261. return source.Provider.CreateQuery<long>(
  9262. Expression.Call(
  9263. null,
  9264. #if CRIPPLED_REFLECTION
  9265. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long>>))),
  9266. #else
  9267. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9268. #endif
  9269. source.Expression,
  9270. selector
  9271. )
  9272. );
  9273. }
  9274. /// <summary>
  9275. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="T:System.Double" /> value.
  9276. /// </summary>
  9277. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9278. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9279. /// <param name="selector">A transform function to apply to each element.</param>
  9280. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable&lt;System.Double&gt;" /> that corresponds to the minimum value in the source sequence.</returns>
  9281. /// <exception cref="T:System.ArgumentNullException">
  9282. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9283. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9284. public static IQbservable<double?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double?>> selector)
  9285. {
  9286. if (source == null)
  9287. throw new ArgumentNullException("source");
  9288. if (selector == null)
  9289. throw new ArgumentNullException("selector");
  9290. return source.Provider.CreateQuery<double?>(
  9291. Expression.Call(
  9292. null,
  9293. #if CRIPPLED_REFLECTION
  9294. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double?>>))),
  9295. #else
  9296. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9297. #endif
  9298. source.Expression,
  9299. selector
  9300. )
  9301. );
  9302. }
  9303. /// <summary>
  9304. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="T:System.Single" /> value.
  9305. /// </summary>
  9306. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9307. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9308. /// <param name="selector">A transform function to apply to each element.</param>
  9309. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable&lt;System.Single&gt;" /> that corresponds to the minimum value in the source sequence.</returns>
  9310. /// <exception cref="T:System.ArgumentNullException">
  9311. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9312. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9313. public static IQbservable<float?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float?>> selector)
  9314. {
  9315. if (source == null)
  9316. throw new ArgumentNullException("source");
  9317. if (selector == null)
  9318. throw new ArgumentNullException("selector");
  9319. return source.Provider.CreateQuery<float?>(
  9320. Expression.Call(
  9321. null,
  9322. #if CRIPPLED_REFLECTION
  9323. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float?>>))),
  9324. #else
  9325. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9326. #endif
  9327. source.Expression,
  9328. selector
  9329. )
  9330. );
  9331. }
  9332. /// <summary>
  9333. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="T:System.Decimal" /> value.
  9334. /// </summary>
  9335. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9336. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9337. /// <param name="selector">A transform function to apply to each element.</param>
  9338. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable&lt;System.Decimal&gt;" /> that corresponds to the minimum value in the source sequence.</returns>
  9339. /// <exception cref="T:System.ArgumentNullException">
  9340. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9341. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9342. public static IQbservable<decimal?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal?>> selector)
  9343. {
  9344. if (source == null)
  9345. throw new ArgumentNullException("source");
  9346. if (selector == null)
  9347. throw new ArgumentNullException("selector");
  9348. return source.Provider.CreateQuery<decimal?>(
  9349. Expression.Call(
  9350. null,
  9351. #if CRIPPLED_REFLECTION
  9352. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal?>>))),
  9353. #else
  9354. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9355. #endif
  9356. source.Expression,
  9357. selector
  9358. )
  9359. );
  9360. }
  9361. /// <summary>
  9362. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="T:System.Int32" /> value.
  9363. /// </summary>
  9364. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9365. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9366. /// <param name="selector">A transform function to apply to each element.</param>
  9367. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable&lt;System.Int32&gt;" /> that corresponds to the minimum value in the source sequence.</returns>
  9368. /// <exception cref="T:System.ArgumentNullException">
  9369. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9370. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9371. public static IQbservable<int?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int?>> selector)
  9372. {
  9373. if (source == null)
  9374. throw new ArgumentNullException("source");
  9375. if (selector == null)
  9376. throw new ArgumentNullException("selector");
  9377. return source.Provider.CreateQuery<int?>(
  9378. Expression.Call(
  9379. null,
  9380. #if CRIPPLED_REFLECTION
  9381. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int?>>))),
  9382. #else
  9383. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9384. #endif
  9385. source.Expression,
  9386. selector
  9387. )
  9388. );
  9389. }
  9390. /// <summary>
  9391. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="T:System.Int64" /> value.
  9392. /// </summary>
  9393. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9394. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9395. /// <param name="selector">A transform function to apply to each element.</param>
  9396. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable&lt;System.Int64&gt;" /> that corresponds to the minimum value in the source sequence.</returns>
  9397. /// <exception cref="T:System.ArgumentNullException">
  9398. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9399. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9400. public static IQbservable<long?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long?>> selector)
  9401. {
  9402. if (source == null)
  9403. throw new ArgumentNullException("source");
  9404. if (selector == null)
  9405. throw new ArgumentNullException("selector");
  9406. return source.Provider.CreateQuery<long?>(
  9407. Expression.Call(
  9408. null,
  9409. #if CRIPPLED_REFLECTION
  9410. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long?>>))),
  9411. #else
  9412. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9413. #endif
  9414. source.Expression,
  9415. selector
  9416. )
  9417. );
  9418. }
  9419. /// <summary>
  9420. /// Invokes a transform function on each element of a sequence and returns the minimum value.
  9421. /// </summary>
  9422. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9423. /// <typeparam name="TResult">The type of the objects derived from the elements in the source sequence to determine the minimum of.</typeparam>
  9424. /// <param name="source">An observable sequence to determine the mimimum element of.</param>
  9425. /// <param name="selector">A transform function to apply to each element.</param>
  9426. /// <returns>An observable sequence containing a single element with the value that corresponds to the minimum element in the source sequence.</returns>
  9427. /// <exception cref="T:System.ArgumentNullException">
  9428. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9429. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9430. public static IQbservable<TResult> Min<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector)
  9431. {
  9432. if (source == null)
  9433. throw new ArgumentNullException("source");
  9434. if (selector == null)
  9435. throw new ArgumentNullException("selector");
  9436. return source.Provider.CreateQuery<TResult>(
  9437. Expression.Call(
  9438. null,
  9439. #if CRIPPLED_REFLECTION
  9440. InfoOf(() => Qbservable.Min<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>))),
  9441. #else
  9442. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  9443. #endif
  9444. source.Expression,
  9445. selector
  9446. )
  9447. );
  9448. }
  9449. /// <summary>
  9450. /// Invokes a transform function on each element of a sequence and returns the minimum value according to the specified comparer.
  9451. /// </summary>
  9452. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9453. /// <typeparam name="TResult">The type of the objects derived from the elements in the source sequence to determine the minimum of.</typeparam>
  9454. /// <param name="source">An observable sequence to determine the mimimum element of.</param>
  9455. /// <param name="selector">A transform function to apply to each element.</param>
  9456. /// <param name="comparer">Comparer used to compare elements.</param>
  9457. /// <returns>An observable sequence containing a single element with the value that corresponds to the minimum element in the source sequence.</returns>
  9458. /// <exception cref="T:System.ArgumentNullException">
  9459. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="comparer" /> is null.</exception>
  9460. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9461. public static IQbservable<TResult> Min<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector, IComparer<TResult> comparer)
  9462. {
  9463. if (source == null)
  9464. throw new ArgumentNullException("source");
  9465. if (selector == null)
  9466. throw new ArgumentNullException("selector");
  9467. if (comparer == null)
  9468. throw new ArgumentNullException("comparer");
  9469. return source.Provider.CreateQuery<TResult>(
  9470. Expression.Call(
  9471. null,
  9472. #if CRIPPLED_REFLECTION
  9473. InfoOf(() => Qbservable.Min<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>), default(IComparer<TResult>))),
  9474. #else
  9475. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  9476. #endif
  9477. source.Expression,
  9478. selector,
  9479. Expression.Constant(comparer, typeof(IComparer<TResult>))
  9480. )
  9481. );
  9482. }
  9483. /// <summary>
  9484. /// Returns the elements in an observable sequence with the minimum key value.
  9485. /// </summary>
  9486. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9487. /// <typeparam name="TKey">The type of the key computed for each element in the source sequence.</typeparam>
  9488. /// <param name="source">An observable sequence to get the minimum elements for.</param>
  9489. /// <param name="keySelector">Key selector function.</param>
  9490. /// <returns>An observable sequence containing a list of zero or more elements that have a minimum key value.</returns>
  9491. /// <exception cref="T:System.ArgumentNullException">
  9492. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  9493. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9494. public static IQbservable<IList<TSource>> MinBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  9495. {
  9496. if (source == null)
  9497. throw new ArgumentNullException("source");
  9498. if (keySelector == null)
  9499. throw new ArgumentNullException("keySelector");
  9500. return source.Provider.CreateQuery<IList<TSource>>(
  9501. Expression.Call(
  9502. null,
  9503. #if CRIPPLED_REFLECTION
  9504. InfoOf(() => Qbservable.MinBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  9505. #else
  9506. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  9507. #endif
  9508. source.Expression,
  9509. keySelector
  9510. )
  9511. );
  9512. }
  9513. /// <summary>
  9514. /// Returns the elements in an observable sequence with the minimum key value according to the specified comparer.
  9515. /// </summary>
  9516. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9517. /// <typeparam name="TKey">The type of the key computed for each element in the source sequence.</typeparam>
  9518. /// <param name="source">An observable sequence to get the minimum elements for.</param>
  9519. /// <param name="keySelector">Key selector function.</param>
  9520. /// <param name="comparer">Comparer used to compare key values.</param>
  9521. /// <returns>An observable sequence containing a list of zero or more elements that have a minimum key value.</returns>
  9522. /// <exception cref="T:System.ArgumentNullException">
  9523. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  9524. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9525. public static IQbservable<IList<TSource>> MinBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer)
  9526. {
  9527. if (source == null)
  9528. throw new ArgumentNullException("source");
  9529. if (keySelector == null)
  9530. throw new ArgumentNullException("keySelector");
  9531. if (comparer == null)
  9532. throw new ArgumentNullException("comparer");
  9533. return source.Provider.CreateQuery<IList<TSource>>(
  9534. Expression.Call(
  9535. null,
  9536. #if CRIPPLED_REFLECTION
  9537. InfoOf(() => Qbservable.MinBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IComparer<TKey>))),
  9538. #else
  9539. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  9540. #endif
  9541. source.Expression,
  9542. keySelector,
  9543. Expression.Constant(comparer, typeof(IComparer<TKey>))
  9544. )
  9545. );
  9546. }
  9547. /// <summary>
  9548. /// 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.
  9549. /// Enumerators on the resulting sequence never block and can produce the same element repeatedly.
  9550. /// </summary>
  9551. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9552. /// <param name="source">Source observable sequence.</param>
  9553. /// <param name="initialValue">Initial value that will be yielded by the enumerable sequence if no element has been sampled yet.</param>
  9554. /// <returns>The enumerable sequence that returns the last sampled element upon each iteration.</returns>
  9555. /// <exception cref="T:System.ArgumentNullException">
  9556. /// <paramref name="source" /> is null.</exception>
  9557. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  9558. public static IQueryable<TSource> MostRecent<TSource>(this IQbservable<TSource> source, TSource initialValue)
  9559. {
  9560. if (source == null)
  9561. throw new ArgumentNullException("source");
  9562. return ((IQueryProvider)source.Provider).CreateQuery<TSource>(
  9563. Expression.Call(
  9564. null,
  9565. #if CRIPPLED_REFLECTION
  9566. InfoOf(() => Qbservable.MostRecent<TSource>(default(IQbservable<TSource>), default(TSource))),
  9567. #else
  9568. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9569. #endif
  9570. source.Expression,
  9571. Expression.Constant(initialValue, typeof(TSource))
  9572. )
  9573. );
  9574. }
  9575. /// <summary>
  9576. /// Multicasts the source sequence notifications through an instantiated subject into all uses of the sequence within a selector function. Each
  9577. /// subscription to the resulting sequence causes a separate multicast invocation, exposing the sequence resulting from the selector function's
  9578. /// invocation. For specializations with fixed subject types, see Publish, PublishLast, and Replay.
  9579. /// </summary>
  9580. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9581. /// <typeparam name="TIntermediate">The type of the elements produced by the intermediate subject.</typeparam>
  9582. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  9583. /// <param name="source">Source sequence which will be multicasted in the specified selector function.</param>
  9584. /// <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>
  9585. /// <param name="selector">Selector function which can use the multicasted source sequence subject to the policies enforced by the created subject.</param>
  9586. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  9587. /// <exception cref="T:System.ArgumentNullException">
  9588. /// <paramref name="source" /> or <paramref name="subjectSelector" /> or <paramref name="selector" /> is null.</exception>
  9589. 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)
  9590. {
  9591. if (source == null)
  9592. throw new ArgumentNullException("source");
  9593. if (subjectSelector == null)
  9594. throw new ArgumentNullException("subjectSelector");
  9595. if (selector == null)
  9596. throw new ArgumentNullException("selector");
  9597. return source.Provider.CreateQuery<TResult>(
  9598. Expression.Call(
  9599. null,
  9600. #if CRIPPLED_REFLECTION
  9601. InfoOf(() => Qbservable.Multicast<TSource, TIntermediate, TResult>(default(IQbservable<TSource>), default(Expression<Func<ISubject<TSource, TIntermediate>>>), default(Expression<Func<IObservable<TIntermediate>, IObservable<TResult>>>))),
  9602. #else
  9603. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TIntermediate), typeof(TResult)),
  9604. #endif
  9605. source.Expression,
  9606. subjectSelector,
  9607. selector
  9608. )
  9609. );
  9610. }
  9611. /// <summary>
  9612. /// Returns a non-terminating observable sequence, which can be used to denote an infinite duration (e.g. when using reactive joins).
  9613. /// </summary>
  9614. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  9615. /// <typeparam name="TResult">The type used for the IObservable&lt;T&gt; type parameter of the resulting sequence.</typeparam>
  9616. /// <returns>An observable sequence whose observers will never get called.</returns>
  9617. public static IQbservable<TResult> Never<TResult>(this IQbservableProvider provider)
  9618. {
  9619. if (provider == null)
  9620. throw new ArgumentNullException("provider");
  9621. return provider.CreateQuery<TResult>(
  9622. Expression.Call(
  9623. null,
  9624. #if CRIPPLED_REFLECTION
  9625. InfoOf(() => Qbservable.Never<TResult>(default(IQbservableProvider))),
  9626. #else
  9627. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  9628. #endif
  9629. Expression.Constant(provider, typeof(IQbservableProvider))
  9630. )
  9631. );
  9632. }
  9633. /// <summary>
  9634. /// Returns a non-terminating observable sequence, which can be used to denote an infinite duration (e.g. when using reactive joins).
  9635. /// </summary>
  9636. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  9637. /// <typeparam name="TResult">The type used for the IObservable&lt;T&gt; type parameter of the resulting sequence.</typeparam>
  9638. /// <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>
  9639. /// <returns>An observable sequence whose observers will never get called.</returns>
  9640. public static IQbservable<TResult> Never<TResult>(this IQbservableProvider provider, TResult witness)
  9641. {
  9642. if (provider == null)
  9643. throw new ArgumentNullException("provider");
  9644. return provider.CreateQuery<TResult>(
  9645. Expression.Call(
  9646. null,
  9647. #if CRIPPLED_REFLECTION
  9648. InfoOf(() => Qbservable.Never<TResult>(default(IQbservableProvider), default(TResult))),
  9649. #else
  9650. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  9651. #endif
  9652. Expression.Constant(provider, typeof(IQbservableProvider)),
  9653. Expression.Constant(witness, typeof(TResult))
  9654. )
  9655. );
  9656. }
  9657. /// <summary>
  9658. /// Returns an enumerable sequence whose enumeration blocks until the next element in the source observable sequence becomes available.
  9659. /// Enumerators on the resulting sequence will block until the next element becomes available.
  9660. /// </summary>
  9661. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9662. /// <param name="source">Source observable sequence.</param>
  9663. /// <returns>The enumerable sequence that blocks upon each iteration until the next element in the observable source sequence becomes available.</returns>
  9664. /// <exception cref="T:System.ArgumentNullException">
  9665. /// <paramref name="source" /> is null.</exception>
  9666. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  9667. public static IQueryable<TSource> Next<TSource>(this IQbservable<TSource> source)
  9668. {
  9669. if (source == null)
  9670. throw new ArgumentNullException("source");
  9671. return ((IQueryProvider)source.Provider).CreateQuery<TSource>(
  9672. Expression.Call(
  9673. null,
  9674. #if CRIPPLED_REFLECTION
  9675. InfoOf(() => Qbservable.Next<TSource>(default(IQbservable<TSource>))),
  9676. #else
  9677. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9678. #endif
  9679. source.Expression
  9680. )
  9681. );
  9682. }
  9683. /// <summary>
  9684. /// Wraps the source sequence in order to run its observer callbacks on the specified synchronization context.
  9685. /// </summary>
  9686. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9687. /// <param name="source">Source sequence.</param>
  9688. /// <param name="context">Synchronization context to notify observers on.</param>
  9689. /// <returns>The source sequence whose observations happen on the specified synchronization context.</returns>
  9690. /// <exception cref="T:System.ArgumentNullException">
  9691. /// <paramref name="source" /> or <paramref name="context" /> is null.</exception>
  9692. /// <remarks>
  9693. /// This only invokes observer callbacks on a synchronization context. In case the subscription and/or unsubscription actions have side-effects
  9694. /// that require to be run on a synchronization context, use <see cref="M:System.Reactive.Linq.Observable.SubscribeOn``1(System.IObservable{``0},System.Threading.SynchronizationContext)" />.
  9695. /// </remarks>
  9696. public static IQbservable<TSource> ObserveOn<TSource>(this IQbservable<TSource> source, SynchronizationContext context)
  9697. {
  9698. if (source == null)
  9699. throw new ArgumentNullException("source");
  9700. if (context == null)
  9701. throw new ArgumentNullException("context");
  9702. return source.Provider.CreateQuery<TSource>(
  9703. Expression.Call(
  9704. null,
  9705. #if CRIPPLED_REFLECTION
  9706. InfoOf(() => Qbservable.ObserveOn<TSource>(default(IQbservable<TSource>), default(SynchronizationContext))),
  9707. #else
  9708. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9709. #endif
  9710. source.Expression,
  9711. Expression.Constant(context, typeof(SynchronizationContext))
  9712. )
  9713. );
  9714. }
  9715. /// <summary>
  9716. /// Wraps the source sequence in order to run its observer callbacks on the specified scheduler.
  9717. /// </summary>
  9718. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9719. /// <param name="source">Source sequence.</param>
  9720. /// <param name="scheduler">Scheduler to notify observers on.</param>
  9721. /// <returns>The source sequence whose observations happen on the specified scheduler.</returns>
  9722. /// <exception cref="T:System.ArgumentNullException">
  9723. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  9724. /// <remarks>
  9725. /// This only invokes observer callbacks on a scheduler. In case the subscription and/or unsubscription actions have side-effects
  9726. /// that require to be run on a scheduler, use <see cref="M:System.Reactive.Linq.Observable.SubscribeOn``1(System.IObservable{``0},System.Reactive.Concurrency.IScheduler)" />.
  9727. /// </remarks>
  9728. public static IQbservable<TSource> ObserveOn<TSource>(this IQbservable<TSource> source, IScheduler scheduler)
  9729. {
  9730. if (source == null)
  9731. throw new ArgumentNullException("source");
  9732. if (scheduler == null)
  9733. throw new ArgumentNullException("scheduler");
  9734. return source.Provider.CreateQuery<TSource>(
  9735. Expression.Call(
  9736. null,
  9737. #if CRIPPLED_REFLECTION
  9738. InfoOf(() => Qbservable.ObserveOn<TSource>(default(IQbservable<TSource>), default(IScheduler))),
  9739. #else
  9740. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9741. #endif
  9742. source.Expression,
  9743. Expression.Constant(scheduler, typeof(IScheduler))
  9744. )
  9745. );
  9746. }
  9747. /// <summary>
  9748. /// Filters the elements of an observable sequence based on the specified type.
  9749. /// </summary>
  9750. /// <typeparam name="TResult">The type to filter the elements in the source sequence on.</typeparam>
  9751. /// <param name="source">The observable sequence that contains the elements to be filtered.</param>
  9752. /// <returns>An observable sequence that contains elements from the input sequence of type TResult.</returns>
  9753. /// <exception cref="T:System.ArgumentNullException">
  9754. /// <paramref name="source" /> is null.</exception>
  9755. public static IQbservable<TResult> OfType<TResult>(this IQbservable<object> source)
  9756. {
  9757. if (source == null)
  9758. throw new ArgumentNullException("source");
  9759. return source.Provider.CreateQuery<TResult>(
  9760. Expression.Call(
  9761. null,
  9762. #if CRIPPLED_REFLECTION
  9763. InfoOf(() => Qbservable.OfType<TResult>(default(IQbservable<object>))),
  9764. #else
  9765. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  9766. #endif
  9767. source.Expression
  9768. )
  9769. );
  9770. }
  9771. /// <summary>
  9772. /// Concatenates the second observable sequence to the first observable sequence upon successful or exceptional termination of the first.
  9773. /// </summary>
  9774. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  9775. /// <param name="first">First observable sequence whose exception (if any) is caught.</param>
  9776. /// <param name="second">Second observable sequence used to produce results after the first sequence terminates.</param>
  9777. /// <returns>An observable sequence that concatenates the first and second sequence, even if the first sequence terminates exceptionally.</returns>
  9778. /// <exception cref="T:System.ArgumentNullException">
  9779. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  9780. public static IQbservable<TSource> OnErrorResumeNext<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  9781. {
  9782. if (first == null)
  9783. throw new ArgumentNullException("first");
  9784. if (second == null)
  9785. throw new ArgumentNullException("second");
  9786. return first.Provider.CreateQuery<TSource>(
  9787. Expression.Call(
  9788. null,
  9789. #if CRIPPLED_REFLECTION
  9790. InfoOf(() => Qbservable.OnErrorResumeNext<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  9791. #else
  9792. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9793. #endif
  9794. first.Expression,
  9795. GetSourceExpression(second)
  9796. )
  9797. );
  9798. }
  9799. /// <summary>
  9800. /// Concatenates all of the specified observable sequences, even if the previous observable sequence terminated exceptionally.
  9801. /// </summary>
  9802. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  9803. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  9804. /// <param name="sources">Observable sequences to concatenate.</param>
  9805. /// <returns>An observable sequence that concatenates the source sequences, even if a sequence terminates exceptionally.</returns>
  9806. /// <exception cref="T:System.ArgumentNullException">
  9807. /// <paramref name="sources" /> is null.</exception>
  9808. public static IQbservable<TSource> OnErrorResumeNext<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  9809. {
  9810. if (provider == null)
  9811. throw new ArgumentNullException("provider");
  9812. if (sources == null)
  9813. throw new ArgumentNullException("sources");
  9814. return provider.CreateQuery<TSource>(
  9815. Expression.Call(
  9816. null,
  9817. #if CRIPPLED_REFLECTION
  9818. InfoOf(() => Qbservable.OnErrorResumeNext<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  9819. #else
  9820. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9821. #endif
  9822. Expression.Constant(provider, typeof(IQbservableProvider)),
  9823. GetSourceExpression(sources)
  9824. )
  9825. );
  9826. }
  9827. /// <summary>
  9828. /// Concatenates all observable sequences in the given enumerable sequence, even if the previous observable sequence terminated exceptionally.
  9829. /// </summary>
  9830. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  9831. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  9832. /// <param name="sources">Observable sequences to concatenate.</param>
  9833. /// <returns>An observable sequence that concatenates the source sequences, even if a sequence terminates exceptionally.</returns>
  9834. /// <exception cref="T:System.ArgumentNullException">
  9835. /// <paramref name="sources" /> is null.</exception>
  9836. public static IQbservable<TSource> OnErrorResumeNext<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  9837. {
  9838. if (provider == null)
  9839. throw new ArgumentNullException("provider");
  9840. if (sources == null)
  9841. throw new ArgumentNullException("sources");
  9842. return provider.CreateQuery<TSource>(
  9843. Expression.Call(
  9844. null,
  9845. #if CRIPPLED_REFLECTION
  9846. InfoOf(() => Qbservable.OnErrorResumeNext<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  9847. #else
  9848. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9849. #endif
  9850. Expression.Constant(provider, typeof(IQbservableProvider)),
  9851. GetSourceExpression(sources)
  9852. )
  9853. );
  9854. }
  9855. /// <summary>
  9856. /// 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.
  9857. /// This operator is a specialization of Multicast using a regular <see cref="T:System.Reactive.Subjects.Subject`1" />.
  9858. /// </summary>
  9859. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9860. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  9861. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  9862. /// <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>
  9863. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  9864. /// <exception cref="T:System.ArgumentNullException">
  9865. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9866. /// <seealso cref="T:System.Reactive.Subjects.Subject`1" />
  9867. public static IQbservable<TResult> Publish<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector)
  9868. {
  9869. if (source == null)
  9870. throw new ArgumentNullException("source");
  9871. if (selector == null)
  9872. throw new ArgumentNullException("selector");
  9873. return source.Provider.CreateQuery<TResult>(
  9874. Expression.Call(
  9875. null,
  9876. #if CRIPPLED_REFLECTION
  9877. InfoOf(() => Qbservable.Publish<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>))),
  9878. #else
  9879. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  9880. #endif
  9881. source.Expression,
  9882. selector
  9883. )
  9884. );
  9885. }
  9886. /// <summary>
  9887. /// 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.
  9888. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.BehaviorSubject`1" />.
  9889. /// </summary>
  9890. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9891. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  9892. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  9893. /// <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>
  9894. /// <param name="initialValue">Initial value received by observers upon subscription.</param>
  9895. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  9896. /// <exception cref="T:System.ArgumentNullException">
  9897. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9898. /// <seealso cref="T:System.Reactive.Subjects.BehaviorSubject`1" />
  9899. public static IQbservable<TResult> Publish<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, TSource initialValue)
  9900. {
  9901. if (source == null)
  9902. throw new ArgumentNullException("source");
  9903. if (selector == null)
  9904. throw new ArgumentNullException("selector");
  9905. return source.Provider.CreateQuery<TResult>(
  9906. Expression.Call(
  9907. null,
  9908. #if CRIPPLED_REFLECTION
  9909. InfoOf(() => Qbservable.Publish<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(TSource))),
  9910. #else
  9911. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  9912. #endif
  9913. source.Expression,
  9914. selector,
  9915. Expression.Constant(initialValue, typeof(TSource))
  9916. )
  9917. );
  9918. }
  9919. /// <summary>
  9920. /// 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.
  9921. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.AsyncSubject`1" />.
  9922. /// </summary>
  9923. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9924. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  9925. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  9926. /// <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>
  9927. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  9928. /// <exception cref="T:System.ArgumentNullException">
  9929. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9930. /// <seealso cref="T:System.Reactive.Subjects.AsyncSubject`1" />
  9931. public static IQbservable<TResult> PublishLast<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector)
  9932. {
  9933. if (source == null)
  9934. throw new ArgumentNullException("source");
  9935. if (selector == null)
  9936. throw new ArgumentNullException("selector");
  9937. return source.Provider.CreateQuery<TResult>(
  9938. Expression.Call(
  9939. null,
  9940. #if CRIPPLED_REFLECTION
  9941. InfoOf(() => Qbservable.PublishLast<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>))),
  9942. #else
  9943. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  9944. #endif
  9945. source.Expression,
  9946. selector
  9947. )
  9948. );
  9949. }
  9950. /// <summary>
  9951. /// Generates an observable sequence of integral numbers within a specified range.
  9952. /// </summary>
  9953. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  9954. /// <param name="start">The value of the first integer in the sequence.</param>
  9955. /// <param name="count">The number of sequential integers to generate.</param>
  9956. /// <returns>An observable sequence that contains a range of sequential integral numbers.</returns>
  9957. /// <exception cref="T:System.ArgumentOutOfRangeException">
  9958. /// <paramref name="count" /> is less than zero. -or- <paramref name="start" /> + <paramref name="count" /> - 1 is larger than <see cref="M:System.Int32.MaxValue" />.</exception>
  9959. public static IQbservable<int> Range(this IQbservableProvider provider, int start, int count)
  9960. {
  9961. if (provider == null)
  9962. throw new ArgumentNullException("provider");
  9963. return provider.CreateQuery<int>(
  9964. Expression.Call(
  9965. null,
  9966. #if CRIPPLED_REFLECTION
  9967. InfoOf(() => Qbservable.Range(default(IQbservableProvider), default(int), default(int))),
  9968. #else
  9969. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9970. #endif
  9971. Expression.Constant(provider, typeof(IQbservableProvider)),
  9972. Expression.Constant(start, typeof(int)),
  9973. Expression.Constant(count, typeof(int))
  9974. )
  9975. );
  9976. }
  9977. /// <summary>
  9978. /// Generates an observable sequence of integral numbers within a specified range, using the specified scheduler to send out observer messages.
  9979. /// </summary>
  9980. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  9981. /// <param name="start">The value of the first integer in the sequence.</param>
  9982. /// <param name="count">The number of sequential integers to generate.</param>
  9983. /// <param name="scheduler">Scheduler to run the generator loop on.</param>
  9984. /// <returns>An observable sequence that contains a range of sequential integral numbers.</returns>
  9985. /// <exception cref="T:System.ArgumentOutOfRangeException">
  9986. /// <paramref name="count" /> is less than zero. -or- <paramref name="start" /> + <paramref name="count" /> - 1 is larger than <see cref="M:System.Int32.MaxValue" />.</exception>
  9987. /// <exception cref="T:System.ArgumentNullException">
  9988. /// <paramref name="scheduler" /> is null.</exception>
  9989. public static IQbservable<int> Range(this IQbservableProvider provider, int start, int count, IScheduler scheduler)
  9990. {
  9991. if (provider == null)
  9992. throw new ArgumentNullException("provider");
  9993. if (scheduler == null)
  9994. throw new ArgumentNullException("scheduler");
  9995. return provider.CreateQuery<int>(
  9996. Expression.Call(
  9997. null,
  9998. #if CRIPPLED_REFLECTION
  9999. InfoOf(() => Qbservable.Range(default(IQbservableProvider), default(int), default(int), default(IScheduler))),
  10000. #else
  10001. (MethodInfo)MethodInfo.GetCurrentMethod(),
  10002. #endif
  10003. Expression.Constant(provider, typeof(IQbservableProvider)),
  10004. Expression.Constant(start, typeof(int)),
  10005. Expression.Constant(count, typeof(int)),
  10006. Expression.Constant(scheduler, typeof(IScheduler))
  10007. )
  10008. );
  10009. }
  10010. /// <summary>
  10011. /// Returns an observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence.
  10012. /// </summary>
  10013. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10014. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10015. /// <param name="source">Connectable observable sequence.</param>
  10016. /// <returns>An observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence.</returns>
  10017. /// <exception cref="T:System.ArgumentNullException">
  10018. /// <paramref name="source" /> is null.</exception>
  10019. public static IQbservable<TSource> RefCount<TSource>(this IQbservableProvider provider, IConnectableObservable<TSource> source)
  10020. {
  10021. if (provider == null)
  10022. throw new ArgumentNullException("provider");
  10023. if (source == null)
  10024. throw new ArgumentNullException("source");
  10025. return provider.CreateQuery<TSource>(
  10026. Expression.Call(
  10027. null,
  10028. #if CRIPPLED_REFLECTION
  10029. InfoOf(() => Qbservable.RefCount<TSource>(default(IQbservableProvider), default(IConnectableObservable<TSource>))),
  10030. #else
  10031. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10032. #endif
  10033. Expression.Constant(provider, typeof(IQbservableProvider)),
  10034. Expression.Constant(source, typeof(IConnectableObservable<TSource>))
  10035. )
  10036. );
  10037. }
  10038. /// <summary>
  10039. /// Generates an observable sequence that repeats the given element infinitely.
  10040. /// </summary>
  10041. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10042. /// <typeparam name="TResult">The type of the element that will be repeated in the produced sequence.</typeparam>
  10043. /// <param name="value">Element to repeat.</param>
  10044. /// <returns>An observable sequence that repeats the given element infinitely.</returns>
  10045. public static IQbservable<TResult> Repeat<TResult>(this IQbservableProvider provider, TResult value)
  10046. {
  10047. if (provider == null)
  10048. throw new ArgumentNullException("provider");
  10049. return provider.CreateQuery<TResult>(
  10050. Expression.Call(
  10051. null,
  10052. #if CRIPPLED_REFLECTION
  10053. InfoOf(() => Qbservable.Repeat<TResult>(default(IQbservableProvider), default(TResult))),
  10054. #else
  10055. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10056. #endif
  10057. Expression.Constant(provider, typeof(IQbservableProvider)),
  10058. Expression.Constant(value, typeof(TResult))
  10059. )
  10060. );
  10061. }
  10062. /// <summary>
  10063. /// Generates an observable sequence that repeats the given element the specified number of times.
  10064. /// </summary>
  10065. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10066. /// <typeparam name="TResult">The type of the element that will be repeated in the produced sequence.</typeparam>
  10067. /// <param name="value">Element to repeat.</param>
  10068. /// <param name="repeatCount">Number of times to repeat the element.</param>
  10069. /// <returns>An observable sequence that repeats the given element the specified number of times.</returns>
  10070. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10071. /// <paramref name="repeatCount" /> is less than zero.</exception>
  10072. public static IQbservable<TResult> Repeat<TResult>(this IQbservableProvider provider, TResult value, int repeatCount)
  10073. {
  10074. if (provider == null)
  10075. throw new ArgumentNullException("provider");
  10076. return provider.CreateQuery<TResult>(
  10077. Expression.Call(
  10078. null,
  10079. #if CRIPPLED_REFLECTION
  10080. InfoOf(() => Qbservable.Repeat<TResult>(default(IQbservableProvider), default(TResult), default(int))),
  10081. #else
  10082. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10083. #endif
  10084. Expression.Constant(provider, typeof(IQbservableProvider)),
  10085. Expression.Constant(value, typeof(TResult)),
  10086. Expression.Constant(repeatCount, typeof(int))
  10087. )
  10088. );
  10089. }
  10090. /// <summary>
  10091. /// Generates an observable sequence that repeats the given element the specified number of times, using the specified scheduler to send out observer messages.
  10092. /// </summary>
  10093. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10094. /// <typeparam name="TResult">The type of the element that will be repeated in the produced sequence.</typeparam>
  10095. /// <param name="value">Element to repeat.</param>
  10096. /// <param name="repeatCount">Number of times to repeat the element.</param>
  10097. /// <param name="scheduler">Scheduler to run the producer loop on.</param>
  10098. /// <returns>An observable sequence that repeats the given element the specified number of times.</returns>
  10099. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10100. /// <paramref name="repeatCount" /> is less than zero.</exception>
  10101. /// <exception cref="T:System.ArgumentNullException">
  10102. /// <paramref name="scheduler" /> is null.</exception>
  10103. public static IQbservable<TResult> Repeat<TResult>(this IQbservableProvider provider, TResult value, int repeatCount, IScheduler scheduler)
  10104. {
  10105. if (provider == null)
  10106. throw new ArgumentNullException("provider");
  10107. if (scheduler == null)
  10108. throw new ArgumentNullException("scheduler");
  10109. return provider.CreateQuery<TResult>(
  10110. Expression.Call(
  10111. null,
  10112. #if CRIPPLED_REFLECTION
  10113. InfoOf(() => Qbservable.Repeat<TResult>(default(IQbservableProvider), default(TResult), default(int), default(IScheduler))),
  10114. #else
  10115. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10116. #endif
  10117. Expression.Constant(provider, typeof(IQbservableProvider)),
  10118. Expression.Constant(value, typeof(TResult)),
  10119. Expression.Constant(repeatCount, typeof(int)),
  10120. Expression.Constant(scheduler, typeof(IScheduler))
  10121. )
  10122. );
  10123. }
  10124. /// <summary>
  10125. /// Generates an observable sequence that repeats the given element infinitely, using the specified scheduler to send out observer messages.
  10126. /// </summary>
  10127. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10128. /// <typeparam name="TResult">The type of the element that will be repeated in the produced sequence.</typeparam>
  10129. /// <param name="value">Element to repeat.</param>
  10130. /// <param name="scheduler">Scheduler to run the producer loop on.</param>
  10131. /// <returns>An observable sequence that repeats the given element infinitely.</returns>
  10132. /// <exception cref="T:System.ArgumentNullException">
  10133. /// <paramref name="scheduler" /> is null.</exception>
  10134. public static IQbservable<TResult> Repeat<TResult>(this IQbservableProvider provider, TResult value, IScheduler scheduler)
  10135. {
  10136. if (provider == null)
  10137. throw new ArgumentNullException("provider");
  10138. if (scheduler == null)
  10139. throw new ArgumentNullException("scheduler");
  10140. return provider.CreateQuery<TResult>(
  10141. Expression.Call(
  10142. null,
  10143. #if CRIPPLED_REFLECTION
  10144. InfoOf(() => Qbservable.Repeat<TResult>(default(IQbservableProvider), default(TResult), default(IScheduler))),
  10145. #else
  10146. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10147. #endif
  10148. Expression.Constant(provider, typeof(IQbservableProvider)),
  10149. Expression.Constant(value, typeof(TResult)),
  10150. Expression.Constant(scheduler, typeof(IScheduler))
  10151. )
  10152. );
  10153. }
  10154. /// <summary>
  10155. /// Repeats the observable sequence indefinitely.
  10156. /// </summary>
  10157. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10158. /// <param name="source">Observable sequence to repeat.</param>
  10159. /// <returns>The observable sequence producing the elements of the given sequence repeatedly and sequentially.</returns>
  10160. /// <exception cref="T:System.ArgumentNullException">
  10161. /// <paramref name="source" /> is null.</exception>
  10162. public static IQbservable<TSource> Repeat<TSource>(this IQbservable<TSource> source)
  10163. {
  10164. if (source == null)
  10165. throw new ArgumentNullException("source");
  10166. return source.Provider.CreateQuery<TSource>(
  10167. Expression.Call(
  10168. null,
  10169. #if CRIPPLED_REFLECTION
  10170. InfoOf(() => Qbservable.Repeat<TSource>(default(IQbservable<TSource>))),
  10171. #else
  10172. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10173. #endif
  10174. source.Expression
  10175. )
  10176. );
  10177. }
  10178. /// <summary>
  10179. /// Repeats the observable sequence a specified number of times.
  10180. /// </summary>
  10181. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10182. /// <param name="source">Observable sequence to repeat.</param>
  10183. /// <param name="repeatCount">Number of times to repeat the sequence.</param>
  10184. /// <returns>The observable sequence producing the elements of the given sequence repeatedly.</returns>
  10185. /// <exception cref="T:System.ArgumentNullException">
  10186. /// <paramref name="source" /> is null.</exception>
  10187. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10188. /// <paramref name="repeatCount" /> is less than zero.</exception>
  10189. public static IQbservable<TSource> Repeat<TSource>(this IQbservable<TSource> source, int repeatCount)
  10190. {
  10191. if (source == null)
  10192. throw new ArgumentNullException("source");
  10193. return source.Provider.CreateQuery<TSource>(
  10194. Expression.Call(
  10195. null,
  10196. #if CRIPPLED_REFLECTION
  10197. InfoOf(() => Qbservable.Repeat<TSource>(default(IQbservable<TSource>), default(int))),
  10198. #else
  10199. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10200. #endif
  10201. source.Expression,
  10202. Expression.Constant(repeatCount, typeof(int))
  10203. )
  10204. );
  10205. }
  10206. /// <summary>
  10207. /// 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.
  10208. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10209. /// </summary>
  10210. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10211. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10212. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10213. /// <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>
  10214. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10215. /// <exception cref="T:System.ArgumentNullException">
  10216. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10217. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10218. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector)
  10219. {
  10220. if (source == null)
  10221. throw new ArgumentNullException("source");
  10222. if (selector == null)
  10223. throw new ArgumentNullException("selector");
  10224. return source.Provider.CreateQuery<TResult>(
  10225. Expression.Call(
  10226. null,
  10227. #if CRIPPLED_REFLECTION
  10228. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>))),
  10229. #else
  10230. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10231. #endif
  10232. source.Expression,
  10233. selector
  10234. )
  10235. );
  10236. }
  10237. /// <summary>
  10238. /// 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.
  10239. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10240. /// </summary>
  10241. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10242. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10243. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10244. /// <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>
  10245. /// <param name="bufferSize">Maximum element count of the replay buffer.</param>
  10246. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10247. /// <exception cref="T:System.ArgumentNullException">
  10248. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10249. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10250. /// <paramref name="bufferSize" /> is less than zero.</exception>
  10251. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10252. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, int bufferSize)
  10253. {
  10254. if (source == null)
  10255. throw new ArgumentNullException("source");
  10256. if (selector == null)
  10257. throw new ArgumentNullException("selector");
  10258. return source.Provider.CreateQuery<TResult>(
  10259. Expression.Call(
  10260. null,
  10261. #if CRIPPLED_REFLECTION
  10262. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(int))),
  10263. #else
  10264. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10265. #endif
  10266. source.Expression,
  10267. selector,
  10268. Expression.Constant(bufferSize, typeof(int))
  10269. )
  10270. );
  10271. }
  10272. /// <summary>
  10273. /// 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.
  10274. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10275. /// </summary>
  10276. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10277. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10278. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10279. /// <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>
  10280. /// <param name="bufferSize">Maximum element count of the replay buffer.</param>
  10281. /// <param name="scheduler">Scheduler where connected observers within the selector function will be invoked on.</param>
  10282. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10283. /// <exception cref="T:System.ArgumentNullException">
  10284. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="scheduler" /> is null.</exception>
  10285. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10286. /// <paramref name="bufferSize" /> is less than zero.</exception>
  10287. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10288. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, int bufferSize, IScheduler scheduler)
  10289. {
  10290. if (source == null)
  10291. throw new ArgumentNullException("source");
  10292. if (selector == null)
  10293. throw new ArgumentNullException("selector");
  10294. if (scheduler == null)
  10295. throw new ArgumentNullException("scheduler");
  10296. return source.Provider.CreateQuery<TResult>(
  10297. Expression.Call(
  10298. null,
  10299. #if CRIPPLED_REFLECTION
  10300. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(int), default(IScheduler))),
  10301. #else
  10302. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10303. #endif
  10304. source.Expression,
  10305. selector,
  10306. Expression.Constant(bufferSize, typeof(int)),
  10307. Expression.Constant(scheduler, typeof(IScheduler))
  10308. )
  10309. );
  10310. }
  10311. /// <summary>
  10312. /// 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.
  10313. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10314. /// </summary>
  10315. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10316. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10317. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10318. /// <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>
  10319. /// <param name="bufferSize">Maximum element count of the replay buffer.</param>
  10320. /// <param name="window">Maximum time length of the replay buffer.</param>
  10321. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10322. /// <exception cref="T:System.ArgumentNullException">
  10323. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10324. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10325. /// <paramref name="bufferSize" /> is less than zero.</exception>
  10326. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10327. /// <paramref name="window" /> is less than TimeSpan.Zero.</exception>
  10328. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10329. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, int bufferSize, TimeSpan window)
  10330. {
  10331. if (source == null)
  10332. throw new ArgumentNullException("source");
  10333. if (selector == null)
  10334. throw new ArgumentNullException("selector");
  10335. return source.Provider.CreateQuery<TResult>(
  10336. Expression.Call(
  10337. null,
  10338. #if CRIPPLED_REFLECTION
  10339. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(int), default(TimeSpan))),
  10340. #else
  10341. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10342. #endif
  10343. source.Expression,
  10344. selector,
  10345. Expression.Constant(bufferSize, typeof(int)),
  10346. Expression.Constant(window, typeof(TimeSpan))
  10347. )
  10348. );
  10349. }
  10350. /// <summary>
  10351. /// 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.
  10352. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10353. /// </summary>
  10354. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10355. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10356. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10357. /// <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>
  10358. /// <param name="bufferSize">Maximum element count of the replay buffer.</param>
  10359. /// <param name="window">Maximum time length of the replay buffer.</param>
  10360. /// <param name="scheduler">Scheduler where connected observers within the selector function will be invoked on.</param>
  10361. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10362. /// <exception cref="T:System.ArgumentNullException">
  10363. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="scheduler" /> is null.</exception>
  10364. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10365. /// <paramref name="bufferSize" /> is less than zero.</exception>
  10366. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10367. /// <paramref name="window" /> is less than TimeSpan.Zero.</exception>
  10368. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10369. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, int bufferSize, TimeSpan window, IScheduler scheduler)
  10370. {
  10371. if (source == null)
  10372. throw new ArgumentNullException("source");
  10373. if (selector == null)
  10374. throw new ArgumentNullException("selector");
  10375. if (scheduler == null)
  10376. throw new ArgumentNullException("scheduler");
  10377. return source.Provider.CreateQuery<TResult>(
  10378. Expression.Call(
  10379. null,
  10380. #if CRIPPLED_REFLECTION
  10381. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(int), default(TimeSpan), default(IScheduler))),
  10382. #else
  10383. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10384. #endif
  10385. source.Expression,
  10386. selector,
  10387. Expression.Constant(bufferSize, typeof(int)),
  10388. Expression.Constant(window, typeof(TimeSpan)),
  10389. Expression.Constant(scheduler, typeof(IScheduler))
  10390. )
  10391. );
  10392. }
  10393. /// <summary>
  10394. /// 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.
  10395. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10396. /// </summary>
  10397. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10398. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10399. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10400. /// <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>
  10401. /// <param name="scheduler">Scheduler where connected observers within the selector function will be invoked on.</param>
  10402. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10403. /// <exception cref="T:System.ArgumentNullException">
  10404. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="scheduler" /> is null.</exception>
  10405. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10406. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, IScheduler scheduler)
  10407. {
  10408. if (source == null)
  10409. throw new ArgumentNullException("source");
  10410. if (selector == null)
  10411. throw new ArgumentNullException("selector");
  10412. if (scheduler == null)
  10413. throw new ArgumentNullException("scheduler");
  10414. return source.Provider.CreateQuery<TResult>(
  10415. Expression.Call(
  10416. null,
  10417. #if CRIPPLED_REFLECTION
  10418. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(IScheduler))),
  10419. #else
  10420. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10421. #endif
  10422. source.Expression,
  10423. selector,
  10424. Expression.Constant(scheduler, typeof(IScheduler))
  10425. )
  10426. );
  10427. }
  10428. /// <summary>
  10429. /// 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.
  10430. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10431. /// </summary>
  10432. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10433. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10434. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10435. /// <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>
  10436. /// <param name="window">Maximum time length of the replay buffer.</param>
  10437. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10438. /// <exception cref="T:System.ArgumentNullException">
  10439. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10440. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10441. /// <paramref name="window" /> is less than TimeSpan.Zero.</exception>
  10442. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10443. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, TimeSpan window)
  10444. {
  10445. if (source == null)
  10446. throw new ArgumentNullException("source");
  10447. if (selector == null)
  10448. throw new ArgumentNullException("selector");
  10449. return source.Provider.CreateQuery<TResult>(
  10450. Expression.Call(
  10451. null,
  10452. #if CRIPPLED_REFLECTION
  10453. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(TimeSpan))),
  10454. #else
  10455. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10456. #endif
  10457. source.Expression,
  10458. selector,
  10459. Expression.Constant(window, typeof(TimeSpan))
  10460. )
  10461. );
  10462. }
  10463. /// <summary>
  10464. /// 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.
  10465. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10466. /// </summary>
  10467. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10468. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10469. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10470. /// <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>
  10471. /// <param name="window">Maximum time length of the replay buffer.</param>
  10472. /// <param name="scheduler">Scheduler where connected observers within the selector function will be invoked on.</param>
  10473. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10474. /// <exception cref="T:System.ArgumentNullException">
  10475. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="scheduler" /> is null.</exception>
  10476. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10477. /// <paramref name="window" /> is less than TimeSpan.Zero.</exception>
  10478. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10479. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, TimeSpan window, IScheduler scheduler)
  10480. {
  10481. if (source == null)
  10482. throw new ArgumentNullException("source");
  10483. if (selector == null)
  10484. throw new ArgumentNullException("selector");
  10485. if (scheduler == null)
  10486. throw new ArgumentNullException("scheduler");
  10487. return source.Provider.CreateQuery<TResult>(
  10488. Expression.Call(
  10489. null,
  10490. #if CRIPPLED_REFLECTION
  10491. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(TimeSpan), default(IScheduler))),
  10492. #else
  10493. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10494. #endif
  10495. source.Expression,
  10496. selector,
  10497. Expression.Constant(window, typeof(TimeSpan)),
  10498. Expression.Constant(scheduler, typeof(IScheduler))
  10499. )
  10500. );
  10501. }
  10502. /// <summary>
  10503. /// Repeats the source observable sequence until it successfully terminates.
  10504. /// </summary>
  10505. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10506. /// <param name="source">Observable sequence to repeat until it successfully terminates.</param>
  10507. /// <returns>An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.</returns>
  10508. /// <exception cref="T:System.ArgumentNullException">
  10509. /// <paramref name="source" /> is null.</exception>
  10510. public static IQbservable<TSource> Retry<TSource>(this IQbservable<TSource> source)
  10511. {
  10512. if (source == null)
  10513. throw new ArgumentNullException("source");
  10514. return source.Provider.CreateQuery<TSource>(
  10515. Expression.Call(
  10516. null,
  10517. #if CRIPPLED_REFLECTION
  10518. InfoOf(() => Qbservable.Retry<TSource>(default(IQbservable<TSource>))),
  10519. #else
  10520. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10521. #endif
  10522. source.Expression
  10523. )
  10524. );
  10525. }
  10526. /// <summary>
  10527. /// Repeats the source observable sequence the specified number of times or until it successfully terminates.
  10528. /// </summary>
  10529. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10530. /// <param name="source">Observable sequence to repeat until it successfully terminates.</param>
  10531. /// <param name="retryCount">Number of times to repeat the sequence.</param>
  10532. /// <returns>An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.</returns>
  10533. /// <exception cref="T:System.ArgumentNullException">
  10534. /// <paramref name="source" /> is null.</exception>
  10535. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10536. /// <paramref name="retryCount" /> is less than zero.</exception>
  10537. public static IQbservable<TSource> Retry<TSource>(this IQbservable<TSource> source, int retryCount)
  10538. {
  10539. if (source == null)
  10540. throw new ArgumentNullException("source");
  10541. return source.Provider.CreateQuery<TSource>(
  10542. Expression.Call(
  10543. null,
  10544. #if CRIPPLED_REFLECTION
  10545. InfoOf(() => Qbservable.Retry<TSource>(default(IQbservable<TSource>), default(int))),
  10546. #else
  10547. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10548. #endif
  10549. source.Expression,
  10550. Expression.Constant(retryCount, typeof(int))
  10551. )
  10552. );
  10553. }
  10554. /// <summary>
  10555. /// Returns an observable sequence that contains a single element.
  10556. /// </summary>
  10557. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10558. /// <typeparam name="TResult">The type of the element that will be returned in the produced sequence.</typeparam>
  10559. /// <param name="value">Single element in the resulting observable sequence.</param>
  10560. /// <returns>An observable sequence containing the single specified element.</returns>
  10561. public static IQbservable<TResult> Return<TResult>(this IQbservableProvider provider, TResult value)
  10562. {
  10563. if (provider == null)
  10564. throw new ArgumentNullException("provider");
  10565. return provider.CreateQuery<TResult>(
  10566. Expression.Call(
  10567. null,
  10568. #if CRIPPLED_REFLECTION
  10569. InfoOf(() => Qbservable.Return<TResult>(default(IQbservableProvider), default(TResult))),
  10570. #else
  10571. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10572. #endif
  10573. Expression.Constant(provider, typeof(IQbservableProvider)),
  10574. Expression.Constant(value, typeof(TResult))
  10575. )
  10576. );
  10577. }
  10578. /// <summary>
  10579. /// Returns an observable sequence that contains a single element, using the specified scheduler to send out observer messages.
  10580. /// </summary>
  10581. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10582. /// <typeparam name="TResult">The type of the element that will be returned in the produced sequence.</typeparam>
  10583. /// <param name="value">Single element in the resulting observable sequence.</param>
  10584. /// <param name="scheduler">Scheduler to send the single element on.</param>
  10585. /// <returns>An observable sequence containing the single specified element.</returns>
  10586. /// <exception cref="T:System.ArgumentNullException">
  10587. /// <paramref name="scheduler" /> is null.</exception>
  10588. public static IQbservable<TResult> Return<TResult>(this IQbservableProvider provider, TResult value, IScheduler scheduler)
  10589. {
  10590. if (provider == null)
  10591. throw new ArgumentNullException("provider");
  10592. if (scheduler == null)
  10593. throw new ArgumentNullException("scheduler");
  10594. return provider.CreateQuery<TResult>(
  10595. Expression.Call(
  10596. null,
  10597. #if CRIPPLED_REFLECTION
  10598. InfoOf(() => Qbservable.Return<TResult>(default(IQbservableProvider), default(TResult), default(IScheduler))),
  10599. #else
  10600. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10601. #endif
  10602. Expression.Constant(provider, typeof(IQbservableProvider)),
  10603. Expression.Constant(value, typeof(TResult)),
  10604. Expression.Constant(scheduler, typeof(IScheduler))
  10605. )
  10606. );
  10607. }
  10608. /// <summary>
  10609. /// Samples the observable sequence at each interval.
  10610. /// Upon each sampling tick, the latest element (if any) in the source sequence during the last sampling interval is sent to the resulting sequence.
  10611. /// </summary>
  10612. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10613. /// <param name="source">Source sequence to sample.</param>
  10614. /// <param name="interval">Interval at which to sample. If this value is equal to TimeSpan.Zero, the scheduler will continuously sample the stream.</param>
  10615. /// <returns>Sampled observable sequence.</returns>
  10616. /// <exception cref="T:System.ArgumentNullException">
  10617. /// <paramref name="source" /> is null.</exception>
  10618. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10619. /// <paramref name="interval" /> is less than TimeSpan.Zero.</exception>
  10620. /// <remarks>
  10621. /// Specifying a TimeSpan.Zero value for <paramref name="interval" /> doesn't guarantee all source sequence elements will be preserved. This is a side-effect
  10622. /// of the asynchrony introduced by the scheduler, where the sampling action may not execute immediately, despite the TimeSpan.Zero due time.
  10623. /// </remarks>
  10624. public static IQbservable<TSource> Sample<TSource>(this IQbservable<TSource> source, TimeSpan interval)
  10625. {
  10626. if (source == null)
  10627. throw new ArgumentNullException("source");
  10628. return source.Provider.CreateQuery<TSource>(
  10629. Expression.Call(
  10630. null,
  10631. #if CRIPPLED_REFLECTION
  10632. InfoOf(() => Qbservable.Sample<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  10633. #else
  10634. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10635. #endif
  10636. source.Expression,
  10637. Expression.Constant(interval, typeof(TimeSpan))
  10638. )
  10639. );
  10640. }
  10641. /// <summary>
  10642. /// Samples the observable sequence at each interval, using the specified scheduler to run sampling timers.
  10643. /// Upon each sampling tick, the latest element (if any) in the source sequence during the last sampling interval is sent to the resulting sequence.
  10644. /// </summary>
  10645. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10646. /// <param name="source">Source sequence to sample.</param>
  10647. /// <param name="interval">Interval at which to sample. If this value is equal to TimeSpan.Zero, the scheduler will continuously sample the stream.</param>
  10648. /// <param name="scheduler">Scheduler to run the sampling timer on.</param>
  10649. /// <returns>Sampled observable sequence.</returns>
  10650. /// <exception cref="T:System.ArgumentNullException">
  10651. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  10652. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10653. /// <paramref name="interval" /> is less than TimeSpan.Zero.</exception>
  10654. /// <remarks>
  10655. /// Specifying a TimeSpan.Zero value for <paramref name="interval" /> doesn't guarantee all source sequence elements will be preserved. This is a side-effect
  10656. /// of the asynchrony introduced by the scheduler, where the sampling action may not execute immediately, despite the TimeSpan.Zero due time.
  10657. /// </remarks>
  10658. public static IQbservable<TSource> Sample<TSource>(this IQbservable<TSource> source, TimeSpan interval, IScheduler scheduler)
  10659. {
  10660. if (source == null)
  10661. throw new ArgumentNullException("source");
  10662. if (scheduler == null)
  10663. throw new ArgumentNullException("scheduler");
  10664. return source.Provider.CreateQuery<TSource>(
  10665. Expression.Call(
  10666. null,
  10667. #if CRIPPLED_REFLECTION
  10668. InfoOf(() => Qbservable.Sample<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  10669. #else
  10670. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10671. #endif
  10672. source.Expression,
  10673. Expression.Constant(interval, typeof(TimeSpan)),
  10674. Expression.Constant(scheduler, typeof(IScheduler))
  10675. )
  10676. );
  10677. }
  10678. /// <summary>
  10679. /// Samples the source observable sequence using a samper observable sequence producing sampling ticks.
  10680. /// Upon each sampling tick, the latest element (if any) in the source sequence during the last sampling interval is sent to the resulting sequence.
  10681. /// </summary>
  10682. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10683. /// <typeparam name="TSample">The type of the elements in the sampling sequence.</typeparam>
  10684. /// <param name="source">Source sequence to sample.</param>
  10685. /// <param name="sampler">Sampling tick sequence.</param>
  10686. /// <returns>Sampled observable sequence.</returns>
  10687. /// <exception cref="T:System.ArgumentNullException">
  10688. /// <paramref name="source" /> or <paramref name="sampler" /> is null.</exception>
  10689. public static IQbservable<TSource> Sample<TSource, TSample>(this IQbservable<TSource> source, IObservable<TSample> sampler)
  10690. {
  10691. if (source == null)
  10692. throw new ArgumentNullException("source");
  10693. if (sampler == null)
  10694. throw new ArgumentNullException("sampler");
  10695. return source.Provider.CreateQuery<TSource>(
  10696. Expression.Call(
  10697. null,
  10698. #if CRIPPLED_REFLECTION
  10699. InfoOf(() => Qbservable.Sample<TSource, TSample>(default(IQbservable<TSource>), default(IObservable<TSample>))),
  10700. #else
  10701. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TSample)),
  10702. #endif
  10703. source.Expression,
  10704. GetSourceExpression(sampler)
  10705. )
  10706. );
  10707. }
  10708. /// <summary>
  10709. /// Applies an accumulator function over an observable sequence and returns each intermediate result.
  10710. /// For aggregation behavior with no intermediate results, see <see cref="M:System.Reactive.Linq.Observable.Aggregate``1(System.IObservable{``0},System.Func{``0,``0,``0})" />.
  10711. /// </summary>
  10712. /// <typeparam name="TSource">The type of the elements in the source sequence and the result of the aggregation.</typeparam>
  10713. /// <param name="source">An observable sequence to accumulate over.</param>
  10714. /// <param name="accumulator">An accumulator function to be invoked on each element.</param>
  10715. /// <returns>An observable sequence containing the accumulated values.</returns>
  10716. /// <exception cref="T:System.ArgumentNullException">
  10717. /// <paramref name="source" /> or <paramref name="accumulator" /> is null.</exception>
  10718. public static IQbservable<TSource> Scan<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, TSource, TSource>> accumulator)
  10719. {
  10720. if (source == null)
  10721. throw new ArgumentNullException("source");
  10722. if (accumulator == null)
  10723. throw new ArgumentNullException("accumulator");
  10724. return source.Provider.CreateQuery<TSource>(
  10725. Expression.Call(
  10726. null,
  10727. #if CRIPPLED_REFLECTION
  10728. InfoOf(() => Qbservable.Scan<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, TSource, TSource>>))),
  10729. #else
  10730. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10731. #endif
  10732. source.Expression,
  10733. accumulator
  10734. )
  10735. );
  10736. }
  10737. /// <summary>
  10738. /// Applies an accumulator function over an observable sequence and returns each intermediate result. The specified seed value is used as the initial accumulator value.
  10739. /// For aggregation behavior with no intermediate results, see <see cref="M:System.Reactive.Linq.Observable.Aggregate``2(System.IObservable{``0},``1,System.Func{``1,``0,``1})" />.
  10740. /// </summary>
  10741. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10742. /// <typeparam name="TAccumulate">The type of the result of the aggregation.</typeparam>
  10743. /// <param name="source">An observable sequence to accumulate over.</param>
  10744. /// <param name="seed">The initial accumulator value.</param>
  10745. /// <param name="accumulator">An accumulator function to be invoked on each element.</param>
  10746. /// <returns>An observable sequence containing the accumulated values.</returns>
  10747. /// <exception cref="T:System.ArgumentNullException">
  10748. /// <paramref name="source" /> or <paramref name="accumulator" /> is null.</exception>
  10749. public static IQbservable<TAccumulate> Scan<TSource, TAccumulate>(this IQbservable<TSource> source, TAccumulate seed, Expression<Func<TAccumulate, TSource, TAccumulate>> accumulator)
  10750. {
  10751. if (source == null)
  10752. throw new ArgumentNullException("source");
  10753. if (accumulator == null)
  10754. throw new ArgumentNullException("accumulator");
  10755. return source.Provider.CreateQuery<TAccumulate>(
  10756. Expression.Call(
  10757. null,
  10758. #if CRIPPLED_REFLECTION
  10759. InfoOf(() => Qbservable.Scan<TSource, TAccumulate>(default(IQbservable<TSource>), default(TAccumulate), default(Expression<Func<TAccumulate, TSource, TAccumulate>>))),
  10760. #else
  10761. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)),
  10762. #endif
  10763. source.Expression,
  10764. Expression.Constant(seed, typeof(TAccumulate)),
  10765. accumulator
  10766. )
  10767. );
  10768. }
  10769. /// <summary>
  10770. /// Projects each element of an observable sequence into a new form.
  10771. /// </summary>
  10772. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10773. /// <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>
  10774. /// <param name="source">A sequence of elements to invoke a transform function on.</param>
  10775. /// <param name="selector">A transform function to apply to each source element.</param>
  10776. /// <returns>An observable sequence whose elements are the result of invoking the transform function on each element of source.</returns>
  10777. /// <exception cref="T:System.ArgumentNullException">
  10778. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10779. public static IQbservable<TResult> Select<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector)
  10780. {
  10781. if (source == null)
  10782. throw new ArgumentNullException("source");
  10783. if (selector == null)
  10784. throw new ArgumentNullException("selector");
  10785. return source.Provider.CreateQuery<TResult>(
  10786. Expression.Call(
  10787. null,
  10788. #if CRIPPLED_REFLECTION
  10789. InfoOf(() => Qbservable.Select<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>))),
  10790. #else
  10791. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10792. #endif
  10793. source.Expression,
  10794. selector
  10795. )
  10796. );
  10797. }
  10798. /// <summary>
  10799. /// Projects each element of an observable sequence into a new form by incorporating the element's index.
  10800. /// </summary>
  10801. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10802. /// <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>
  10803. /// <param name="source">A sequence of elements to invoke a transform function on.</param>
  10804. /// <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>
  10805. /// <returns>An observable sequence whose elements are the result of invoking the transform function on each element of source.</returns>
  10806. /// <exception cref="T:System.ArgumentNullException">
  10807. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10808. public static IQbservable<TResult> Select<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, TResult>> selector)
  10809. {
  10810. if (source == null)
  10811. throw new ArgumentNullException("source");
  10812. if (selector == null)
  10813. throw new ArgumentNullException("selector");
  10814. return source.Provider.CreateQuery<TResult>(
  10815. Expression.Call(
  10816. null,
  10817. #if CRIPPLED_REFLECTION
  10818. InfoOf(() => Qbservable.Select<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, TResult>>))),
  10819. #else
  10820. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10821. #endif
  10822. source.Expression,
  10823. selector
  10824. )
  10825. );
  10826. }
  10827. /// <summary>
  10828. /// 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.
  10829. /// </summary>
  10830. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10831. /// <typeparam name="TCollection">The type of the elements in the projected intermediate sequences.</typeparam>
  10832. /// <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>
  10833. /// <param name="source">An observable sequence of elements to project.</param>
  10834. /// <param name="collectionSelector">A transform function to apply to each element.</param>
  10835. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
  10836. /// <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>
  10837. /// <exception cref="T:System.ArgumentNullException">
  10838. /// <paramref name="source" /> or <paramref name="collectionSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  10839. public static IQbservable<TResult> SelectMany<TSource, TCollection, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TCollection>>> collectionSelector, Expression<Func<TSource, TCollection, TResult>> resultSelector)
  10840. {
  10841. if (source == null)
  10842. throw new ArgumentNullException("source");
  10843. if (collectionSelector == null)
  10844. throw new ArgumentNullException("collectionSelector");
  10845. if (resultSelector == null)
  10846. throw new ArgumentNullException("resultSelector");
  10847. return source.Provider.CreateQuery<TResult>(
  10848. Expression.Call(
  10849. null,
  10850. #if CRIPPLED_REFLECTION
  10851. InfoOf(() => Qbservable.SelectMany<TSource, TCollection, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TCollection>>>), default(Expression<Func<TSource, TCollection, TResult>>))),
  10852. #else
  10853. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)),
  10854. #endif
  10855. source.Expression,
  10856. collectionSelector,
  10857. resultSelector
  10858. )
  10859. );
  10860. }
  10861. /// <summary>
  10862. /// 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.
  10863. /// </summary>
  10864. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10865. /// <typeparam name="TCollection">The type of the elements in the projected intermediate sequences.</typeparam>
  10866. /// <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>
  10867. /// <param name="source">An observable sequence of elements to project.</param>
  10868. /// <param name="collectionSelector">A transform function to apply to each source element; the second parameter of the function represents the index of the source element.</param>
  10869. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
  10870. /// <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>
  10871. /// <exception cref="T:System.ArgumentNullException">
  10872. /// <paramref name="source" /> or <paramref name="collectionSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  10873. 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)
  10874. {
  10875. if (source == null)
  10876. throw new ArgumentNullException("source");
  10877. if (collectionSelector == null)
  10878. throw new ArgumentNullException("collectionSelector");
  10879. if (resultSelector == null)
  10880. throw new ArgumentNullException("resultSelector");
  10881. return source.Provider.CreateQuery<TResult>(
  10882. Expression.Call(
  10883. null,
  10884. #if CRIPPLED_REFLECTION
  10885. InfoOf(() => Qbservable.SelectMany<TSource, TCollection, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, IObservable<TCollection>>>), default(Expression<Func<TSource, int, TCollection, int, TResult>>))),
  10886. #else
  10887. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)),
  10888. #endif
  10889. source.Expression,
  10890. collectionSelector,
  10891. resultSelector
  10892. )
  10893. );
  10894. }
  10895. /// <summary>
  10896. /// 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.
  10897. /// </summary>
  10898. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10899. /// <typeparam name="TCollection">The type of the elements in the projected intermediate enumerable sequences.</typeparam>
  10900. /// <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>
  10901. /// <param name="source">An observable sequence of elements to project.</param>
  10902. /// <param name="collectionSelector">A transform function to apply to each element.</param>
  10903. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
  10904. /// <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>
  10905. /// <exception cref="T:System.ArgumentNullException">
  10906. /// <paramref name="source" /> or <paramref name="collectionSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  10907. /// <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="M:System.Reactive.Linq.Observable.ToObservable``1(System.Collections.Generic.IEnumerable{``0})" /> conversion.</remarks>
  10908. public static IQbservable<TResult> SelectMany<TSource, TCollection, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, IEnumerable<TCollection>>> collectionSelector, Expression<Func<TSource, TCollection, TResult>> resultSelector)
  10909. {
  10910. if (source == null)
  10911. throw new ArgumentNullException("source");
  10912. if (collectionSelector == null)
  10913. throw new ArgumentNullException("collectionSelector");
  10914. if (resultSelector == null)
  10915. throw new ArgumentNullException("resultSelector");
  10916. return source.Provider.CreateQuery<TResult>(
  10917. Expression.Call(
  10918. null,
  10919. #if CRIPPLED_REFLECTION
  10920. InfoOf(() => Qbservable.SelectMany<TSource, TCollection, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, IEnumerable<TCollection>>>), default(Expression<Func<TSource, TCollection, TResult>>))),
  10921. #else
  10922. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)),
  10923. #endif
  10924. source.Expression,
  10925. collectionSelector,
  10926. resultSelector
  10927. )
  10928. );
  10929. }
  10930. /// <summary>
  10931. /// 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.
  10932. /// </summary>
  10933. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10934. /// <typeparam name="TCollection">The type of the elements in the projected intermediate enumerable sequences.</typeparam>
  10935. /// <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>
  10936. /// <param name="source">An observable sequence of elements to project.</param>
  10937. /// <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>
  10938. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
  10939. /// <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>
  10940. /// <exception cref="T:System.ArgumentNullException">
  10941. /// <paramref name="source" /> or <paramref name="collectionSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  10942. /// <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="M:System.Reactive.Linq.Observable.ToObservable``1(System.Collections.Generic.IEnumerable{``0})" /> conversion.</remarks>
  10943. 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)
  10944. {
  10945. if (source == null)
  10946. throw new ArgumentNullException("source");
  10947. if (collectionSelector == null)
  10948. throw new ArgumentNullException("collectionSelector");
  10949. if (resultSelector == null)
  10950. throw new ArgumentNullException("resultSelector");
  10951. return source.Provider.CreateQuery<TResult>(
  10952. Expression.Call(
  10953. null,
  10954. #if CRIPPLED_REFLECTION
  10955. InfoOf(() => Qbservable.SelectMany<TSource, TCollection, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, IEnumerable<TCollection>>>), default(Expression<Func<TSource, int, TCollection, int, TResult>>))),
  10956. #else
  10957. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)),
  10958. #endif
  10959. source.Expression,
  10960. collectionSelector,
  10961. resultSelector
  10962. )
  10963. );
  10964. }
  10965. /// <summary>
  10966. /// Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
  10967. /// </summary>
  10968. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10969. /// <typeparam name="TOther">The type of the elements in the other sequence and the elements in the result sequence.</typeparam>
  10970. /// <param name="source">An observable sequence of elements to project.</param>
  10971. /// <param name="other">An observable sequence to project each element from the source sequence onto.</param>
  10972. /// <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>
  10973. /// <exception cref="T:System.ArgumentNullException">
  10974. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  10975. public static IQbservable<TOther> SelectMany<TSource, TOther>(this IQbservable<TSource> source, IObservable<TOther> other)
  10976. {
  10977. if (source == null)
  10978. throw new ArgumentNullException("source");
  10979. if (other == null)
  10980. throw new ArgumentNullException("other");
  10981. return source.Provider.CreateQuery<TOther>(
  10982. Expression.Call(
  10983. null,
  10984. #if CRIPPLED_REFLECTION
  10985. InfoOf(() => Qbservable.SelectMany<TSource, TOther>(default(IQbservable<TSource>), default(IObservable<TOther>))),
  10986. #else
  10987. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)),
  10988. #endif
  10989. source.Expression,
  10990. GetSourceExpression(other)
  10991. )
  10992. );
  10993. }
  10994. /// <summary>
  10995. /// Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  10996. /// </summary>
  10997. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10998. /// <typeparam name="TResult">The type of the elements in the projected inner sequences and the elements in the merged result sequence.</typeparam>
  10999. /// <param name="source">An observable sequence of notifications to project.</param>
  11000. /// <param name="onNext">A transform function to apply to each element.</param>
  11001. /// <param name="onError">A transform function to apply when an error occurs in the source sequence.</param>
  11002. /// <param name="onCompleted">A transform function to apply when the end of the source sequence is reached.</param>
  11003. /// <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>
  11004. /// <exception cref="T:System.ArgumentNullException">
  11005. /// <paramref name="source" /> or <paramref name="onNext" /> or <paramref name="onError" /> or <paramref name="onCompleted" /> is null.</exception>
  11006. 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)
  11007. {
  11008. if (source == null)
  11009. throw new ArgumentNullException("source");
  11010. if (onNext == null)
  11011. throw new ArgumentNullException("onNext");
  11012. if (onError == null)
  11013. throw new ArgumentNullException("onError");
  11014. if (onCompleted == null)
  11015. throw new ArgumentNullException("onCompleted");
  11016. return source.Provider.CreateQuery<TResult>(
  11017. Expression.Call(
  11018. null,
  11019. #if CRIPPLED_REFLECTION
  11020. 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>>>))),
  11021. #else
  11022. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11023. #endif
  11024. source.Expression,
  11025. onNext,
  11026. onError,
  11027. onCompleted
  11028. )
  11029. );
  11030. }
  11031. /// <summary>
  11032. /// Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  11033. /// </summary>
  11034. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11035. /// <typeparam name="TResult">The type of the elements in the projected inner sequences and the elements in the merged result sequence.</typeparam>
  11036. /// <param name="source">An observable sequence of notifications to project.</param>
  11037. /// <param name="onNext">A transform function to apply to each element; the second parameter represents the index of the source element.</param>
  11038. /// <param name="onError">A transform function to apply when an error occurs in the source sequence; the second parameter represents the index of the source element.</param>
  11039. /// <param name="onCompleted">A transform function to apply when the end of the source sequence is reached; the second parameter represents the number of elements observed.</param>
  11040. /// <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>
  11041. /// <exception cref="T:System.ArgumentNullException">
  11042. /// <paramref name="source" /> or <paramref name="onNext" /> or <paramref name="onError" /> or <paramref name="onCompleted" /> is null.</exception>
  11043. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, IObservable<TResult>>> onNext, Expression<Func<Exception, int, IObservable<TResult>>> onError, Expression<Func<int, IObservable<TResult>>> onCompleted)
  11044. {
  11045. if (source == null)
  11046. throw new ArgumentNullException("source");
  11047. if (onNext == null)
  11048. throw new ArgumentNullException("onNext");
  11049. if (onError == null)
  11050. throw new ArgumentNullException("onError");
  11051. if (onCompleted == null)
  11052. throw new ArgumentNullException("onCompleted");
  11053. return source.Provider.CreateQuery<TResult>(
  11054. Expression.Call(
  11055. null,
  11056. #if CRIPPLED_REFLECTION
  11057. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, IObservable<TResult>>>), default(Expression<Func<Exception, int, IObservable<TResult>>>), default(Expression<Func<int, IObservable<TResult>>>))),
  11058. #else
  11059. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11060. #endif
  11061. source.Expression,
  11062. onNext,
  11063. onError,
  11064. onCompleted
  11065. )
  11066. );
  11067. }
  11068. /// <summary>
  11069. /// Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  11070. /// </summary>
  11071. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11072. /// <typeparam name="TResult">The type of the elements in the projected inner sequences and the elements in the merged result sequence.</typeparam>
  11073. /// <param name="source">An observable sequence of elements to project.</param>
  11074. /// <param name="selector">A transform function to apply to each element.</param>
  11075. /// <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>
  11076. /// <exception cref="T:System.ArgumentNullException">
  11077. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11078. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TResult>>> selector)
  11079. {
  11080. if (source == null)
  11081. throw new ArgumentNullException("source");
  11082. if (selector == null)
  11083. throw new ArgumentNullException("selector");
  11084. return source.Provider.CreateQuery<TResult>(
  11085. Expression.Call(
  11086. null,
  11087. #if CRIPPLED_REFLECTION
  11088. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TResult>>>))),
  11089. #else
  11090. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11091. #endif
  11092. source.Expression,
  11093. selector
  11094. )
  11095. );
  11096. }
  11097. /// <summary>
  11098. /// Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  11099. /// </summary>
  11100. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11101. /// <typeparam name="TResult">The type of the elements in the projected inner sequences and the elements in the merged result sequence.</typeparam>
  11102. /// <param name="source">An observable sequence of elements to project.</param>
  11103. /// <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>
  11104. /// <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>
  11105. /// <exception cref="T:System.ArgumentNullException">
  11106. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11107. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, IObservable<TResult>>> selector)
  11108. {
  11109. if (source == null)
  11110. throw new ArgumentNullException("source");
  11111. if (selector == null)
  11112. throw new ArgumentNullException("selector");
  11113. return source.Provider.CreateQuery<TResult>(
  11114. Expression.Call(
  11115. null,
  11116. #if CRIPPLED_REFLECTION
  11117. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, IObservable<TResult>>>))),
  11118. #else
  11119. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11120. #endif
  11121. source.Expression,
  11122. selector
  11123. )
  11124. );
  11125. }
  11126. #if !NO_TPL
  11127. /// <summary>
  11128. /// Projects each element of an observable sequence to a task and merges all of the task results into one observable sequence.
  11129. /// </summary>
  11130. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11131. /// <typeparam name="TResult">The type of the result produced by the projected tasks and the elements in the merged result sequence.</typeparam>
  11132. /// <param name="source">An observable sequence of elements to project.</param>
  11133. /// <param name="selector">A transform function to apply to each element.</param>
  11134. /// <returns>An observable sequence whose elements are the result of the tasks executed for each element of the input sequence.</returns>
  11135. /// <remarks>This overload supports composition of observable sequences and tasks, without requiring manual conversion of the tasks to observable sequences using <see cref="M:System.Reactive.Threading.Tasks.TaskObservableExtensions.ToObservable``1(System.Threading.Tasks.Task{``0})" />.</remarks>
  11136. /// <exception cref="T:System.ArgumentNullException">
  11137. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11138. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, Task<TResult>>> selector)
  11139. {
  11140. if (source == null)
  11141. throw new ArgumentNullException("source");
  11142. if (selector == null)
  11143. throw new ArgumentNullException("selector");
  11144. return source.Provider.CreateQuery<TResult>(
  11145. Expression.Call(
  11146. null,
  11147. #if CRIPPLED_REFLECTION
  11148. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, Task<TResult>>>))),
  11149. #else
  11150. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11151. #endif
  11152. source.Expression,
  11153. selector
  11154. )
  11155. );
  11156. }
  11157. #endif
  11158. #if !NO_TPL
  11159. /// <summary>
  11160. /// Projects each element of an observable sequence to a task with cancellation support and merges all of the task results into one observable sequence.
  11161. /// </summary>
  11162. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11163. /// <typeparam name="TResult">The type of the result produced by the projected tasks and the elements in the merged result sequence.</typeparam>
  11164. /// <param name="source">An observable sequence of elements to project.</param>
  11165. /// <param name="selector">A transform function to apply to each element.</param>
  11166. /// <returns>An observable sequence whose elements are the result of the tasks executed for each element of the input sequence.</returns>
  11167. /// <remarks>This overload supports composition of observable sequences and tasks, without requiring manual conversion of the tasks to observable sequences using <see cref="M:System.Reactive.Threading.Tasks.TaskObservableExtensions.ToObservable``1(System.Threading.Tasks.Task{``0})" />.</remarks>
  11168. /// <exception cref="T:System.ArgumentNullException">
  11169. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11170. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, CancellationToken, Task<TResult>>> selector)
  11171. {
  11172. if (source == null)
  11173. throw new ArgumentNullException("source");
  11174. if (selector == null)
  11175. throw new ArgumentNullException("selector");
  11176. return source.Provider.CreateQuery<TResult>(
  11177. Expression.Call(
  11178. null,
  11179. #if CRIPPLED_REFLECTION
  11180. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, CancellationToken, Task<TResult>>>))),
  11181. #else
  11182. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11183. #endif
  11184. source.Expression,
  11185. selector
  11186. )
  11187. );
  11188. }
  11189. #endif
  11190. /// <summary>
  11191. /// Projects each element of an observable sequence to an enumerable sequence and concatenates the resulting enumerable sequences into one observable sequence.
  11192. /// </summary>
  11193. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11194. /// <typeparam name="TResult">The type of the elements in the projected inner enumerable sequences and the elements in the merged result sequence.</typeparam>
  11195. /// <param name="source">An observable sequence of elements to project.</param>
  11196. /// <param name="selector">A transform function to apply to each element.</param>
  11197. /// <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>
  11198. /// <exception cref="T:System.ArgumentNullException">
  11199. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11200. /// <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="M:System.Reactive.Linq.Observable.ToObservable``1(System.Collections.Generic.IEnumerable{``0})" /> conversion.</remarks>
  11201. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, IEnumerable<TResult>>> selector)
  11202. {
  11203. if (source == null)
  11204. throw new ArgumentNullException("source");
  11205. if (selector == null)
  11206. throw new ArgumentNullException("selector");
  11207. return source.Provider.CreateQuery<TResult>(
  11208. Expression.Call(
  11209. null,
  11210. #if CRIPPLED_REFLECTION
  11211. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, IEnumerable<TResult>>>))),
  11212. #else
  11213. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11214. #endif
  11215. source.Expression,
  11216. selector
  11217. )
  11218. );
  11219. }
  11220. /// <summary>
  11221. /// Projects each element of an observable sequence to an enumerable sequence and concatenates the resulting enumerable sequences into one observable sequence.
  11222. /// The index of each source element is used in the projected form of that element.
  11223. /// </summary>
  11224. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11225. /// <typeparam name="TResult">The type of the elements in the projected inner enumerable sequences and the elements in the merged result sequence.</typeparam>
  11226. /// <param name="source">An observable sequence of elements to project.</param>
  11227. /// <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>
  11228. /// <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>
  11229. /// <exception cref="T:System.ArgumentNullException">
  11230. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11231. /// <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="M:System.Reactive.Linq.Observable.ToObservable``1(System.Collections.Generic.IEnumerable{``0})" /> conversion.</remarks>
  11232. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, IEnumerable<TResult>>> selector)
  11233. {
  11234. if (source == null)
  11235. throw new ArgumentNullException("source");
  11236. if (selector == null)
  11237. throw new ArgumentNullException("selector");
  11238. return source.Provider.CreateQuery<TResult>(
  11239. Expression.Call(
  11240. null,
  11241. #if CRIPPLED_REFLECTION
  11242. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, IEnumerable<TResult>>>))),
  11243. #else
  11244. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11245. #endif
  11246. source.Expression,
  11247. selector
  11248. )
  11249. );
  11250. }
  11251. #if !NO_TPL
  11252. /// <summary>
  11253. /// 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.
  11254. /// </summary>
  11255. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11256. /// <typeparam name="TTaskResult">The type of the results produced by the projected intermediate tasks.</typeparam>
  11257. /// <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>
  11258. /// <param name="source">An observable sequence of elements to project.</param>
  11259. /// <param name="taskSelector">A transform function to apply to each element.</param>
  11260. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
  11261. /// <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>
  11262. /// <exception cref="T:System.ArgumentNullException">
  11263. /// <paramref name="source" /> or <paramref name="taskSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11264. /// <remarks>This overload supports using LINQ query comprehension syntax in C# and Visual Basic to compose observable sequences and tasks, without requiring manual conversion of the tasks to observable sequences using <see cref="M:System.Reactive.Threading.Tasks.TaskObservableExtensions.ToObservable``1(System.Threading.Tasks.Task{``0})" />.</remarks>
  11265. public static IQbservable<TResult> SelectMany<TSource, TTaskResult, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, Task<TTaskResult>>> taskSelector, Expression<Func<TSource, TTaskResult, TResult>> resultSelector)
  11266. {
  11267. if (source == null)
  11268. throw new ArgumentNullException("source");
  11269. if (taskSelector == null)
  11270. throw new ArgumentNullException("taskSelector");
  11271. if (resultSelector == null)
  11272. throw new ArgumentNullException("resultSelector");
  11273. return source.Provider.CreateQuery<TResult>(
  11274. Expression.Call(
  11275. null,
  11276. #if CRIPPLED_REFLECTION
  11277. InfoOf(() => Qbservable.SelectMany<TSource, TTaskResult, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, Task<TTaskResult>>>), default(Expression<Func<TSource, TTaskResult, TResult>>))),
  11278. #else
  11279. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTaskResult), typeof(TResult)),
  11280. #endif
  11281. source.Expression,
  11282. taskSelector,
  11283. resultSelector
  11284. )
  11285. );
  11286. }
  11287. #endif
  11288. #if !NO_TPL
  11289. /// <summary>
  11290. /// 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.
  11291. /// </summary>
  11292. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11293. /// <typeparam name="TTaskResult">The type of the results produced by the projected intermediate tasks.</typeparam>
  11294. /// <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>
  11295. /// <param name="source">An observable sequence of elements to project.</param>
  11296. /// <param name="taskSelector">A transform function to apply to each element.</param>
  11297. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
  11298. /// <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>
  11299. /// <exception cref="T:System.ArgumentNullException">
  11300. /// <paramref name="source" /> or <paramref name="taskSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11301. /// <remarks>This overload supports using LINQ query comprehension syntax in C# and Visual Basic to compose observable sequences and tasks, without requiring manual conversion of the tasks to observable sequences using <see cref="M:System.Reactive.Threading.Tasks.TaskObservableExtensions.ToObservable``1(System.Threading.Tasks.Task{``0})" />.</remarks>
  11302. 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)
  11303. {
  11304. if (source == null)
  11305. throw new ArgumentNullException("source");
  11306. if (taskSelector == null)
  11307. throw new ArgumentNullException("taskSelector");
  11308. if (resultSelector == null)
  11309. throw new ArgumentNullException("resultSelector");
  11310. return source.Provider.CreateQuery<TResult>(
  11311. Expression.Call(
  11312. null,
  11313. #if CRIPPLED_REFLECTION
  11314. InfoOf(() => Qbservable.SelectMany<TSource, TTaskResult, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, CancellationToken, Task<TTaskResult>>>), default(Expression<Func<TSource, TTaskResult, TResult>>))),
  11315. #else
  11316. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTaskResult), typeof(TResult)),
  11317. #endif
  11318. source.Expression,
  11319. taskSelector,
  11320. resultSelector
  11321. )
  11322. );
  11323. }
  11324. #endif
  11325. /// <summary>
  11326. /// Determines whether two sequences are equal by comparing the elements pairwise.
  11327. /// </summary>
  11328. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11329. /// <param name="first">First observable sequence to compare.</param>
  11330. /// <param name="second">Second observable sequence to compare.</param>
  11331. /// <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>
  11332. /// <exception cref="T:System.ArgumentNullException">
  11333. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  11334. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  11335. public static IQbservable<bool> SequenceEqual<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  11336. {
  11337. if (first == null)
  11338. throw new ArgumentNullException("first");
  11339. if (second == null)
  11340. throw new ArgumentNullException("second");
  11341. return first.Provider.CreateQuery<bool>(
  11342. Expression.Call(
  11343. null,
  11344. #if CRIPPLED_REFLECTION
  11345. InfoOf(() => Qbservable.SequenceEqual<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  11346. #else
  11347. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11348. #endif
  11349. first.Expression,
  11350. GetSourceExpression(second)
  11351. )
  11352. );
  11353. }
  11354. /// <summary>
  11355. /// Determines whether an observable and enumerable sequence are equal by comparing the elements pairwise.
  11356. /// </summary>
  11357. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11358. /// <param name="first">First observable sequence to compare.</param>
  11359. /// <param name="second">Second observable sequence to compare.</param>
  11360. /// <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>
  11361. /// <exception cref="T:System.ArgumentNullException">
  11362. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  11363. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  11364. public static IQbservable<bool> SequenceEqual<TSource>(this IQbservable<TSource> first, IEnumerable<TSource> second)
  11365. {
  11366. if (first == null)
  11367. throw new ArgumentNullException("first");
  11368. if (second == null)
  11369. throw new ArgumentNullException("second");
  11370. return first.Provider.CreateQuery<bool>(
  11371. Expression.Call(
  11372. null,
  11373. #if CRIPPLED_REFLECTION
  11374. InfoOf(() => Qbservable.SequenceEqual<TSource>(default(IQbservable<TSource>), default(IEnumerable<TSource>))),
  11375. #else
  11376. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11377. #endif
  11378. first.Expression,
  11379. GetSourceExpression(second)
  11380. )
  11381. );
  11382. }
  11383. /// <summary>
  11384. /// Determines whether two sequences are equal by comparing the elements pairwise using a specified equality comparer.
  11385. /// </summary>
  11386. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11387. /// <param name="first">First observable sequence to compare.</param>
  11388. /// <param name="second">Second observable sequence to compare.</param>
  11389. /// <param name="comparer">Comparer used to compare elements of both sequences.</param>
  11390. /// <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>
  11391. /// <exception cref="T:System.ArgumentNullException">
  11392. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="comparer" /> is null.</exception>
  11393. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  11394. public static IQbservable<bool> SequenceEqual<TSource>(this IQbservable<TSource> first, IObservable<TSource> second, IEqualityComparer<TSource> comparer)
  11395. {
  11396. if (first == null)
  11397. throw new ArgumentNullException("first");
  11398. if (second == null)
  11399. throw new ArgumentNullException("second");
  11400. if (comparer == null)
  11401. throw new ArgumentNullException("comparer");
  11402. return first.Provider.CreateQuery<bool>(
  11403. Expression.Call(
  11404. null,
  11405. #if CRIPPLED_REFLECTION
  11406. InfoOf(() => Qbservable.SequenceEqual<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>), default(IEqualityComparer<TSource>))),
  11407. #else
  11408. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11409. #endif
  11410. first.Expression,
  11411. GetSourceExpression(second),
  11412. Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))
  11413. )
  11414. );
  11415. }
  11416. /// <summary>
  11417. /// Determines whether an observable and enumerable sequence are equal by comparing the elements pairwise using a specified equality comparer.
  11418. /// </summary>
  11419. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11420. /// <param name="first">First observable sequence to compare.</param>
  11421. /// <param name="second">Second observable sequence to compare.</param>
  11422. /// <param name="comparer">Comparer used to compare elements of both sequences.</param>
  11423. /// <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>
  11424. /// <exception cref="T:System.ArgumentNullException">
  11425. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="comparer" /> is null.</exception>
  11426. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  11427. public static IQbservable<bool> SequenceEqual<TSource>(this IQbservable<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
  11428. {
  11429. if (first == null)
  11430. throw new ArgumentNullException("first");
  11431. if (second == null)
  11432. throw new ArgumentNullException("second");
  11433. if (comparer == null)
  11434. throw new ArgumentNullException("comparer");
  11435. return first.Provider.CreateQuery<bool>(
  11436. Expression.Call(
  11437. null,
  11438. #if CRIPPLED_REFLECTION
  11439. InfoOf(() => Qbservable.SequenceEqual<TSource>(default(IQbservable<TSource>), default(IEnumerable<TSource>), default(IEqualityComparer<TSource>))),
  11440. #else
  11441. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11442. #endif
  11443. first.Expression,
  11444. GetSourceExpression(second),
  11445. Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))
  11446. )
  11447. );
  11448. }
  11449. /// <summary>
  11450. /// Returns the only element of an observable sequence, and reports an exception if there is not exactly one element in the observable sequence.
  11451. /// </summary>
  11452. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11453. /// <param name="source">Source observable sequence.</param>
  11454. /// <returns>Sequence containing the single element in the observable sequence.</returns>
  11455. /// <exception cref="T:System.ArgumentNullException">
  11456. /// <paramref name="source" /> is null.</exception>
  11457. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence contains more than one element. -or- The source sequence is empty.</exception>
  11458. public static IQbservable<TSource> SingleAsync<TSource>(this IQbservable<TSource> source)
  11459. {
  11460. if (source == null)
  11461. throw new ArgumentNullException("source");
  11462. return source.Provider.CreateQuery<TSource>(
  11463. Expression.Call(
  11464. null,
  11465. #if CRIPPLED_REFLECTION
  11466. InfoOf(() => Qbservable.SingleAsync<TSource>(default(IQbservable<TSource>))),
  11467. #else
  11468. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11469. #endif
  11470. source.Expression
  11471. )
  11472. );
  11473. }
  11474. /// <summary>
  11475. /// 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.
  11476. /// </summary>
  11477. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11478. /// <param name="source">Source observable sequence.</param>
  11479. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  11480. /// <returns>Sequence containing the single element in the observable sequence that satisfies the condition in the predicate.</returns>
  11481. /// <exception cref="T:System.ArgumentNullException">
  11482. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  11483. /// <exception cref="T:System.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>
  11484. public static IQbservable<TSource> SingleAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  11485. {
  11486. if (source == null)
  11487. throw new ArgumentNullException("source");
  11488. if (predicate == null)
  11489. throw new ArgumentNullException("predicate");
  11490. return source.Provider.CreateQuery<TSource>(
  11491. Expression.Call(
  11492. null,
  11493. #if CRIPPLED_REFLECTION
  11494. InfoOf(() => Qbservable.SingleAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  11495. #else
  11496. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11497. #endif
  11498. source.Expression,
  11499. predicate
  11500. )
  11501. );
  11502. }
  11503. /// <summary>
  11504. /// 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.
  11505. /// </summary>
  11506. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11507. /// <param name="source">Source observable sequence.</param>
  11508. /// <returns>Sequence containing the single element in the observable sequence, or a default value if no such element exists.</returns>
  11509. /// <exception cref="T:System.ArgumentNullException">
  11510. /// <paramref name="source" /> is null.</exception>
  11511. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence contains more than one element.</exception>
  11512. public static IQbservable<TSource> SingleOrDefaultAsync<TSource>(this IQbservable<TSource> source)
  11513. {
  11514. if (source == null)
  11515. throw new ArgumentNullException("source");
  11516. return source.Provider.CreateQuery<TSource>(
  11517. Expression.Call(
  11518. null,
  11519. #if CRIPPLED_REFLECTION
  11520. InfoOf(() => Qbservable.SingleOrDefaultAsync<TSource>(default(IQbservable<TSource>))),
  11521. #else
  11522. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11523. #endif
  11524. source.Expression
  11525. )
  11526. );
  11527. }
  11528. /// <summary>
  11529. /// 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.
  11530. /// </summary>
  11531. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11532. /// <param name="source">Source observable sequence.</param>
  11533. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  11534. /// <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>
  11535. /// <exception cref="T:System.ArgumentNullException">
  11536. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  11537. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The sequence contains more than one element that satisfies the condition in the predicate.</exception>
  11538. public static IQbservable<TSource> SingleOrDefaultAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  11539. {
  11540. if (source == null)
  11541. throw new ArgumentNullException("source");
  11542. if (predicate == null)
  11543. throw new ArgumentNullException("predicate");
  11544. return source.Provider.CreateQuery<TSource>(
  11545. Expression.Call(
  11546. null,
  11547. #if CRIPPLED_REFLECTION
  11548. InfoOf(() => Qbservable.SingleOrDefaultAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  11549. #else
  11550. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11551. #endif
  11552. source.Expression,
  11553. predicate
  11554. )
  11555. );
  11556. }
  11557. /// <summary>
  11558. /// Bypasses a specified number of elements in an observable sequence and then returns the remaining elements.
  11559. /// </summary>
  11560. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11561. /// <param name="source">The sequence to take elements from.</param>
  11562. /// <param name="count">The number of elements to skip before returning the remaining elements.</param>
  11563. /// <returns>An observable sequence that contains the elements that occur after the specified index in the input sequence.</returns>
  11564. /// <exception cref="T:System.ArgumentNullException">
  11565. /// <paramref name="source" /> is null.</exception>
  11566. /// <exception cref="T:System.ArgumentOutOfRangeException">
  11567. /// <paramref name="count" /> is less than zero.</exception>
  11568. public static IQbservable<TSource> Skip<TSource>(this IQbservable<TSource> source, int count)
  11569. {
  11570. if (source == null)
  11571. throw new ArgumentNullException("source");
  11572. return source.Provider.CreateQuery<TSource>(
  11573. Expression.Call(
  11574. null,
  11575. #if CRIPPLED_REFLECTION
  11576. InfoOf(() => Qbservable.Skip<TSource>(default(IQbservable<TSource>), default(int))),
  11577. #else
  11578. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11579. #endif
  11580. source.Expression,
  11581. Expression.Constant(count, typeof(int))
  11582. )
  11583. );
  11584. }
  11585. /// <summary>
  11586. /// Skips elements for the specified duration from the start of the observable source sequence.
  11587. /// </summary>
  11588. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11589. /// <param name="source">Source sequence to skip elements for.</param>
  11590. /// <param name="duration">Duration for skipping elements from the start of the sequence.</param>
  11591. /// <returns>An observable sequence with the elements skipped during the specified duration from the start of the source sequence.</returns>
  11592. /// <exception cref="T:System.ArgumentNullException">
  11593. /// <paramref name="source" /> is null.</exception>
  11594. /// <exception cref="T:System.ArgumentOutOfRangeException">
  11595. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  11596. /// <remarks>
  11597. /// <para>
  11598. /// Specifying a TimeSpan.Zero value for <paramref name="duration" /> doesn't guarantee no elements will be dropped from the start of the source sequence.
  11599. /// 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
  11600. /// may not execute immediately, despite the TimeSpan.Zero due time.
  11601. /// </para>
  11602. /// <para>
  11603. /// Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the <paramref name="duration" />.
  11604. /// </para>
  11605. /// </remarks>
  11606. public static IQbservable<TSource> Skip<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  11607. {
  11608. if (source == null)
  11609. throw new ArgumentNullException("source");
  11610. return source.Provider.CreateQuery<TSource>(
  11611. Expression.Call(
  11612. null,
  11613. #if CRIPPLED_REFLECTION
  11614. InfoOf(() => Qbservable.Skip<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  11615. #else
  11616. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11617. #endif
  11618. source.Expression,
  11619. Expression.Constant(duration, typeof(TimeSpan))
  11620. )
  11621. );
  11622. }
  11623. /// <summary>
  11624. /// Skips elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers.
  11625. /// </summary>
  11626. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11627. /// <param name="source">Source sequence to skip elements for.</param>
  11628. /// <param name="duration">Duration for skipping elements from the start of the sequence.</param>
  11629. /// <param name="scheduler">Scheduler to run the timer on.</param>
  11630. /// <returns>An observable sequence with the elements skipped during the specified duration from the start of the source sequence.</returns>
  11631. /// <exception cref="T:System.ArgumentNullException">
  11632. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  11633. /// <exception cref="T:System.ArgumentOutOfRangeException">
  11634. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  11635. /// <remarks>
  11636. /// <para>
  11637. /// Specifying a TimeSpan.Zero value for <paramref name="duration" /> doesn't guarantee no elements will be dropped from the start of the source sequence.
  11638. /// 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
  11639. /// may not execute immediately, despite the TimeSpan.Zero due time.
  11640. /// </para>
  11641. /// <para>
  11642. /// Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the <paramref name="duration" />.
  11643. /// </para>
  11644. /// </remarks>
  11645. public static IQbservable<TSource> Skip<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  11646. {
  11647. if (source == null)
  11648. throw new ArgumentNullException("source");
  11649. if (scheduler == null)
  11650. throw new ArgumentNullException("scheduler");
  11651. return source.Provider.CreateQuery<TSource>(
  11652. Expression.Call(
  11653. null,
  11654. #if CRIPPLED_REFLECTION
  11655. InfoOf(() => Qbservable.Skip<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  11656. #else
  11657. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11658. #endif
  11659. source.Expression,
  11660. Expression.Constant(duration, typeof(TimeSpan)),
  11661. Expression.Constant(scheduler, typeof(IScheduler))
  11662. )
  11663. );
  11664. }
  11665. /// <summary>
  11666. /// Bypasses a specified number of elements at the end of an observable sequence.
  11667. /// </summary>
  11668. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11669. /// <param name="source">Source sequence.</param>
  11670. /// <param name="count">Number of elements to bypass at the end of the source sequence.</param>
  11671. /// <returns>An observable sequence containing the source sequence elements except for the bypassed ones at the end.</returns>
  11672. /// <exception cref="T:System.ArgumentNullException">
  11673. /// <paramref name="source" /> is null.</exception>
  11674. /// <exception cref="T:System.ArgumentOutOfRangeException">
  11675. /// <paramref name="count" /> is less than zero.</exception>
  11676. /// <remarks>
  11677. /// This operator accumulates a queue with a length enough to store the first <paramref name="count" /> elements. As more elements are
  11678. /// received, elements are taken from the front of the queue and produced on the result sequence. This causes elements to be delayed.
  11679. /// </remarks>
  11680. public static IQbservable<TSource> SkipLast<TSource>(this IQbservable<TSource> source, int count)
  11681. {
  11682. if (source == null)
  11683. throw new ArgumentNullException("source");
  11684. return source.Provider.CreateQuery<TSource>(
  11685. Expression.Call(
  11686. null,
  11687. #if CRIPPLED_REFLECTION
  11688. InfoOf(() => Qbservable.SkipLast<TSource>(default(IQbservable<TSource>), default(int))),
  11689. #else
  11690. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11691. #endif
  11692. source.Expression,
  11693. Expression.Constant(count, typeof(int))
  11694. )
  11695. );
  11696. }
  11697. /// <summary>
  11698. /// Skips elements for the specified duration from the end of the observable source sequence.
  11699. /// </summary>
  11700. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11701. /// <param name="source">Source sequence to skip elements for.</param>
  11702. /// <param name="duration">Duration for skipping elements from the end of the sequence.</param>
  11703. /// <returns>An observable sequence with the elements skipped during the specified duration from the end of the source sequence.</returns>
  11704. /// <exception cref="T:System.ArgumentNullException">
  11705. /// <paramref name="source" /> is null.</exception>
  11706. /// <exception cref="T:System.ArgumentOutOfRangeException">
  11707. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  11708. /// <remarks>
  11709. /// This operator accumulates a queue with a length enough to store elements received during the initial <paramref name="duration" /> window.
  11710. /// As more elements are received, elements older than the specified <paramref name="duration" /> are taken from the queue and produced on the
  11711. /// result sequence. This causes elements to be delayed with <paramref name="duration" />.
  11712. /// </remarks>
  11713. public static IQbservable<TSource> SkipLast<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  11714. {
  11715. if (source == null)
  11716. throw new ArgumentNullException("source");
  11717. return source.Provider.CreateQuery<TSource>(
  11718. Expression.Call(
  11719. null,
  11720. #if CRIPPLED_REFLECTION
  11721. InfoOf(() => Qbservable.SkipLast<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  11722. #else
  11723. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11724. #endif
  11725. source.Expression,
  11726. Expression.Constant(duration, typeof(TimeSpan))
  11727. )
  11728. );
  11729. }
  11730. /// <summary>
  11731. /// Skips elements for the specified duration from the end of the observable source sequence, using the specified scheduler to run timers.
  11732. /// </summary>
  11733. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11734. /// <param name="source">Source sequence to skip elements for.</param>
  11735. /// <param name="duration">Duration for skipping elements from the end of the sequence.</param>
  11736. /// <param name="scheduler">Scheduler to run the timer on.</param>
  11737. /// <returns>An observable sequence with the elements skipped during the specified duration from the end of the source sequence.</returns>
  11738. /// <exception cref="T:System.ArgumentNullException">
  11739. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  11740. /// <exception cref="T:System.ArgumentOutOfRangeException">
  11741. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  11742. /// <remarks>
  11743. /// This operator accumulates a queue with a length enough to store elements received during the initial <paramref name="duration" /> window.
  11744. /// As more elements are received, elements older than the specified <paramref name="duration" /> are taken from the queue and produced on the
  11745. /// result sequence. This causes elements to be delayed with <paramref name="duration" />.
  11746. /// </remarks>
  11747. public static IQbservable<TSource> SkipLast<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  11748. {
  11749. if (source == null)
  11750. throw new ArgumentNullException("source");
  11751. if (scheduler == null)
  11752. throw new ArgumentNullException("scheduler");
  11753. return source.Provider.CreateQuery<TSource>(
  11754. Expression.Call(
  11755. null,
  11756. #if CRIPPLED_REFLECTION
  11757. InfoOf(() => Qbservable.SkipLast<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  11758. #else
  11759. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11760. #endif
  11761. source.Expression,
  11762. Expression.Constant(duration, typeof(TimeSpan)),
  11763. Expression.Constant(scheduler, typeof(IScheduler))
  11764. )
  11765. );
  11766. }
  11767. /// <summary>
  11768. /// Skips elements from the observable source sequence until the specified start time.
  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="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>
  11773. /// <returns>An observable sequence with the elements skipped until the specified start time.</returns>
  11774. /// <exception cref="T:System.ArgumentNullException">
  11775. /// <paramref name="source" /> is null.</exception>
  11776. /// <remarks>
  11777. /// Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the <paramref name="startTime" />.
  11778. /// </remarks>
  11779. public static IQbservable<TSource> SkipUntil<TSource>(this IQbservable<TSource> source, DateTimeOffset startTime)
  11780. {
  11781. if (source == null)
  11782. throw new ArgumentNullException("source");
  11783. return source.Provider.CreateQuery<TSource>(
  11784. Expression.Call(
  11785. null,
  11786. #if CRIPPLED_REFLECTION
  11787. InfoOf(() => Qbservable.SkipUntil<TSource>(default(IQbservable<TSource>), default(DateTimeOffset))),
  11788. #else
  11789. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11790. #endif
  11791. source.Expression,
  11792. Expression.Constant(startTime, typeof(DateTimeOffset))
  11793. )
  11794. );
  11795. }
  11796. /// <summary>
  11797. /// Skips elements from the observable source sequence until the specified start time, using the specified scheduler to run timers.
  11798. /// </summary>
  11799. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11800. /// <param name="source">Source sequence to skip elements for.</param>
  11801. /// <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>
  11802. /// <param name="scheduler">Scheduler to run the timer on.</param>
  11803. /// <returns>An observable sequence with the elements skipped until the specified start time.</returns>
  11804. /// <exception cref="T:System.ArgumentNullException">
  11805. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  11806. /// <remarks>
  11807. /// Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the <paramref name="startTime" />.
  11808. /// </remarks>
  11809. public static IQbservable<TSource> SkipUntil<TSource>(this IQbservable<TSource> source, DateTimeOffset startTime, IScheduler scheduler)
  11810. {
  11811. if (source == null)
  11812. throw new ArgumentNullException("source");
  11813. if (scheduler == null)
  11814. throw new ArgumentNullException("scheduler");
  11815. return source.Provider.CreateQuery<TSource>(
  11816. Expression.Call(
  11817. null,
  11818. #if CRIPPLED_REFLECTION
  11819. InfoOf(() => Qbservable.SkipUntil<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IScheduler))),
  11820. #else
  11821. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11822. #endif
  11823. source.Expression,
  11824. Expression.Constant(startTime, typeof(DateTimeOffset)),
  11825. Expression.Constant(scheduler, typeof(IScheduler))
  11826. )
  11827. );
  11828. }
  11829. /// <summary>
  11830. /// Returns the elements from the source observable sequence only after the other observable sequence produces an element.
  11831. /// </summary>
  11832. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11833. /// <typeparam name="TOther">The type of the elements in the other sequence that indicates the end of skip behavior.</typeparam>
  11834. /// <param name="source">Source sequence to propagate elements for.</param>
  11835. /// <param name="other">Observable sequence that triggers propagation of elements of the source sequence.</param>
  11836. /// <returns>An observable sequence containing the elements of the source sequence starting from the point the other sequence triggered propagation.</returns>
  11837. /// <exception cref="T:System.ArgumentNullException">
  11838. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  11839. public static IQbservable<TSource> SkipUntil<TSource, TOther>(this IQbservable<TSource> source, IObservable<TOther> other)
  11840. {
  11841. if (source == null)
  11842. throw new ArgumentNullException("source");
  11843. if (other == null)
  11844. throw new ArgumentNullException("other");
  11845. return source.Provider.CreateQuery<TSource>(
  11846. Expression.Call(
  11847. null,
  11848. #if CRIPPLED_REFLECTION
  11849. InfoOf(() => Qbservable.SkipUntil<TSource, TOther>(default(IQbservable<TSource>), default(IObservable<TOther>))),
  11850. #else
  11851. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)),
  11852. #endif
  11853. source.Expression,
  11854. GetSourceExpression(other)
  11855. )
  11856. );
  11857. }
  11858. /// <summary>
  11859. /// Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements.
  11860. /// </summary>
  11861. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11862. /// <param name="source">An observable sequence to return elements from.</param>
  11863. /// <param name="predicate">A function to test each element for a condition.</param>
  11864. /// <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>
  11865. /// <exception cref="T:System.ArgumentNullException">
  11866. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  11867. public static IQbservable<TSource> SkipWhile<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  11868. {
  11869. if (source == null)
  11870. throw new ArgumentNullException("source");
  11871. if (predicate == null)
  11872. throw new ArgumentNullException("predicate");
  11873. return source.Provider.CreateQuery<TSource>(
  11874. Expression.Call(
  11875. null,
  11876. #if CRIPPLED_REFLECTION
  11877. InfoOf(() => Qbservable.SkipWhile<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  11878. #else
  11879. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11880. #endif
  11881. source.Expression,
  11882. predicate
  11883. )
  11884. );
  11885. }
  11886. /// <summary>
  11887. /// Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements.
  11888. /// The element's index is used in the logic of the predicate function.
  11889. /// </summary>
  11890. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11891. /// <param name="source">An observable sequence to return elements from.</param>
  11892. /// <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>
  11893. /// <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>
  11894. /// <exception cref="T:System.ArgumentNullException">
  11895. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  11896. public static IQbservable<TSource> SkipWhile<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int, bool>> predicate)
  11897. {
  11898. if (source == null)
  11899. throw new ArgumentNullException("source");
  11900. if (predicate == null)
  11901. throw new ArgumentNullException("predicate");
  11902. return source.Provider.CreateQuery<TSource>(
  11903. Expression.Call(
  11904. null,
  11905. #if CRIPPLED_REFLECTION
  11906. InfoOf(() => Qbservable.SkipWhile<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, bool>>))),
  11907. #else
  11908. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11909. #endif
  11910. source.Expression,
  11911. predicate
  11912. )
  11913. );
  11914. }
  11915. /// <summary>
  11916. /// Invokes the action asynchronously, surfacing the result through an observable sequence.
  11917. /// </summary>
  11918. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  11919. /// <param name="action">Action to run asynchronously.</param>
  11920. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  11921. /// <exception cref="T:System.ArgumentNullException">
  11922. /// <paramref name="action" /> is null.</exception>
  11923. /// <remarks>
  11924. /// <list type="bullet">
  11925. /// <item>
  11926. /// <description>The action is called immediately, not during the subscription of the resulting sequence.</description>
  11927. /// </item>
  11928. /// <item>
  11929. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  11930. /// </item>
  11931. /// </list>
  11932. /// </remarks>
  11933. public static IQbservable<Unit> Start(this IQbservableProvider provider, Expression<Action> action)
  11934. {
  11935. if (provider == null)
  11936. throw new ArgumentNullException("provider");
  11937. if (action == null)
  11938. throw new ArgumentNullException("action");
  11939. return provider.CreateQuery<Unit>(
  11940. Expression.Call(
  11941. null,
  11942. #if CRIPPLED_REFLECTION
  11943. InfoOf(() => Qbservable.Start(default(IQbservableProvider), default(Expression<Action>))),
  11944. #else
  11945. (MethodInfo)MethodInfo.GetCurrentMethod(),
  11946. #endif
  11947. Expression.Constant(provider, typeof(IQbservableProvider)),
  11948. action
  11949. )
  11950. );
  11951. }
  11952. /// <summary>
  11953. /// Invokes the action asynchronously on the specified scheduler, surfacing the result through an observable sequence.
  11954. /// </summary>
  11955. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  11956. /// <param name="action">Action to run asynchronously.</param>
  11957. /// <param name="scheduler">Scheduler to run the action on.</param>
  11958. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  11959. /// <exception cref="T:System.ArgumentNullException">
  11960. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  11961. /// <remarks>
  11962. /// <list type="bullet">
  11963. /// <item>
  11964. /// <description>The action is called immediately, not during the subscription of the resulting sequence.</description>
  11965. /// </item>
  11966. /// <item>
  11967. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  11968. /// </item>
  11969. /// </list>
  11970. /// </remarks>
  11971. public static IQbservable<Unit> Start(this IQbservableProvider provider, Expression<Action> action, IScheduler scheduler)
  11972. {
  11973. if (provider == null)
  11974. throw new ArgumentNullException("provider");
  11975. if (action == null)
  11976. throw new ArgumentNullException("action");
  11977. if (scheduler == null)
  11978. throw new ArgumentNullException("scheduler");
  11979. return provider.CreateQuery<Unit>(
  11980. Expression.Call(
  11981. null,
  11982. #if CRIPPLED_REFLECTION
  11983. InfoOf(() => Qbservable.Start(default(IQbservableProvider), default(Expression<Action>), default(IScheduler))),
  11984. #else
  11985. (MethodInfo)MethodInfo.GetCurrentMethod(),
  11986. #endif
  11987. Expression.Constant(provider, typeof(IQbservableProvider)),
  11988. action,
  11989. Expression.Constant(scheduler, typeof(IScheduler))
  11990. )
  11991. );
  11992. }
  11993. /// <summary>
  11994. /// Invokes the specified function asynchronously, surfacing the result through an observable sequence.
  11995. /// </summary>
  11996. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  11997. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  11998. /// <param name="function">Function to run asynchronously.</param>
  11999. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12000. /// <exception cref="T:System.ArgumentNullException">
  12001. /// <paramref name="function" /> is null.</exception>
  12002. /// <remarks>
  12003. /// <list type="bullet">
  12004. /// <item>
  12005. /// <description>The function is called immediately, not during the subscription of the resulting sequence.</description>
  12006. /// </item>
  12007. /// <item>
  12008. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12009. /// </item>
  12010. /// </list>
  12011. /// </remarks>
  12012. public static IQbservable<TResult> Start<TResult>(this IQbservableProvider provider, Expression<Func<TResult>> function)
  12013. {
  12014. if (provider == null)
  12015. throw new ArgumentNullException("provider");
  12016. if (function == null)
  12017. throw new ArgumentNullException("function");
  12018. return provider.CreateQuery<TResult>(
  12019. Expression.Call(
  12020. null,
  12021. #if CRIPPLED_REFLECTION
  12022. InfoOf(() => Qbservable.Start<TResult>(default(IQbservableProvider), default(Expression<Func<TResult>>))),
  12023. #else
  12024. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12025. #endif
  12026. Expression.Constant(provider, typeof(IQbservableProvider)),
  12027. function
  12028. )
  12029. );
  12030. }
  12031. /// <summary>
  12032. /// Invokes the specified function asynchronously on the specified scheduler, surfacing the result through an observable sequence
  12033. /// </summary>
  12034. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  12035. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  12036. /// <param name="function">Function to run asynchronously.</param>
  12037. /// <param name="scheduler">Scheduler to run the function on.</param>
  12038. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12039. /// <exception cref="T:System.ArgumentNullException">
  12040. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  12041. /// <remarks>
  12042. /// <list type="bullet">
  12043. /// <item>
  12044. /// <description>The function is called immediately, not during the subscription of the resulting sequence.</description>
  12045. /// </item>
  12046. /// <item>
  12047. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12048. /// </item>
  12049. /// </list>
  12050. /// </remarks>
  12051. public static IQbservable<TResult> Start<TResult>(this IQbservableProvider provider, Expression<Func<TResult>> function, IScheduler scheduler)
  12052. {
  12053. if (provider == null)
  12054. throw new ArgumentNullException("provider");
  12055. if (function == null)
  12056. throw new ArgumentNullException("function");
  12057. if (scheduler == null)
  12058. throw new ArgumentNullException("scheduler");
  12059. return provider.CreateQuery<TResult>(
  12060. Expression.Call(
  12061. null,
  12062. #if CRIPPLED_REFLECTION
  12063. InfoOf(() => Qbservable.Start<TResult>(default(IQbservableProvider), default(Expression<Func<TResult>>), default(IScheduler))),
  12064. #else
  12065. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12066. #endif
  12067. Expression.Constant(provider, typeof(IQbservableProvider)),
  12068. function,
  12069. Expression.Constant(scheduler, typeof(IScheduler))
  12070. )
  12071. );
  12072. }
  12073. #if !NO_TPL
  12074. /// <summary>
  12075. /// Invokes the asynchronous action, surfacing the result through an observable sequence.
  12076. /// </summary>
  12077. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  12078. /// <param name="actionAsync">Asynchronous action to run.</param>
  12079. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12080. /// <exception cref="T:System.ArgumentNullException">
  12081. /// <paramref name="actionAsync" /> is null.</exception>
  12082. /// <remarks>
  12083. /// <list type="bullet">
  12084. /// <item>
  12085. /// <description>The action is started immediately, not during the subscription of the resulting sequence.</description>
  12086. /// </item>
  12087. /// <item>
  12088. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12089. /// </item>
  12090. /// </list>
  12091. /// </remarks>
  12092. public static IQbservable<Unit> StartAsync(this IQbservableProvider provider, Expression<Func<Task>> actionAsync)
  12093. {
  12094. if (provider == null)
  12095. throw new ArgumentNullException("provider");
  12096. if (actionAsync == null)
  12097. throw new ArgumentNullException("actionAsync");
  12098. return provider.CreateQuery<Unit>(
  12099. Expression.Call(
  12100. null,
  12101. #if CRIPPLED_REFLECTION
  12102. InfoOf(() => Qbservable.StartAsync(default(IQbservableProvider), default(Expression<Func<Task>>))),
  12103. #else
  12104. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12105. #endif
  12106. Expression.Constant(provider, typeof(IQbservableProvider)),
  12107. actionAsync
  12108. )
  12109. );
  12110. }
  12111. #endif
  12112. #if !NO_TPL
  12113. /// <summary>
  12114. /// Invokes the asynchronous action, surfacing the result through an observable sequence.
  12115. /// The CancellationToken is shared by all subscriptions on the resulting observable sequence. See the remarks section for more information.
  12116. /// </summary>
  12117. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  12118. /// <param name="actionAsync">Asynchronous action to run.</param>
  12119. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12120. /// <exception cref="T:System.ArgumentNullException">
  12121. /// <paramref name="actionAsync" /> is null.</exception>
  12122. /// <remarks>
  12123. /// <list type="bullet">
  12124. /// <item>
  12125. /// <description>The action is started immediately, not during the subscription of the resulting sequence.</description>
  12126. /// </item>
  12127. /// <item>
  12128. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12129. /// </item>
  12130. /// <item>
  12131. /// <description>
  12132. /// If any subscription to the resulting sequence is disposed, the CancellationToken is set. The observer associated to the disposed
  12133. /// subscription won't see the TaskCanceledException, but other observers will. You can protect against this using the Catch operator.
  12134. /// Be careful when handing out the resulting sequence because of this behavior. The most common use is to have a single subscription
  12135. /// to the resulting sequence, which controls the CancellationToken state. Alternatively, you can control subscription behavior using
  12136. /// multicast operators.
  12137. /// </description>
  12138. /// </item>
  12139. /// </list>
  12140. /// </remarks>
  12141. public static IQbservable<Unit> StartAsync(this IQbservableProvider provider, Expression<Func<CancellationToken, Task>> actionAsync)
  12142. {
  12143. if (provider == null)
  12144. throw new ArgumentNullException("provider");
  12145. if (actionAsync == null)
  12146. throw new ArgumentNullException("actionAsync");
  12147. return provider.CreateQuery<Unit>(
  12148. Expression.Call(
  12149. null,
  12150. #if CRIPPLED_REFLECTION
  12151. InfoOf(() => Qbservable.StartAsync(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task>>))),
  12152. #else
  12153. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12154. #endif
  12155. Expression.Constant(provider, typeof(IQbservableProvider)),
  12156. actionAsync
  12157. )
  12158. );
  12159. }
  12160. #endif
  12161. #if !NO_TPL
  12162. /// <summary>
  12163. /// Invokes the asynchronous function, surfacing the result through an observable sequence.
  12164. /// </summary>
  12165. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  12166. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  12167. /// <param name="functionAsync">Asynchronous function to run.</param>
  12168. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12169. /// <exception cref="T:System.ArgumentNullException">
  12170. /// <paramref name="functionAsync" /> is null.</exception>
  12171. /// <remarks>
  12172. /// <list type="bullet">
  12173. /// <item>
  12174. /// <description>The function is started immediately, not during the subscription of the resulting sequence.</description>
  12175. /// </item>
  12176. /// <item>
  12177. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12178. /// </item>
  12179. /// </list>
  12180. /// </remarks>
  12181. public static IQbservable<TResult> StartAsync<TResult>(this IQbservableProvider provider, Expression<Func<Task<TResult>>> functionAsync)
  12182. {
  12183. if (provider == null)
  12184. throw new ArgumentNullException("provider");
  12185. if (functionAsync == null)
  12186. throw new ArgumentNullException("functionAsync");
  12187. return provider.CreateQuery<TResult>(
  12188. Expression.Call(
  12189. null,
  12190. #if CRIPPLED_REFLECTION
  12191. InfoOf(() => Qbservable.StartAsync<TResult>(default(IQbservableProvider), default(Expression<Func<Task<TResult>>>))),
  12192. #else
  12193. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12194. #endif
  12195. Expression.Constant(provider, typeof(IQbservableProvider)),
  12196. functionAsync
  12197. )
  12198. );
  12199. }
  12200. #endif
  12201. #if !NO_TPL
  12202. /// <summary>
  12203. /// Invokes the asynchronous function, surfacing the result through an observable sequence.
  12204. /// The CancellationToken is shared by all subscriptions on the resulting observable sequence. See the remarks section for more information.
  12205. /// </summary>
  12206. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  12207. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  12208. /// <param name="functionAsync">Asynchronous function to run.</param>
  12209. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12210. /// <exception cref="T:System.ArgumentNullException">
  12211. /// <paramref name="functionAsync" /> is null.</exception>
  12212. /// <remarks>
  12213. /// <list type="bullet">
  12214. /// <item>
  12215. /// <description>The function is started immediately, not during the subscription of the resulting sequence.</description>
  12216. /// </item>
  12217. /// <item>
  12218. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12219. /// </item>
  12220. /// <item>
  12221. /// <description>
  12222. /// If any subscription to the resulting sequence is disposed, the CancellationToken is set. The observer associated to the disposed
  12223. /// subscription won't see the TaskCanceledException, but other observers will. You can protect against this using the Catch operator.
  12224. /// Be careful when handing out the resulting sequence because of this behavior. The most common use is to have a single subscription
  12225. /// to the resulting sequence, which controls the CancellationToken state. Alternatively, you can control subscription behavior using
  12226. /// multicast operators.
  12227. /// </description>
  12228. /// </item>
  12229. /// </list>
  12230. /// </remarks>
  12231. public static IQbservable<TResult> StartAsync<TResult>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<TResult>>> functionAsync)
  12232. {
  12233. if (provider == null)
  12234. throw new ArgumentNullException("provider");
  12235. if (functionAsync == null)
  12236. throw new ArgumentNullException("functionAsync");
  12237. return provider.CreateQuery<TResult>(
  12238. Expression.Call(
  12239. null,
  12240. #if CRIPPLED_REFLECTION
  12241. InfoOf(() => Qbservable.StartAsync<TResult>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<TResult>>>))),
  12242. #else
  12243. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12244. #endif
  12245. Expression.Constant(provider, typeof(IQbservableProvider)),
  12246. functionAsync
  12247. )
  12248. );
  12249. }
  12250. #endif
  12251. /// <summary>
  12252. /// Prepends a sequence of values to an observable sequence.
  12253. /// </summary>
  12254. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12255. /// <param name="source">Source sequence to prepend values to.</param>
  12256. /// <param name="scheduler">Scheduler to emit the prepended values on.</param>
  12257. /// <param name="values">Values to prepend to the specified sequence.</param>
  12258. /// <returns>The source sequence prepended with the specified values.</returns>
  12259. /// <exception cref="T:System.ArgumentNullException">
  12260. /// <paramref name="source" /> or <paramref name="scheduler" /> or <paramref name="values" /> is null.</exception>
  12261. public static IQbservable<TSource> StartWith<TSource>(this IQbservable<TSource> source, IScheduler scheduler, params TSource[] values)
  12262. {
  12263. if (source == null)
  12264. throw new ArgumentNullException("source");
  12265. if (scheduler == null)
  12266. throw new ArgumentNullException("scheduler");
  12267. if (values == null)
  12268. throw new ArgumentNullException("values");
  12269. return source.Provider.CreateQuery<TSource>(
  12270. Expression.Call(
  12271. null,
  12272. #if CRIPPLED_REFLECTION
  12273. InfoOf(() => Qbservable.StartWith<TSource>(default(IQbservable<TSource>), default(IScheduler), default(TSource[]))),
  12274. #else
  12275. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12276. #endif
  12277. source.Expression,
  12278. Expression.Constant(scheduler, typeof(IScheduler)),
  12279. Expression.Constant(values, typeof(TSource[]))
  12280. )
  12281. );
  12282. }
  12283. /// <summary>
  12284. /// Prepends a sequence of values to an observable sequence.
  12285. /// </summary>
  12286. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12287. /// <param name="source">Source sequence to prepend values to.</param>
  12288. /// <param name="scheduler">Scheduler to emit the prepended values on.</param>
  12289. /// <param name="values">Values to prepend to the specified sequence.</param>
  12290. /// <returns>The source sequence prepended with the specified values.</returns>
  12291. /// <exception cref="T:System.ArgumentNullException">
  12292. /// <paramref name="source" /> or <paramref name="scheduler" /> or <paramref name="values" /> is null.</exception>
  12293. public static IQbservable<TSource> StartWith<TSource>(this IQbservable<TSource> source, IScheduler scheduler, IEnumerable<TSource> values)
  12294. {
  12295. if (source == null)
  12296. throw new ArgumentNullException("source");
  12297. if (scheduler == null)
  12298. throw new ArgumentNullException("scheduler");
  12299. if (values == null)
  12300. throw new ArgumentNullException("values");
  12301. return source.Provider.CreateQuery<TSource>(
  12302. Expression.Call(
  12303. null,
  12304. #if CRIPPLED_REFLECTION
  12305. InfoOf(() => Qbservable.StartWith<TSource>(default(IQbservable<TSource>), default(IScheduler), default(IEnumerable<TSource>))),
  12306. #else
  12307. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12308. #endif
  12309. source.Expression,
  12310. Expression.Constant(scheduler, typeof(IScheduler)),
  12311. GetSourceExpression(values)
  12312. )
  12313. );
  12314. }
  12315. /// <summary>
  12316. /// Prepends a sequence of values to an observable sequence.
  12317. /// </summary>
  12318. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12319. /// <param name="source">Source sequence to prepend values to.</param>
  12320. /// <param name="values">Values to prepend to the specified sequence.</param>
  12321. /// <returns>The source sequence prepended with the specified values.</returns>
  12322. /// <exception cref="T:System.ArgumentNullException">
  12323. /// <paramref name="source" /> or <paramref name="values" /> is null.</exception>
  12324. public static IQbservable<TSource> StartWith<TSource>(this IQbservable<TSource> source, params TSource[] values)
  12325. {
  12326. if (source == null)
  12327. throw new ArgumentNullException("source");
  12328. if (values == null)
  12329. throw new ArgumentNullException("values");
  12330. return source.Provider.CreateQuery<TSource>(
  12331. Expression.Call(
  12332. null,
  12333. #if CRIPPLED_REFLECTION
  12334. InfoOf(() => Qbservable.StartWith<TSource>(default(IQbservable<TSource>), default(TSource[]))),
  12335. #else
  12336. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12337. #endif
  12338. source.Expression,
  12339. Expression.Constant(values, typeof(TSource[]))
  12340. )
  12341. );
  12342. }
  12343. /// <summary>
  12344. /// Prepends a sequence of values to an observable sequence.
  12345. /// </summary>
  12346. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12347. /// <param name="source">Source sequence to prepend values to.</param>
  12348. /// <param name="values">Values to prepend to the specified sequence.</param>
  12349. /// <returns>The source sequence prepended with the specified values.</returns>
  12350. /// <exception cref="T:System.ArgumentNullException">
  12351. /// <paramref name="source" /> or <paramref name="values" /> is null.</exception>
  12352. public static IQbservable<TSource> StartWith<TSource>(this IQbservable<TSource> source, IEnumerable<TSource> values)
  12353. {
  12354. if (source == null)
  12355. throw new ArgumentNullException("source");
  12356. if (values == null)
  12357. throw new ArgumentNullException("values");
  12358. return source.Provider.CreateQuery<TSource>(
  12359. Expression.Call(
  12360. null,
  12361. #if CRIPPLED_REFLECTION
  12362. InfoOf(() => Qbservable.StartWith<TSource>(default(IQbservable<TSource>), default(IEnumerable<TSource>))),
  12363. #else
  12364. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12365. #endif
  12366. source.Expression,
  12367. GetSourceExpression(values)
  12368. )
  12369. );
  12370. }
  12371. /// <summary>
  12372. /// Wraps the source sequence in order to run its subscription and unsubscription logic on the specified synchronization context. This operation is not commonly used;
  12373. /// see the remarks section for more information on the distinction between SubscribeOn and ObserveOn.
  12374. /// </summary>
  12375. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12376. /// <param name="source">Source sequence.</param>
  12377. /// <param name="context">Synchronization context to perform subscription and unsubscription actions on.</param>
  12378. /// <returns>The source sequence whose subscriptions and unsubscriptions happen on the specified synchronization context.</returns>
  12379. /// <exception cref="T:System.ArgumentNullException">
  12380. /// <paramref name="source" /> or <paramref name="context" /> is null.</exception>
  12381. /// <remarks>
  12382. /// This only performs the side-effects of subscription and unsubscription on the specified synchronization context. In order to invoke observer
  12383. /// callbacks on a synchronization context, use <see cref="M:System.Reactive.Linq.Observable.ObserveOn``1(System.IObservable{``0},System.Threading.SynchronizationContext)" />.
  12384. /// </remarks>
  12385. public static IQbservable<TSource> SubscribeOn<TSource>(this IQbservable<TSource> source, SynchronizationContext context)
  12386. {
  12387. if (source == null)
  12388. throw new ArgumentNullException("source");
  12389. if (context == null)
  12390. throw new ArgumentNullException("context");
  12391. return source.Provider.CreateQuery<TSource>(
  12392. Expression.Call(
  12393. null,
  12394. #if CRIPPLED_REFLECTION
  12395. InfoOf(() => Qbservable.SubscribeOn<TSource>(default(IQbservable<TSource>), default(SynchronizationContext))),
  12396. #else
  12397. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12398. #endif
  12399. source.Expression,
  12400. Expression.Constant(context, typeof(SynchronizationContext))
  12401. )
  12402. );
  12403. }
  12404. /// <summary>
  12405. /// Wraps the source sequence in order to run its subscription and unsubscription logic on the specified scheduler. This operation is not commonly used;
  12406. /// see the remarks section for more information on the distinction between SubscribeOn and ObserveOn.
  12407. /// </summary>
  12408. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12409. /// <param name="source">Source sequence.</param>
  12410. /// <param name="scheduler">Scheduler to perform subscription and unsubscription actions on.</param>
  12411. /// <returns>The source sequence whose subscriptions and unsubscriptions happen on the specified scheduler.</returns>
  12412. /// <exception cref="T:System.ArgumentNullException">
  12413. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  12414. /// <remarks>
  12415. /// This only performs the side-effects of subscription and unsubscription on the specified scheduler. In order to invoke observer
  12416. /// callbacks on a scheduler, use <see cref="M:System.Reactive.Linq.Observable.ObserveOn``1(System.IObservable{``0},System.Reactive.Concurrency.IScheduler)" />.
  12417. /// </remarks>
  12418. public static IQbservable<TSource> SubscribeOn<TSource>(this IQbservable<TSource> source, IScheduler scheduler)
  12419. {
  12420. if (source == null)
  12421. throw new ArgumentNullException("source");
  12422. if (scheduler == null)
  12423. throw new ArgumentNullException("scheduler");
  12424. return source.Provider.CreateQuery<TSource>(
  12425. Expression.Call(
  12426. null,
  12427. #if CRIPPLED_REFLECTION
  12428. InfoOf(() => Qbservable.SubscribeOn<TSource>(default(IQbservable<TSource>), default(IScheduler))),
  12429. #else
  12430. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12431. #endif
  12432. source.Expression,
  12433. Expression.Constant(scheduler, typeof(IScheduler))
  12434. )
  12435. );
  12436. }
  12437. /// <summary>
  12438. /// Computes the sum of a sequence of <see cref="T:System.Decimal" /> values.
  12439. /// </summary>
  12440. /// <param name="source">A sequence of <see cref="T:System.Decimal" /> values to calculate the sum of.</param>
  12441. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  12442. /// <exception cref="T:System.ArgumentNullException">
  12443. /// <paramref name="source" /> is null.</exception>
  12444. /// <exception cref="T:System.OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="M:System.Decimal.MaxValue" />.</exception>
  12445. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12446. public static IQbservable<decimal> Sum(this IQbservable<decimal> source)
  12447. {
  12448. if (source == null)
  12449. throw new ArgumentNullException("source");
  12450. return source.Provider.CreateQuery<decimal>(
  12451. Expression.Call(
  12452. null,
  12453. #if CRIPPLED_REFLECTION
  12454. InfoOf(() => Qbservable.Sum(default(IQbservable<decimal>))),
  12455. #else
  12456. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12457. #endif
  12458. source.Expression
  12459. )
  12460. );
  12461. }
  12462. /// <summary>
  12463. /// Computes the sum of a sequence of <see cref="T:System.Double" /> values.
  12464. /// </summary>
  12465. /// <param name="source">A sequence of <see cref="T:System.Double" /> values to calculate the sum of.</param>
  12466. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  12467. /// <exception cref="T:System.ArgumentNullException">
  12468. /// <paramref name="source" /> is null.</exception>
  12469. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12470. public static IQbservable<double> Sum(this IQbservable<double> source)
  12471. {
  12472. if (source == null)
  12473. throw new ArgumentNullException("source");
  12474. return source.Provider.CreateQuery<double>(
  12475. Expression.Call(
  12476. null,
  12477. #if CRIPPLED_REFLECTION
  12478. InfoOf(() => Qbservable.Sum(default(IQbservable<double>))),
  12479. #else
  12480. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12481. #endif
  12482. source.Expression
  12483. )
  12484. );
  12485. }
  12486. /// <summary>
  12487. /// Computes the sum of a sequence of <see cref="T:System.Int32" /> values.
  12488. /// </summary>
  12489. /// <param name="source">A sequence of <see cref="T:System.Int32" /> values to calculate the sum of.</param>
  12490. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  12491. /// <exception cref="T:System.ArgumentNullException">
  12492. /// <paramref name="source" /> is null.</exception>
  12493. /// <exception cref="T:System.OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="M:System.Int32.MaxValue" />.</exception>
  12494. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12495. public static IQbservable<int> Sum(this IQbservable<int> source)
  12496. {
  12497. if (source == null)
  12498. throw new ArgumentNullException("source");
  12499. return source.Provider.CreateQuery<int>(
  12500. Expression.Call(
  12501. null,
  12502. #if CRIPPLED_REFLECTION
  12503. InfoOf(() => Qbservable.Sum(default(IQbservable<int>))),
  12504. #else
  12505. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12506. #endif
  12507. source.Expression
  12508. )
  12509. );
  12510. }
  12511. /// <summary>
  12512. /// Computes the sum of a sequence of <see cref="T:System.Int64" /> values.
  12513. /// </summary>
  12514. /// <param name="source">A sequence of <see cref="T:System.Int64" /> values to calculate the sum of.</param>
  12515. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  12516. /// <exception cref="T:System.ArgumentNullException">
  12517. /// <paramref name="source" /> is null.</exception>
  12518. /// <exception cref="T:System.OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue" />.</exception>
  12519. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12520. public static IQbservable<long> Sum(this IQbservable<long> source)
  12521. {
  12522. if (source == null)
  12523. throw new ArgumentNullException("source");
  12524. return source.Provider.CreateQuery<long>(
  12525. Expression.Call(
  12526. null,
  12527. #if CRIPPLED_REFLECTION
  12528. InfoOf(() => Qbservable.Sum(default(IQbservable<long>))),
  12529. #else
  12530. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12531. #endif
  12532. source.Expression
  12533. )
  12534. );
  12535. }
  12536. /// <summary>
  12537. /// Computes the sum of a sequence of nullable <see cref="T:System.Decimal" /> values.
  12538. /// </summary>
  12539. /// <param name="source">A sequence of nullable <see cref="T:System.Decimal" /> values to calculate the sum of.</param>
  12540. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  12541. /// <exception cref="T:System.ArgumentNullException">
  12542. /// <paramref name="source" /> is null.</exception>
  12543. /// <exception cref="T:System.OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="M:System.Decimal.MaxValue" />.</exception>
  12544. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12545. public static IQbservable<decimal?> Sum(this IQbservable<decimal?> source)
  12546. {
  12547. if (source == null)
  12548. throw new ArgumentNullException("source");
  12549. return source.Provider.CreateQuery<decimal?>(
  12550. Expression.Call(
  12551. null,
  12552. #if CRIPPLED_REFLECTION
  12553. InfoOf(() => Qbservable.Sum(default(IQbservable<decimal?>))),
  12554. #else
  12555. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12556. #endif
  12557. source.Expression
  12558. )
  12559. );
  12560. }
  12561. /// <summary>
  12562. /// Computes the sum of a sequence of nullable <see cref="T:System.Double" /> values.
  12563. /// </summary>
  12564. /// <param name="source">A sequence of nullable <see cref="T:System.Double" /> values to calculate the sum of.</param>
  12565. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  12566. /// <exception cref="T:System.ArgumentNullException">
  12567. /// <paramref name="source" /> is null.</exception>
  12568. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12569. public static IQbservable<double?> Sum(this IQbservable<double?> source)
  12570. {
  12571. if (source == null)
  12572. throw new ArgumentNullException("source");
  12573. return source.Provider.CreateQuery<double?>(
  12574. Expression.Call(
  12575. null,
  12576. #if CRIPPLED_REFLECTION
  12577. InfoOf(() => Qbservable.Sum(default(IQbservable<double?>))),
  12578. #else
  12579. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12580. #endif
  12581. source.Expression
  12582. )
  12583. );
  12584. }
  12585. /// <summary>
  12586. /// Computes the sum of a sequence of nullable <see cref="T:System.Int32" /> values.
  12587. /// </summary>
  12588. /// <param name="source">A sequence of nullable <see cref="T:System.Int32" /> values to calculate the sum of.</param>
  12589. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  12590. /// <exception cref="T:System.ArgumentNullException">
  12591. /// <paramref name="source" /> is null.</exception>
  12592. /// <exception cref="T:System.OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="M:System.Int32.MaxValue" />.</exception>
  12593. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12594. public static IQbservable<int?> Sum(this IQbservable<int?> source)
  12595. {
  12596. if (source == null)
  12597. throw new ArgumentNullException("source");
  12598. return source.Provider.CreateQuery<int?>(
  12599. Expression.Call(
  12600. null,
  12601. #if CRIPPLED_REFLECTION
  12602. InfoOf(() => Qbservable.Sum(default(IQbservable<int?>))),
  12603. #else
  12604. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12605. #endif
  12606. source.Expression
  12607. )
  12608. );
  12609. }
  12610. /// <summary>
  12611. /// Computes the sum of a sequence of nullable <see cref="T:System.Int64" /> values.
  12612. /// </summary>
  12613. /// <param name="source">A sequence of nullable <see cref="T:System.Int64" /> values to calculate the sum of.</param>
  12614. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  12615. /// <exception cref="T:System.ArgumentNullException">
  12616. /// <paramref name="source" /> is null.</exception>
  12617. /// <exception cref="T:System.OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue" />.</exception>
  12618. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12619. public static IQbservable<long?> Sum(this IQbservable<long?> source)
  12620. {
  12621. if (source == null)
  12622. throw new ArgumentNullException("source");
  12623. return source.Provider.CreateQuery<long?>(
  12624. Expression.Call(
  12625. null,
  12626. #if CRIPPLED_REFLECTION
  12627. InfoOf(() => Qbservable.Sum(default(IQbservable<long?>))),
  12628. #else
  12629. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12630. #endif
  12631. source.Expression
  12632. )
  12633. );
  12634. }
  12635. /// <summary>
  12636. /// Computes the sum of a sequence of nullable <see cref="T:System.Single" /> values.
  12637. /// </summary>
  12638. /// <param name="source">A sequence of nullable <see cref="T:System.Single" /> values to calculate the sum of.</param>
  12639. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  12640. /// <exception cref="T:System.ArgumentNullException">
  12641. /// <paramref name="source" /> is null.</exception>
  12642. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12643. public static IQbservable<float?> Sum(this IQbservable<float?> source)
  12644. {
  12645. if (source == null)
  12646. throw new ArgumentNullException("source");
  12647. return source.Provider.CreateQuery<float?>(
  12648. Expression.Call(
  12649. null,
  12650. #if CRIPPLED_REFLECTION
  12651. InfoOf(() => Qbservable.Sum(default(IQbservable<float?>))),
  12652. #else
  12653. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12654. #endif
  12655. source.Expression
  12656. )
  12657. );
  12658. }
  12659. /// <summary>
  12660. /// Computes the sum of a sequence of <see cref="T:System.Single" /> values.
  12661. /// </summary>
  12662. /// <param name="source">A sequence of <see cref="T:System.Single" /> values to calculate the sum of.</param>
  12663. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  12664. /// <exception cref="T:System.ArgumentNullException">
  12665. /// <paramref name="source" /> is null.</exception>
  12666. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12667. public static IQbservable<float> Sum(this IQbservable<float> source)
  12668. {
  12669. if (source == null)
  12670. throw new ArgumentNullException("source");
  12671. return source.Provider.CreateQuery<float>(
  12672. Expression.Call(
  12673. null,
  12674. #if CRIPPLED_REFLECTION
  12675. InfoOf(() => Qbservable.Sum(default(IQbservable<float>))),
  12676. #else
  12677. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12678. #endif
  12679. source.Expression
  12680. )
  12681. );
  12682. }
  12683. /// <summary>
  12684. /// Computes the sum of a sequence of <see cref="T:System.Double" /> values that are obtained by invoking a transform function on each element of the input sequence.
  12685. /// </summary>
  12686. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12687. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  12688. /// <param name="selector">A transform function to apply to each element.</param>
  12689. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  12690. /// <exception cref="T:System.ArgumentNullException">
  12691. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  12692. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12693. public static IQbservable<double> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double>> selector)
  12694. {
  12695. if (source == null)
  12696. throw new ArgumentNullException("source");
  12697. if (selector == null)
  12698. throw new ArgumentNullException("selector");
  12699. return source.Provider.CreateQuery<double>(
  12700. Expression.Call(
  12701. null,
  12702. #if CRIPPLED_REFLECTION
  12703. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double>>))),
  12704. #else
  12705. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12706. #endif
  12707. source.Expression,
  12708. selector
  12709. )
  12710. );
  12711. }
  12712. /// <summary>
  12713. /// Computes the sum of a sequence of <see cref="T:System.Single" /> values that are obtained by invoking a transform function on each element of the input sequence.
  12714. /// </summary>
  12715. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12716. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  12717. /// <param name="selector">A transform function to apply to each element.</param>
  12718. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  12719. /// <exception cref="T:System.ArgumentNullException">
  12720. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  12721. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12722. public static IQbservable<float> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float>> selector)
  12723. {
  12724. if (source == null)
  12725. throw new ArgumentNullException("source");
  12726. if (selector == null)
  12727. throw new ArgumentNullException("selector");
  12728. return source.Provider.CreateQuery<float>(
  12729. Expression.Call(
  12730. null,
  12731. #if CRIPPLED_REFLECTION
  12732. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float>>))),
  12733. #else
  12734. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12735. #endif
  12736. source.Expression,
  12737. selector
  12738. )
  12739. );
  12740. }
  12741. /// <summary>
  12742. /// Computes the sum of a sequence of <see cref="T:System.Decimal" /> values that are obtained by invoking a transform function on each element of the input sequence.
  12743. /// </summary>
  12744. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12745. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  12746. /// <param name="selector">A transform function to apply to each element.</param>
  12747. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  12748. /// <exception cref="T:System.ArgumentNullException">
  12749. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  12750. /// <exception cref="T:System.OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="M:System.Decimal.MaxValue" />.</exception>
  12751. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12752. public static IQbservable<decimal> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal>> selector)
  12753. {
  12754. if (source == null)
  12755. throw new ArgumentNullException("source");
  12756. if (selector == null)
  12757. throw new ArgumentNullException("selector");
  12758. return source.Provider.CreateQuery<decimal>(
  12759. Expression.Call(
  12760. null,
  12761. #if CRIPPLED_REFLECTION
  12762. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal>>))),
  12763. #else
  12764. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12765. #endif
  12766. source.Expression,
  12767. selector
  12768. )
  12769. );
  12770. }
  12771. /// <summary>
  12772. /// Computes the sum of a sequence of <see cref="T:System.Int32" /> values that are obtained by invoking a transform function on each element of the input sequence.
  12773. /// </summary>
  12774. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12775. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  12776. /// <param name="selector">A transform function to apply to each element.</param>
  12777. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  12778. /// <exception cref="T:System.ArgumentNullException">
  12779. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  12780. /// <exception cref="T:System.OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="M:System.Int32.MaxValue" />.</exception>
  12781. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12782. public static IQbservable<int> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int>> selector)
  12783. {
  12784. if (source == null)
  12785. throw new ArgumentNullException("source");
  12786. if (selector == null)
  12787. throw new ArgumentNullException("selector");
  12788. return source.Provider.CreateQuery<int>(
  12789. Expression.Call(
  12790. null,
  12791. #if CRIPPLED_REFLECTION
  12792. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int>>))),
  12793. #else
  12794. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12795. #endif
  12796. source.Expression,
  12797. selector
  12798. )
  12799. );
  12800. }
  12801. /// <summary>
  12802. /// Computes the sum of a sequence of <see cref="T:System.Int64" /> values that are obtained by invoking a transform function on each element of the input sequence.
  12803. /// </summary>
  12804. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12805. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  12806. /// <param name="selector">A transform function to apply to each element.</param>
  12807. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  12808. /// <exception cref="T:System.ArgumentNullException">
  12809. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  12810. /// <exception cref="T:System.OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue" />.</exception>
  12811. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12812. public static IQbservable<long> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long>> selector)
  12813. {
  12814. if (source == null)
  12815. throw new ArgumentNullException("source");
  12816. if (selector == null)
  12817. throw new ArgumentNullException("selector");
  12818. return source.Provider.CreateQuery<long>(
  12819. Expression.Call(
  12820. null,
  12821. #if CRIPPLED_REFLECTION
  12822. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long>>))),
  12823. #else
  12824. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12825. #endif
  12826. source.Expression,
  12827. selector
  12828. )
  12829. );
  12830. }
  12831. /// <summary>
  12832. /// Computes the sum of a sequence of nullable <see cref="T:System.Double" /> values that are obtained by invoking a transform function on each element of the input sequence.
  12833. /// </summary>
  12834. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12835. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  12836. /// <param name="selector">A transform function to apply to each element.</param>
  12837. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  12838. /// <exception cref="T:System.ArgumentNullException">
  12839. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  12840. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12841. public static IQbservable<double?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double?>> selector)
  12842. {
  12843. if (source == null)
  12844. throw new ArgumentNullException("source");
  12845. if (selector == null)
  12846. throw new ArgumentNullException("selector");
  12847. return source.Provider.CreateQuery<double?>(
  12848. Expression.Call(
  12849. null,
  12850. #if CRIPPLED_REFLECTION
  12851. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double?>>))),
  12852. #else
  12853. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12854. #endif
  12855. source.Expression,
  12856. selector
  12857. )
  12858. );
  12859. }
  12860. /// <summary>
  12861. /// Computes the sum of a sequence of nullable <see cref="T:System.Single" /> values that are obtained by invoking a transform function on each element of the input sequence.
  12862. /// </summary>
  12863. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12864. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  12865. /// <param name="selector">A transform function to apply to each element.</param>
  12866. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  12867. /// <exception cref="T:System.ArgumentNullException">
  12868. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  12869. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12870. public static IQbservable<float?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float?>> selector)
  12871. {
  12872. if (source == null)
  12873. throw new ArgumentNullException("source");
  12874. if (selector == null)
  12875. throw new ArgumentNullException("selector");
  12876. return source.Provider.CreateQuery<float?>(
  12877. Expression.Call(
  12878. null,
  12879. #if CRIPPLED_REFLECTION
  12880. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float?>>))),
  12881. #else
  12882. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12883. #endif
  12884. source.Expression,
  12885. selector
  12886. )
  12887. );
  12888. }
  12889. /// <summary>
  12890. /// Computes the sum of a sequence of nullable <see cref="T:System.Decimal" /> values that are obtained by invoking a transform function on each element of the input sequence.
  12891. /// </summary>
  12892. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12893. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  12894. /// <param name="selector">A transform function to apply to each element.</param>
  12895. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  12896. /// <exception cref="T:System.ArgumentNullException">
  12897. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  12898. /// <exception cref="T:System.OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="M:System.Decimal.MaxValue" />.</exception>
  12899. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12900. public static IQbservable<decimal?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal?>> selector)
  12901. {
  12902. if (source == null)
  12903. throw new ArgumentNullException("source");
  12904. if (selector == null)
  12905. throw new ArgumentNullException("selector");
  12906. return source.Provider.CreateQuery<decimal?>(
  12907. Expression.Call(
  12908. null,
  12909. #if CRIPPLED_REFLECTION
  12910. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal?>>))),
  12911. #else
  12912. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12913. #endif
  12914. source.Expression,
  12915. selector
  12916. )
  12917. );
  12918. }
  12919. /// <summary>
  12920. /// Computes the sum of a sequence of nullable <see cref="T:System.Int32" /> values that are obtained by invoking a transform function on each element of the input sequence.
  12921. /// </summary>
  12922. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12923. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  12924. /// <param name="selector">A transform function to apply to each element.</param>
  12925. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  12926. /// <exception cref="T:System.ArgumentNullException">
  12927. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  12928. /// <exception cref="T:System.OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="M:System.Int32.MaxValue" />.</exception>
  12929. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12930. public static IQbservable<int?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int?>> selector)
  12931. {
  12932. if (source == null)
  12933. throw new ArgumentNullException("source");
  12934. if (selector == null)
  12935. throw new ArgumentNullException("selector");
  12936. return source.Provider.CreateQuery<int?>(
  12937. Expression.Call(
  12938. null,
  12939. #if CRIPPLED_REFLECTION
  12940. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int?>>))),
  12941. #else
  12942. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12943. #endif
  12944. source.Expression,
  12945. selector
  12946. )
  12947. );
  12948. }
  12949. /// <summary>
  12950. /// Computes the sum of a sequence of nullable <see cref="T:System.Int64" /> values that are obtained by invoking a transform function on each element of the input sequence.
  12951. /// </summary>
  12952. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12953. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  12954. /// <param name="selector">A transform function to apply to each element.</param>
  12955. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  12956. /// <exception cref="T:System.ArgumentNullException">
  12957. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  12958. /// <exception cref="T:System.OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue" />.</exception>
  12959. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12960. public static IQbservable<long?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long?>> selector)
  12961. {
  12962. if (source == null)
  12963. throw new ArgumentNullException("source");
  12964. if (selector == null)
  12965. throw new ArgumentNullException("selector");
  12966. return source.Provider.CreateQuery<long?>(
  12967. Expression.Call(
  12968. null,
  12969. #if CRIPPLED_REFLECTION
  12970. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long?>>))),
  12971. #else
  12972. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12973. #endif
  12974. source.Expression,
  12975. selector
  12976. )
  12977. );
  12978. }
  12979. /// <summary>
  12980. /// Switches between the inner observable sequences such that the resulting sequence always produces elements from the most recently received inner observable sequence.
  12981. /// Each time a new inner observable sequence is received, the previous inner observable sequence is unsubscribed from.
  12982. /// </summary>
  12983. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  12984. /// <param name="sources">Observable sequence of inner observable sequences.</param>
  12985. /// <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>
  12986. /// <exception cref="T:System.ArgumentNullException">
  12987. /// <paramref name="sources" /> is null.</exception>
  12988. public static IQbservable<TSource> Switch<TSource>(this IQbservable<IObservable<TSource>> sources)
  12989. {
  12990. if (sources == null)
  12991. throw new ArgumentNullException("sources");
  12992. return sources.Provider.CreateQuery<TSource>(
  12993. Expression.Call(
  12994. null,
  12995. #if CRIPPLED_REFLECTION
  12996. InfoOf(() => Qbservable.Switch<TSource>(default(IQbservable<IObservable<TSource>>))),
  12997. #else
  12998. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12999. #endif
  13000. sources.Expression
  13001. )
  13002. );
  13003. }
  13004. #if !NO_TPL
  13005. /// <summary>
  13006. /// Switches between the tasks such that the resulting sequence always produces results from the most recently received task.
  13007. /// Each time a new task is received, the previous task's result is ignored.
  13008. /// </summary>
  13009. /// <typeparam name="TSource">The type of the results produced by the source tasks.</typeparam>
  13010. /// <param name="sources">Observable sequence of tasks.</param>
  13011. /// <returns>The observable sequence that at any point in time produces the result of the most recent task that has been received.</returns>
  13012. /// <exception cref="T:System.ArgumentNullException">
  13013. /// <paramref name="sources" /> is null.</exception>
  13014. /// <remarks>If the tasks support cancellation, consider manual conversion of the tasks using <see cref="M:System.Reactive.Linq.Observable.FromAsync``1(System.Func{System.Threading.CancellationToken,System.Threading.Tasks.Task{``0}})" />, followed by a switch operation using <see cref="M:System.Reactive.Linq.Observable.Switch``1(System.IObservable{System.IObservable{``0}})" />.</remarks>
  13015. public static IQbservable<TSource> Switch<TSource>(this IQbservable<Task<TSource>> sources)
  13016. {
  13017. if (sources == null)
  13018. throw new ArgumentNullException("sources");
  13019. return sources.Provider.CreateQuery<TSource>(
  13020. Expression.Call(
  13021. null,
  13022. #if CRIPPLED_REFLECTION
  13023. InfoOf(() => Qbservable.Switch<TSource>(default(IQbservable<Task<TSource>>))),
  13024. #else
  13025. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13026. #endif
  13027. sources.Expression
  13028. )
  13029. );
  13030. }
  13031. #endif
  13032. /// <summary>
  13033. /// Synchronizes the observable sequence such that observer notifications cannot be delivered concurrently.
  13034. /// This overload is useful to "fix" an observable sequence that exhibits concurrent callbacks on individual observers, which is invalid behavior for the query processor.
  13035. /// </summary>
  13036. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13037. /// <param name="source">Source sequence.</param>
  13038. /// <returns>The source sequence whose outgoing calls to observers are synchronized.</returns>
  13039. /// <exception cref="T:System.ArgumentNullException">
  13040. /// <paramref name="source" /> is null.</exception>
  13041. /// <remarks>
  13042. /// It's invalid behavior - according to the observer grammar - for a sequence to exhibit concurrent callbacks on a given observer.
  13043. /// This operator can be used to "fix" a source that doesn't conform to this rule.
  13044. /// </remarks>
  13045. public static IQbservable<TSource> Synchronize<TSource>(this IQbservable<TSource> source)
  13046. {
  13047. if (source == null)
  13048. throw new ArgumentNullException("source");
  13049. return source.Provider.CreateQuery<TSource>(
  13050. Expression.Call(
  13051. null,
  13052. #if CRIPPLED_REFLECTION
  13053. InfoOf(() => Qbservable.Synchronize<TSource>(default(IQbservable<TSource>))),
  13054. #else
  13055. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13056. #endif
  13057. source.Expression
  13058. )
  13059. );
  13060. }
  13061. /// <summary>
  13062. /// Synchronizes the observable sequence such that observer notifications cannot be delivered concurrently, using the specified gate object.
  13063. /// 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.
  13064. /// </summary>
  13065. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13066. /// <param name="source">Source sequence.</param>
  13067. /// <param name="gate">Gate object to synchronize each observer call on.</param>
  13068. /// <returns>The source sequence whose outgoing calls to observers are synchronized on the given gate object.</returns>
  13069. /// <exception cref="T:System.ArgumentNullException">
  13070. /// <paramref name="source" /> or <paramref name="gate" /> is null.</exception>
  13071. public static IQbservable<TSource> Synchronize<TSource>(this IQbservable<TSource> source, object gate)
  13072. {
  13073. if (source == null)
  13074. throw new ArgumentNullException("source");
  13075. if (gate == null)
  13076. throw new ArgumentNullException("gate");
  13077. return source.Provider.CreateQuery<TSource>(
  13078. Expression.Call(
  13079. null,
  13080. #if CRIPPLED_REFLECTION
  13081. InfoOf(() => Qbservable.Synchronize<TSource>(default(IQbservable<TSource>), default(object))),
  13082. #else
  13083. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13084. #endif
  13085. source.Expression,
  13086. Expression.Constant(gate, typeof(object))
  13087. )
  13088. );
  13089. }
  13090. /// <summary>
  13091. /// Returns a specified number of contiguous elements from the start of an observable sequence.
  13092. /// </summary>
  13093. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13094. /// <param name="source">The sequence to take elements from.</param>
  13095. /// <param name="count">The number of elements to return.</param>
  13096. /// <returns>An observable sequence that contains the specified number of elements from the start of the input sequence.</returns>
  13097. /// <exception cref="T:System.ArgumentNullException">
  13098. /// <paramref name="source" /> is null.</exception>
  13099. /// <exception cref="T:System.ArgumentOutOfRangeException">
  13100. /// <paramref name="count" /> is less than zero.</exception>
  13101. public static IQbservable<TSource> Take<TSource>(this IQbservable<TSource> source, int count)
  13102. {
  13103. if (source == null)
  13104. throw new ArgumentNullException("source");
  13105. return source.Provider.CreateQuery<TSource>(
  13106. Expression.Call(
  13107. null,
  13108. #if CRIPPLED_REFLECTION
  13109. InfoOf(() => Qbservable.Take<TSource>(default(IQbservable<TSource>), default(int))),
  13110. #else
  13111. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13112. #endif
  13113. source.Expression,
  13114. Expression.Constant(count, typeof(int))
  13115. )
  13116. );
  13117. }
  13118. /// <summary>
  13119. /// 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).
  13120. /// </summary>
  13121. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13122. /// <param name="source">The sequence to take elements from.</param>
  13123. /// <param name="count">The number of elements to return.</param>
  13124. /// <param name="scheduler">Scheduler used to produce an OnCompleted message in case <paramref name="count">count</paramref> is set to 0.</param>
  13125. /// <returns>An observable sequence that contains the specified number of elements from the start of the input sequence.</returns>
  13126. /// <exception cref="T:System.ArgumentNullException">
  13127. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13128. /// <exception cref="T:System.ArgumentOutOfRangeException">
  13129. /// <paramref name="count" /> is less than zero.</exception>
  13130. public static IQbservable<TSource> Take<TSource>(this IQbservable<TSource> source, int count, IScheduler scheduler)
  13131. {
  13132. if (source == null)
  13133. throw new ArgumentNullException("source");
  13134. if (scheduler == null)
  13135. throw new ArgumentNullException("scheduler");
  13136. return source.Provider.CreateQuery<TSource>(
  13137. Expression.Call(
  13138. null,
  13139. #if CRIPPLED_REFLECTION
  13140. InfoOf(() => Qbservable.Take<TSource>(default(IQbservable<TSource>), default(int), default(IScheduler))),
  13141. #else
  13142. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13143. #endif
  13144. source.Expression,
  13145. Expression.Constant(count, typeof(int)),
  13146. Expression.Constant(scheduler, typeof(IScheduler))
  13147. )
  13148. );
  13149. }
  13150. /// <summary>
  13151. /// Takes elements for the specified duration from the start of the observable source sequence.
  13152. /// </summary>
  13153. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13154. /// <param name="source">Source sequence to take elements from.</param>
  13155. /// <param name="duration">Duration for taking elements from the start of the sequence.</param>
  13156. /// <returns>An observable sequence with the elements taken during the specified duration from the start of the source sequence.</returns>
  13157. /// <exception cref="T:System.ArgumentNullException">
  13158. /// <paramref name="source" /> is null.</exception>
  13159. /// <exception cref="T:System.ArgumentOutOfRangeException">
  13160. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  13161. /// <remarks>
  13162. /// Specifying a TimeSpan.Zero value for <paramref name="duration" /> doesn't guarantee an empty sequence will be returned. This is a side-effect
  13163. /// of the asynchrony introduced by the scheduler, where the action that stops forwarding callbacks from the source sequence may not execute
  13164. /// immediately, despite the TimeSpan.Zero due time.
  13165. /// </remarks>
  13166. public static IQbservable<TSource> Take<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  13167. {
  13168. if (source == null)
  13169. throw new ArgumentNullException("source");
  13170. return source.Provider.CreateQuery<TSource>(
  13171. Expression.Call(
  13172. null,
  13173. #if CRIPPLED_REFLECTION
  13174. InfoOf(() => Qbservable.Take<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  13175. #else
  13176. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13177. #endif
  13178. source.Expression,
  13179. Expression.Constant(duration, typeof(TimeSpan))
  13180. )
  13181. );
  13182. }
  13183. /// <summary>
  13184. /// Takes elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers.
  13185. /// </summary>
  13186. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13187. /// <param name="source">Source sequence to take elements from.</param>
  13188. /// <param name="duration">Duration for taking elements from the start of the sequence.</param>
  13189. /// <param name="scheduler">Scheduler to run the timer on.</param>
  13190. /// <returns>An observable sequence with the elements taken during the specified duration from the start of the source sequence.</returns>
  13191. /// <exception cref="T:System.ArgumentNullException">
  13192. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13193. /// <exception cref="T:System.ArgumentOutOfRangeException">
  13194. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  13195. /// <remarks>
  13196. /// Specifying a TimeSpan.Zero value for <paramref name="duration" /> doesn't guarantee an empty sequence will be returned. This is a side-effect
  13197. /// of the asynchrony introduced by the scheduler, where the action that stops forwarding callbacks from the source sequence may not execute
  13198. /// immediately, despite the TimeSpan.Zero due time.
  13199. /// </remarks>
  13200. public static IQbservable<TSource> Take<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  13201. {
  13202. if (source == null)
  13203. throw new ArgumentNullException("source");
  13204. if (scheduler == null)
  13205. throw new ArgumentNullException("scheduler");
  13206. return source.Provider.CreateQuery<TSource>(
  13207. Expression.Call(
  13208. null,
  13209. #if CRIPPLED_REFLECTION
  13210. InfoOf(() => Qbservable.Take<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  13211. #else
  13212. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13213. #endif
  13214. source.Expression,
  13215. Expression.Constant(duration, typeof(TimeSpan)),
  13216. Expression.Constant(scheduler, typeof(IScheduler))
  13217. )
  13218. );
  13219. }
  13220. /// <summary>
  13221. /// Returns a specified number of contiguous elements from the end of an observable sequence.
  13222. /// </summary>
  13223. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13224. /// <param name="source">Source sequence.</param>
  13225. /// <param name="count">Number of elements to take from the end of the source sequence.</param>
  13226. /// <returns>An observable sequence containing the specified number of elements from the end of the source sequence.</returns>
  13227. /// <exception cref="T:System.ArgumentNullException">
  13228. /// <paramref name="source" /> is null.</exception>
  13229. /// <exception cref="T:System.ArgumentOutOfRangeException">
  13230. /// <paramref name="count" /> is less than zero.</exception>
  13231. /// <remarks>
  13232. /// This operator accumulates a buffer with a length enough to store elements <paramref name="count" /> elements. Upon completion of
  13233. /// the source sequence, this buffer is drained on the result sequence. This causes the elements to be delayed.
  13234. /// </remarks>
  13235. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, int count)
  13236. {
  13237. if (source == null)
  13238. throw new ArgumentNullException("source");
  13239. return source.Provider.CreateQuery<TSource>(
  13240. Expression.Call(
  13241. null,
  13242. #if CRIPPLED_REFLECTION
  13243. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(int))),
  13244. #else
  13245. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13246. #endif
  13247. source.Expression,
  13248. Expression.Constant(count, typeof(int))
  13249. )
  13250. );
  13251. }
  13252. /// <summary>
  13253. /// Returns a specified number of contiguous elements from the end of an observable sequence, using the specified scheduler to drain the queue.
  13254. /// </summary>
  13255. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13256. /// <param name="source">Source sequence.</param>
  13257. /// <param name="count">Number of elements to take from the end of the source sequence.</param>
  13258. /// <param name="scheduler">Scheduler used to drain the queue upon completion of the source sequence.</param>
  13259. /// <returns>An observable sequence containing the specified number of elements from the end of the source sequence.</returns>
  13260. /// <exception cref="T:System.ArgumentNullException">
  13261. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13262. /// <exception cref="T:System.ArgumentOutOfRangeException">
  13263. /// <paramref name="count" /> is less than zero.</exception>
  13264. /// <remarks>
  13265. /// This operator accumulates a buffer with a length enough to store elements <paramref name="count" /> elements. Upon completion of
  13266. /// the source sequence, this buffer is drained on the result sequence. This causes the elements to be delayed.
  13267. /// </remarks>
  13268. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, int count, IScheduler scheduler)
  13269. {
  13270. if (source == null)
  13271. throw new ArgumentNullException("source");
  13272. if (scheduler == null)
  13273. throw new ArgumentNullException("scheduler");
  13274. return source.Provider.CreateQuery<TSource>(
  13275. Expression.Call(
  13276. null,
  13277. #if CRIPPLED_REFLECTION
  13278. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(int), default(IScheduler))),
  13279. #else
  13280. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13281. #endif
  13282. source.Expression,
  13283. Expression.Constant(count, typeof(int)),
  13284. Expression.Constant(scheduler, typeof(IScheduler))
  13285. )
  13286. );
  13287. }
  13288. /// <summary>
  13289. /// Returns elements within the specified duration from the end of the observable source sequence.
  13290. /// </summary>
  13291. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13292. /// <param name="source">Source sequence to take elements from.</param>
  13293. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  13294. /// <returns>An observable sequence with the elements taken during the specified duration from the end of the source sequence.</returns>
  13295. /// <exception cref="T:System.ArgumentNullException">
  13296. /// <paramref name="source" /> is null.</exception>
  13297. /// <exception cref="T:System.ArgumentOutOfRangeException">
  13298. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  13299. /// <remarks>
  13300. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  13301. /// the source sequence. Upon completion of the source sequence, this buffer is drained on the result sequence. This causes the result elements
  13302. /// to be delayed with <paramref name="duration" />.
  13303. /// </remarks>
  13304. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  13305. {
  13306. if (source == null)
  13307. throw new ArgumentNullException("source");
  13308. return source.Provider.CreateQuery<TSource>(
  13309. Expression.Call(
  13310. null,
  13311. #if CRIPPLED_REFLECTION
  13312. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  13313. #else
  13314. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13315. #endif
  13316. source.Expression,
  13317. Expression.Constant(duration, typeof(TimeSpan))
  13318. )
  13319. );
  13320. }
  13321. /// <summary>
  13322. /// Returns elements within the specified duration from the end of the observable source sequence, using the specified scheduler to run timers.
  13323. /// </summary>
  13324. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13325. /// <param name="source">Source sequence to take elements from.</param>
  13326. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  13327. /// <param name="scheduler">Scheduler to run the timer on.</param>
  13328. /// <returns>An observable sequence with the elements taken during the specified duration from the end of the source sequence.</returns>
  13329. /// <exception cref="T:System.ArgumentNullException">
  13330. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13331. /// <exception cref="T:System.ArgumentOutOfRangeException">
  13332. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  13333. /// <remarks>
  13334. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  13335. /// the source sequence. Upon completion of the source sequence, this buffer is drained on the result sequence. This causes the result elements
  13336. /// to be delayed with <paramref name="duration" />.
  13337. /// </remarks>
  13338. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  13339. {
  13340. if (source == null)
  13341. throw new ArgumentNullException("source");
  13342. if (scheduler == null)
  13343. throw new ArgumentNullException("scheduler");
  13344. return source.Provider.CreateQuery<TSource>(
  13345. Expression.Call(
  13346. null,
  13347. #if CRIPPLED_REFLECTION
  13348. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  13349. #else
  13350. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13351. #endif
  13352. source.Expression,
  13353. Expression.Constant(duration, typeof(TimeSpan)),
  13354. Expression.Constant(scheduler, typeof(IScheduler))
  13355. )
  13356. );
  13357. }
  13358. /// <summary>
  13359. /// 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.
  13360. /// </summary>
  13361. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13362. /// <param name="source">Source sequence to take elements from.</param>
  13363. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  13364. /// <param name="timerScheduler">Scheduler to run the timer on.</param>
  13365. /// <param name="loopScheduler">Scheduler to drain the collected elements.</param>
  13366. /// <returns>An observable sequence with the elements taken during the specified duration from the end of the source sequence.</returns>
  13367. /// <exception cref="T:System.ArgumentNullException">
  13368. /// <paramref name="source" /> or <paramref name="timerScheduler" /> or <paramref name="loopScheduler" /> is null.</exception>
  13369. /// <exception cref="T:System.ArgumentOutOfRangeException">
  13370. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  13371. /// <remarks>
  13372. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  13373. /// the source sequence. Upon completion of the source sequence, this buffer is drained on the result sequence. This causes the result elements
  13374. /// to be delayed with <paramref name="duration" />.
  13375. /// </remarks>
  13376. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler timerScheduler, IScheduler loopScheduler)
  13377. {
  13378. if (source == null)
  13379. throw new ArgumentNullException("source");
  13380. if (timerScheduler == null)
  13381. throw new ArgumentNullException("timerScheduler");
  13382. if (loopScheduler == null)
  13383. throw new ArgumentNullException("loopScheduler");
  13384. return source.Provider.CreateQuery<TSource>(
  13385. Expression.Call(
  13386. null,
  13387. #if CRIPPLED_REFLECTION
  13388. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler), default(IScheduler))),
  13389. #else
  13390. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13391. #endif
  13392. source.Expression,
  13393. Expression.Constant(duration, typeof(TimeSpan)),
  13394. Expression.Constant(timerScheduler, typeof(IScheduler)),
  13395. Expression.Constant(loopScheduler, typeof(IScheduler))
  13396. )
  13397. );
  13398. }
  13399. /// <summary>
  13400. /// Returns a list with the specified number of contiguous elements from the end of an observable sequence.
  13401. /// </summary>
  13402. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13403. /// <param name="source">Source sequence.</param>
  13404. /// <param name="count">Number of elements to take from the end of the source sequence.</param>
  13405. /// <returns>An observable sequence containing a single list with the specified number of elements from the end of the source sequence.</returns>
  13406. /// <exception cref="T:System.ArgumentNullException">
  13407. /// <paramref name="source" /> is null.</exception>
  13408. /// <exception cref="T:System.ArgumentOutOfRangeException">
  13409. /// <paramref name="count" /> is less than zero.</exception>
  13410. /// <remarks>
  13411. /// This operator accumulates a buffer with a length enough to store <paramref name="count" /> elements. Upon completion of the
  13412. /// source sequence, this buffer is produced on the result sequence.
  13413. /// </remarks>
  13414. public static IQbservable<IList<TSource>> TakeLastBuffer<TSource>(this IQbservable<TSource> source, int count)
  13415. {
  13416. if (source == null)
  13417. throw new ArgumentNullException("source");
  13418. return source.Provider.CreateQuery<IList<TSource>>(
  13419. Expression.Call(
  13420. null,
  13421. #if CRIPPLED_REFLECTION
  13422. InfoOf(() => Qbservable.TakeLastBuffer<TSource>(default(IQbservable<TSource>), default(int))),
  13423. #else
  13424. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13425. #endif
  13426. source.Expression,
  13427. Expression.Constant(count, typeof(int))
  13428. )
  13429. );
  13430. }
  13431. /// <summary>
  13432. /// Returns a list with the elements within the specified duration from the end of the observable source sequence.
  13433. /// </summary>
  13434. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13435. /// <param name="source">Source sequence to take elements from.</param>
  13436. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  13437. /// <returns>An observable sequence containing a single list with the elements taken during the specified duration from the end of the source sequence.</returns>
  13438. /// <exception cref="T:System.ArgumentNullException">
  13439. /// <paramref name="source" /> is null.</exception>
  13440. /// <exception cref="T:System.ArgumentOutOfRangeException">
  13441. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  13442. /// <remarks>
  13443. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  13444. /// the source sequence. Upon completion of the source sequence, this buffer is produced on the result sequence.
  13445. /// </remarks>
  13446. public static IQbservable<IList<TSource>> TakeLastBuffer<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  13447. {
  13448. if (source == null)
  13449. throw new ArgumentNullException("source");
  13450. return source.Provider.CreateQuery<IList<TSource>>(
  13451. Expression.Call(
  13452. null,
  13453. #if CRIPPLED_REFLECTION
  13454. InfoOf(() => Qbservable.TakeLastBuffer<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  13455. #else
  13456. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13457. #endif
  13458. source.Expression,
  13459. Expression.Constant(duration, typeof(TimeSpan))
  13460. )
  13461. );
  13462. }
  13463. /// <summary>
  13464. /// 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.
  13465. /// </summary>
  13466. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13467. /// <param name="source">Source sequence to take elements from.</param>
  13468. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  13469. /// <param name="scheduler">Scheduler to run the timer on.</param>
  13470. /// <returns>An observable sequence containing a single list with the elements taken during the specified duration from the end of the source sequence.</returns>
  13471. /// <exception cref="T:System.ArgumentNullException">
  13472. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13473. /// <exception cref="T:System.ArgumentOutOfRangeException">
  13474. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  13475. /// <remarks>
  13476. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  13477. /// the source sequence. Upon completion of the source sequence, this buffer is produced on the result sequence.
  13478. /// </remarks>
  13479. public static IQbservable<IList<TSource>> TakeLastBuffer<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  13480. {
  13481. if (source == null)
  13482. throw new ArgumentNullException("source");
  13483. if (scheduler == null)
  13484. throw new ArgumentNullException("scheduler");
  13485. return source.Provider.CreateQuery<IList<TSource>>(
  13486. Expression.Call(
  13487. null,
  13488. #if CRIPPLED_REFLECTION
  13489. InfoOf(() => Qbservable.TakeLastBuffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  13490. #else
  13491. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13492. #endif
  13493. source.Expression,
  13494. Expression.Constant(duration, typeof(TimeSpan)),
  13495. Expression.Constant(scheduler, typeof(IScheduler))
  13496. )
  13497. );
  13498. }
  13499. /// <summary>
  13500. /// Takes elements for the specified duration until the specified end time.
  13501. /// </summary>
  13502. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13503. /// <param name="source">Source sequence to take elements from.</param>
  13504. /// <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>
  13505. /// <returns>An observable sequence with the elements taken until the specified end time.</returns>
  13506. /// <exception cref="T:System.ArgumentNullException">
  13507. /// <paramref name="source" /> is null.</exception>
  13508. public static IQbservable<TSource> TakeUntil<TSource>(this IQbservable<TSource> source, DateTimeOffset endTime)
  13509. {
  13510. if (source == null)
  13511. throw new ArgumentNullException("source");
  13512. return source.Provider.CreateQuery<TSource>(
  13513. Expression.Call(
  13514. null,
  13515. #if CRIPPLED_REFLECTION
  13516. InfoOf(() => Qbservable.TakeUntil<TSource>(default(IQbservable<TSource>), default(DateTimeOffset))),
  13517. #else
  13518. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13519. #endif
  13520. source.Expression,
  13521. Expression.Constant(endTime, typeof(DateTimeOffset))
  13522. )
  13523. );
  13524. }
  13525. /// <summary>
  13526. /// Takes elements for the specified duration until the specified end time, using the specified scheduler to run timers.
  13527. /// </summary>
  13528. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13529. /// <param name="source">Source sequence to take elements from.</param>
  13530. /// <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>
  13531. /// <param name="scheduler">Scheduler to run the timer on.</param>
  13532. /// <returns>An observable sequence with the elements taken until the specified end time.</returns>
  13533. /// <exception cref="T:System.ArgumentNullException">
  13534. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13535. public static IQbservable<TSource> TakeUntil<TSource>(this IQbservable<TSource> source, DateTimeOffset endTime, IScheduler scheduler)
  13536. {
  13537. if (source == null)
  13538. throw new ArgumentNullException("source");
  13539. if (scheduler == null)
  13540. throw new ArgumentNullException("scheduler");
  13541. return source.Provider.CreateQuery<TSource>(
  13542. Expression.Call(
  13543. null,
  13544. #if CRIPPLED_REFLECTION
  13545. InfoOf(() => Qbservable.TakeUntil<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IScheduler))),
  13546. #else
  13547. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13548. #endif
  13549. source.Expression,
  13550. Expression.Constant(endTime, typeof(DateTimeOffset)),
  13551. Expression.Constant(scheduler, typeof(IScheduler))
  13552. )
  13553. );
  13554. }
  13555. /// <summary>
  13556. /// Returns the elements from the source observable sequence until the other observable sequence produces an element.
  13557. /// </summary>
  13558. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13559. /// <typeparam name="TOther">The type of the elements in the other sequence that indicates the end of take behavior.</typeparam>
  13560. /// <param name="source">Source sequence to propagate elements for.</param>
  13561. /// <param name="other">Observable sequence that terminates propagation of elements of the source sequence.</param>
  13562. /// <returns>An observable sequence containing the elements of the source sequence up to the point the other sequence interrupted further propagation.</returns>
  13563. /// <exception cref="T:System.ArgumentNullException">
  13564. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  13565. public static IQbservable<TSource> TakeUntil<TSource, TOther>(this IQbservable<TSource> source, IObservable<TOther> other)
  13566. {
  13567. if (source == null)
  13568. throw new ArgumentNullException("source");
  13569. if (other == null)
  13570. throw new ArgumentNullException("other");
  13571. return source.Provider.CreateQuery<TSource>(
  13572. Expression.Call(
  13573. null,
  13574. #if CRIPPLED_REFLECTION
  13575. InfoOf(() => Qbservable.TakeUntil<TSource, TOther>(default(IQbservable<TSource>), default(IObservable<TOther>))),
  13576. #else
  13577. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)),
  13578. #endif
  13579. source.Expression,
  13580. GetSourceExpression(other)
  13581. )
  13582. );
  13583. }
  13584. /// <summary>
  13585. /// Returns elements from an observable sequence as long as a specified condition is true.
  13586. /// </summary>
  13587. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13588. /// <param name="source">A sequence to return elements from.</param>
  13589. /// <param name="predicate">A function to test each element for a condition.</param>
  13590. /// <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>
  13591. /// <exception cref="T:System.ArgumentNullException">
  13592. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  13593. public static IQbservable<TSource> TakeWhile<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  13594. {
  13595. if (source == null)
  13596. throw new ArgumentNullException("source");
  13597. if (predicate == null)
  13598. throw new ArgumentNullException("predicate");
  13599. return source.Provider.CreateQuery<TSource>(
  13600. Expression.Call(
  13601. null,
  13602. #if CRIPPLED_REFLECTION
  13603. InfoOf(() => Qbservable.TakeWhile<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  13604. #else
  13605. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13606. #endif
  13607. source.Expression,
  13608. predicate
  13609. )
  13610. );
  13611. }
  13612. /// <summary>
  13613. /// Returns elements from an observable sequence as long as a specified condition is true.
  13614. /// The element's index is used in the logic of the predicate function.
  13615. /// </summary>
  13616. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13617. /// <param name="source">A sequence to return elements from.</param>
  13618. /// <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>
  13619. /// <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>
  13620. /// <exception cref="T:System.ArgumentNullException">
  13621. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  13622. public static IQbservable<TSource> TakeWhile<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int, bool>> predicate)
  13623. {
  13624. if (source == null)
  13625. throw new ArgumentNullException("source");
  13626. if (predicate == null)
  13627. throw new ArgumentNullException("predicate");
  13628. return source.Provider.CreateQuery<TSource>(
  13629. Expression.Call(
  13630. null,
  13631. #if CRIPPLED_REFLECTION
  13632. InfoOf(() => Qbservable.TakeWhile<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, bool>>))),
  13633. #else
  13634. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13635. #endif
  13636. source.Expression,
  13637. predicate
  13638. )
  13639. );
  13640. }
  13641. /// <summary>
  13642. /// Ignores elements from an observable sequence which are followed by another element within a specified relative time duration.
  13643. /// </summary>
  13644. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13645. /// <param name="source">Source sequence to throttle.</param>
  13646. /// <param name="dueTime">Throttling duration for each element.</param>
  13647. /// <returns>The throttled sequence.</returns>
  13648. /// <exception cref="T:System.ArgumentNullException">
  13649. /// <paramref name="source" /> is null.</exception>
  13650. /// <exception cref="T:System.ArgumentOutOfRangeException">
  13651. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  13652. /// <remarks>
  13653. /// <para>
  13654. /// This operator throttles the source sequence by holding on to each element for the duration specified in <paramref name="dueTime" />. If another
  13655. /// element is produced within this time window, the element is dropped and a new timer is started for the current element, repeating this whole
  13656. /// process. For streams that never have gaps larger than or equal to <paramref name="dueTime" /> between elements, the resulting stream won't
  13657. /// produce any elements. In order to reduce the volume of a stream whilst guaranteeing the periodic production of elements, consider using the
  13658. /// Observable.Sample set of operators.
  13659. /// </para>
  13660. /// <para>
  13661. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing throttling timers to be scheduled
  13662. /// 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
  13663. /// asynchrony introduced by the scheduler, where the action to forward the current element may not execute immediately, despite the TimeSpan.Zero
  13664. /// due time. In such cases, the next element may arrive before the scheduler gets a chance to run the throttling action.
  13665. /// </para>
  13666. /// </remarks>
  13667. public static IQbservable<TSource> Throttle<TSource>(this IQbservable<TSource> source, TimeSpan dueTime)
  13668. {
  13669. if (source == null)
  13670. throw new ArgumentNullException("source");
  13671. return source.Provider.CreateQuery<TSource>(
  13672. Expression.Call(
  13673. null,
  13674. #if CRIPPLED_REFLECTION
  13675. InfoOf(() => Qbservable.Throttle<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  13676. #else
  13677. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13678. #endif
  13679. source.Expression,
  13680. Expression.Constant(dueTime, typeof(TimeSpan))
  13681. )
  13682. );
  13683. }
  13684. /// <summary>
  13685. /// 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.
  13686. /// </summary>
  13687. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13688. /// <param name="source">Source sequence to throttle.</param>
  13689. /// <param name="dueTime">Throttling duration for each element.</param>
  13690. /// <param name="scheduler">Scheduler to run the throttle timers on.</param>
  13691. /// <returns>The throttled sequence.</returns>
  13692. /// <exception cref="T:System.ArgumentNullException">
  13693. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13694. /// <exception cref="T:System.ArgumentOutOfRangeException">
  13695. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  13696. /// <remarks>
  13697. /// <para>
  13698. /// This operator throttles the source sequence by holding on to each element for the duration specified in <paramref name="dueTime" />. If another
  13699. /// element is produced within this time window, the element is dropped and a new timer is started for the current element, repeating this whole
  13700. /// process. For streams that never have gaps larger than or equal to <paramref name="dueTime" /> between elements, the resulting stream won't
  13701. /// produce any elements. In order to reduce the volume of a stream whilst guaranteeing the periodic production of elements, consider using the
  13702. /// Observable.Sample set of operators.
  13703. /// </para>
  13704. /// <para>
  13705. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing throttling timers to be scheduled
  13706. /// 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
  13707. /// asynchrony introduced by the scheduler, where the action to forward the current element may not execute immediately, despite the TimeSpan.Zero
  13708. /// due time. In such cases, the next element may arrive before the scheduler gets a chance to run the throttling action.
  13709. /// </para>
  13710. /// </remarks>
  13711. public static IQbservable<TSource> Throttle<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IScheduler scheduler)
  13712. {
  13713. if (source == null)
  13714. throw new ArgumentNullException("source");
  13715. if (scheduler == null)
  13716. throw new ArgumentNullException("scheduler");
  13717. return source.Provider.CreateQuery<TSource>(
  13718. Expression.Call(
  13719. null,
  13720. #if CRIPPLED_REFLECTION
  13721. InfoOf(() => Qbservable.Throttle<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  13722. #else
  13723. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13724. #endif
  13725. source.Expression,
  13726. Expression.Constant(dueTime, typeof(TimeSpan)),
  13727. Expression.Constant(scheduler, typeof(IScheduler))
  13728. )
  13729. );
  13730. }
  13731. /// <summary>
  13732. /// Ignores elements from an observable sequence which are followed by another value within a computed throttle duration.
  13733. /// </summary>
  13734. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13735. /// <typeparam name="TThrottle">The type of the elements in the throttle sequences selected for each element in the source sequence.</typeparam>
  13736. /// <param name="source">Source sequence to throttle.</param>
  13737. /// <param name="throttleDurationSelector">Selector function to retrieve a sequence indicating the throttle duration for each given element.</param>
  13738. /// <returns>The throttled sequence.</returns>
  13739. /// <exception cref="T:System.ArgumentNullException">
  13740. /// <paramref name="source" /> or <paramref name="throttleDurationSelector" /> is null.</exception>
  13741. /// <remarks>
  13742. /// This operator throttles the source sequence by holding on to each element for the duration denoted by <paramref name="throttleDurationSelector" />.
  13743. /// 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
  13744. /// whole process. For streams where the duration computed by applying the <paramref name="throttleDurationSelector" /> to each element overlaps with
  13745. /// the occurrence of the successor element, the resulting stream won't produce any elements. In order to reduce the volume of a stream whilst
  13746. /// guaranteeing the periodic production of elements, consider using the Observable.Sample set of operators.
  13747. /// </remarks>
  13748. public static IQbservable<TSource> Throttle<TSource, TThrottle>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TThrottle>>> throttleDurationSelector)
  13749. {
  13750. if (source == null)
  13751. throw new ArgumentNullException("source");
  13752. if (throttleDurationSelector == null)
  13753. throw new ArgumentNullException("throttleDurationSelector");
  13754. return source.Provider.CreateQuery<TSource>(
  13755. Expression.Call(
  13756. null,
  13757. #if CRIPPLED_REFLECTION
  13758. InfoOf(() => Qbservable.Throttle<TSource, TThrottle>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TThrottle>>>))),
  13759. #else
  13760. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TThrottle)),
  13761. #endif
  13762. source.Expression,
  13763. throttleDurationSelector
  13764. )
  13765. );
  13766. }
  13767. /// <summary>
  13768. /// Returns an observable sequence that terminates with an exception.
  13769. /// </summary>
  13770. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  13771. /// <typeparam name="TResult">The type used for the IObservable&lt;T&gt; type parameter of the resulting sequence.</typeparam>
  13772. /// <param name="exception">Exception object used for the sequence's termination.</param>
  13773. /// <returns>The observable sequence that terminates exceptionally with the specified exception object.</returns>
  13774. /// <exception cref="T:System.ArgumentNullException">
  13775. /// <paramref name="exception" /> is null.</exception>
  13776. public static IQbservable<TResult> Throw<TResult>(this IQbservableProvider provider, Exception exception)
  13777. {
  13778. if (provider == null)
  13779. throw new ArgumentNullException("provider");
  13780. if (exception == null)
  13781. throw new ArgumentNullException("exception");
  13782. return provider.CreateQuery<TResult>(
  13783. Expression.Call(
  13784. null,
  13785. #if CRIPPLED_REFLECTION
  13786. InfoOf(() => Qbservable.Throw<TResult>(default(IQbservableProvider), default(Exception))),
  13787. #else
  13788. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  13789. #endif
  13790. Expression.Constant(provider, typeof(IQbservableProvider)),
  13791. Expression.Constant(exception, typeof(Exception))
  13792. )
  13793. );
  13794. }
  13795. /// <summary>
  13796. /// Returns an observable sequence that terminates with an exception, using the specified scheduler to send out the single OnError message.
  13797. /// </summary>
  13798. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  13799. /// <typeparam name="TResult">The type used for the IObservable&lt;T&gt; type parameter of the resulting sequence.</typeparam>
  13800. /// <param name="exception">Exception object used for the sequence's termination.</param>
  13801. /// <param name="scheduler">Scheduler to send the exceptional termination call on.</param>
  13802. /// <returns>The observable sequence that terminates exceptionally with the specified exception object.</returns>
  13803. /// <exception cref="T:System.ArgumentNullException">
  13804. /// <paramref name="exception" /> or <paramref name="scheduler" /> is null.</exception>
  13805. public static IQbservable<TResult> Throw<TResult>(this IQbservableProvider provider, Exception exception, IScheduler scheduler)
  13806. {
  13807. if (provider == null)
  13808. throw new ArgumentNullException("provider");
  13809. if (exception == null)
  13810. throw new ArgumentNullException("exception");
  13811. if (scheduler == null)
  13812. throw new ArgumentNullException("scheduler");
  13813. return provider.CreateQuery<TResult>(
  13814. Expression.Call(
  13815. null,
  13816. #if CRIPPLED_REFLECTION
  13817. InfoOf(() => Qbservable.Throw<TResult>(default(IQbservableProvider), default(Exception), default(IScheduler))),
  13818. #else
  13819. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  13820. #endif
  13821. Expression.Constant(provider, typeof(IQbservableProvider)),
  13822. Expression.Constant(exception, typeof(Exception)),
  13823. Expression.Constant(scheduler, typeof(IScheduler))
  13824. )
  13825. );
  13826. }
  13827. /// <summary>
  13828. /// Returns an observable sequence that terminates with an exception, using the specified scheduler to send out the single OnError message.
  13829. /// </summary>
  13830. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  13831. /// <typeparam name="TResult">The type used for the IObservable&lt;T&gt; type parameter of the resulting sequence.</typeparam>
  13832. /// <param name="exception">Exception object used for the sequence's termination.</param>
  13833. /// <param name="scheduler">Scheduler to send the exceptional termination call on.</param>
  13834. /// <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>
  13835. /// <returns>The observable sequence that terminates exceptionally with the specified exception object.</returns>
  13836. /// <exception cref="T:System.ArgumentNullException">
  13837. /// <paramref name="exception" /> or <paramref name="scheduler" /> is null.</exception>
  13838. public static IQbservable<TResult> Throw<TResult>(this IQbservableProvider provider, Exception exception, IScheduler scheduler, TResult witness)
  13839. {
  13840. if (provider == null)
  13841. throw new ArgumentNullException("provider");
  13842. if (exception == null)
  13843. throw new ArgumentNullException("exception");
  13844. if (scheduler == null)
  13845. throw new ArgumentNullException("scheduler");
  13846. return provider.CreateQuery<TResult>(
  13847. Expression.Call(
  13848. null,
  13849. #if CRIPPLED_REFLECTION
  13850. InfoOf(() => Qbservable.Throw<TResult>(default(IQbservableProvider), default(Exception), default(IScheduler), default(TResult))),
  13851. #else
  13852. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  13853. #endif
  13854. Expression.Constant(provider, typeof(IQbservableProvider)),
  13855. Expression.Constant(exception, typeof(Exception)),
  13856. Expression.Constant(scheduler, typeof(IScheduler)),
  13857. Expression.Constant(witness, typeof(TResult))
  13858. )
  13859. );
  13860. }
  13861. /// <summary>
  13862. /// Returns an observable sequence that terminates with an exception.
  13863. /// </summary>
  13864. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  13865. /// <typeparam name="TResult">The type used for the IObservable&lt;T&gt; type parameter of the resulting sequence.</typeparam>
  13866. /// <param name="exception">Exception object used for the sequence's termination.</param>
  13867. /// <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>
  13868. /// <returns>The observable sequence that terminates exceptionally with the specified exception object.</returns>
  13869. /// <exception cref="T:System.ArgumentNullException">
  13870. /// <paramref name="exception" /> is null.</exception>
  13871. public static IQbservable<TResult> Throw<TResult>(this IQbservableProvider provider, Exception exception, TResult witness)
  13872. {
  13873. if (provider == null)
  13874. throw new ArgumentNullException("provider");
  13875. if (exception == null)
  13876. throw new ArgumentNullException("exception");
  13877. return provider.CreateQuery<TResult>(
  13878. Expression.Call(
  13879. null,
  13880. #if CRIPPLED_REFLECTION
  13881. InfoOf(() => Qbservable.Throw<TResult>(default(IQbservableProvider), default(Exception), default(TResult))),
  13882. #else
  13883. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  13884. #endif
  13885. Expression.Constant(provider, typeof(IQbservableProvider)),
  13886. Expression.Constant(exception, typeof(Exception)),
  13887. Expression.Constant(witness, typeof(TResult))
  13888. )
  13889. );
  13890. }
  13891. /// <summary>
  13892. /// Records the time interval between consecutive elements in an observable sequence.
  13893. /// </summary>
  13894. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13895. /// <param name="source">Source sequence to record time intervals for.</param>
  13896. /// <returns>An observable sequence with time interval information on elements.</returns>
  13897. /// <exception cref="T:System.ArgumentNullException">
  13898. /// <paramref name="source" /> is null.</exception>
  13899. public static IQbservable<TimeInterval<TSource>> TimeInterval<TSource>(this IQbservable<TSource> source)
  13900. {
  13901. if (source == null)
  13902. throw new ArgumentNullException("source");
  13903. return source.Provider.CreateQuery<TimeInterval<TSource>>(
  13904. Expression.Call(
  13905. null,
  13906. #if CRIPPLED_REFLECTION
  13907. InfoOf(() => Qbservable.TimeInterval<TSource>(default(IQbservable<TSource>))),
  13908. #else
  13909. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13910. #endif
  13911. source.Expression
  13912. )
  13913. );
  13914. }
  13915. /// <summary>
  13916. /// Records the time interval between consecutive elements in an observable sequence, using the specified scheduler to compute time intervals.
  13917. /// </summary>
  13918. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13919. /// <param name="source">Source sequence to record time intervals for.</param>
  13920. /// <param name="scheduler">Scheduler used to compute time intervals.</param>
  13921. /// <returns>An observable sequence with time interval information on elements.</returns>
  13922. /// <exception cref="T:System.ArgumentNullException">
  13923. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13924. public static IQbservable<TimeInterval<TSource>> TimeInterval<TSource>(this IQbservable<TSource> source, IScheduler scheduler)
  13925. {
  13926. if (source == null)
  13927. throw new ArgumentNullException("source");
  13928. if (scheduler == null)
  13929. throw new ArgumentNullException("scheduler");
  13930. return source.Provider.CreateQuery<TimeInterval<TSource>>(
  13931. Expression.Call(
  13932. null,
  13933. #if CRIPPLED_REFLECTION
  13934. InfoOf(() => Qbservable.TimeInterval<TSource>(default(IQbservable<TSource>), default(IScheduler))),
  13935. #else
  13936. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13937. #endif
  13938. source.Expression,
  13939. Expression.Constant(scheduler, typeof(IScheduler))
  13940. )
  13941. );
  13942. }
  13943. /// <summary>
  13944. /// Applies a timeout policy to the observable sequence based on an absolute time.
  13945. /// If the sequence doesn't terminate before the specified absolute due time, a TimeoutException is propagated to the observer.
  13946. /// </summary>
  13947. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13948. /// <param name="source">Source sequence to perform a timeout for.</param>
  13949. /// <param name="dueTime">Time when a timeout occurs. If this value is less than or equal to DateTimeOffset.UtcNow, the timeout occurs immediately.</param>
  13950. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  13951. /// <exception cref="T:System.ArgumentNullException">
  13952. /// <paramref name="source" /> is null.</exception>
  13953. /// <exception cref="T:System.TimeoutException">(Asynchronous) If the sequence hasn't terminated before <paramref name="dueTime" />.</exception>
  13954. /// <remarks>
  13955. /// In case you only want to timeout on the first element, consider using the <see cref="M:System.Reactive.Linq.Observable.Amb``1(System.IObservable{``0},System.IObservable{``0})" />
  13956. /// operator applied to the source sequence and a delayed <see cref="M:System.Reactive.Linq.Observable.Throw``1(System.Exception)" /> sequence. Alternatively, the general-purpose overload
  13957. /// of Timeout, <see cref="M:System.Reactive.Linq.Observable.Timeout``2(System.IObservable{``0},System.IObservable{``1},System.Func{``0,System.IObservable{``1}})" /> can be used.
  13958. /// </remarks>
  13959. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime)
  13960. {
  13961. if (source == null)
  13962. throw new ArgumentNullException("source");
  13963. return source.Provider.CreateQuery<TSource>(
  13964. Expression.Call(
  13965. null,
  13966. #if CRIPPLED_REFLECTION
  13967. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(DateTimeOffset))),
  13968. #else
  13969. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13970. #endif
  13971. source.Expression,
  13972. Expression.Constant(dueTime, typeof(DateTimeOffset))
  13973. )
  13974. );
  13975. }
  13976. /// <summary>
  13977. /// Applies a timeout policy to the observable sequence based on an absolute time.
  13978. /// 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.
  13979. /// </summary>
  13980. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  13981. /// <param name="source">Source sequence to perform a timeout for.</param>
  13982. /// <param name="dueTime">Time when a timeout occurs. If this value is less than or equal to DateTimeOffset.UtcNow, the timeout occurs immediately.</param>
  13983. /// <param name="other">Sequence to return in case of a timeout.</param>
  13984. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  13985. /// <exception cref="T:System.ArgumentNullException">
  13986. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  13987. /// <remarks>
  13988. /// In case you only want to timeout on the first element, consider using the <see cref="M:System.Reactive.Linq.Observable.Amb``1(System.IObservable{``0},System.IObservable{``0})" />
  13989. /// operator applied to the source sequence and a delayed <see cref="M:System.Reactive.Linq.Observable.Throw``1(System.Exception)" /> sequence. Alternatively, the general-purpose overload
  13990. /// of Timeout, <see cref="M:System.Reactive.Linq.Observable.Timeout``2(System.IObservable{``0},System.IObservable{``1},System.Func{``0,System.IObservable{``1}})" /> can be used.
  13991. /// </remarks>
  13992. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime, IObservable<TSource> other)
  13993. {
  13994. if (source == null)
  13995. throw new ArgumentNullException("source");
  13996. if (other == null)
  13997. throw new ArgumentNullException("other");
  13998. return source.Provider.CreateQuery<TSource>(
  13999. Expression.Call(
  14000. null,
  14001. #if CRIPPLED_REFLECTION
  14002. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IObservable<TSource>))),
  14003. #else
  14004. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14005. #endif
  14006. source.Expression,
  14007. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  14008. GetSourceExpression(other)
  14009. )
  14010. );
  14011. }
  14012. /// <summary>
  14013. /// Applies a timeout policy to the observable sequence based on an absolute time, using the specified scheduler to run timeout timers.
  14014. /// 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.
  14015. /// </summary>
  14016. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  14017. /// <param name="source">Source sequence to perform a timeout for.</param>
  14018. /// <param name="dueTime">Time when a timeout occurs. If this value is less than or equal to DateTimeOffset.UtcNow, the timeout occurs immediately.</param>
  14019. /// <param name="other">Sequence to return in case of a timeout.</param>
  14020. /// <param name="scheduler">Scheduler to run the timeout timers on.</param>
  14021. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  14022. /// <exception cref="T:System.ArgumentNullException">
  14023. /// <paramref name="source" /> or <paramref name="other" /> or <paramref name="scheduler" /> is null.</exception>
  14024. /// <remarks>
  14025. /// In case you only want to timeout on the first element, consider using the <see cref="M:System.Reactive.Linq.Observable.Amb``1(System.IObservable{``0},System.IObservable{``0})" />
  14026. /// operator applied to the source sequence and a delayed <see cref="M:System.Reactive.Linq.Observable.Throw``1(System.Exception)" /> sequence. Alternatively, the general-purpose overload
  14027. /// of Timeout, <see cref="M:System.Reactive.Linq.Observable.Timeout``2(System.IObservable{``0},System.IObservable{``1},System.Func{``0,System.IObservable{``1}})" /> can be used.
  14028. /// </remarks>
  14029. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime, IObservable<TSource> other, IScheduler scheduler)
  14030. {
  14031. if (source == null)
  14032. throw new ArgumentNullException("source");
  14033. if (other == null)
  14034. throw new ArgumentNullException("other");
  14035. if (scheduler == null)
  14036. throw new ArgumentNullException("scheduler");
  14037. return source.Provider.CreateQuery<TSource>(
  14038. Expression.Call(
  14039. null,
  14040. #if CRIPPLED_REFLECTION
  14041. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IObservable<TSource>), default(IScheduler))),
  14042. #else
  14043. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14044. #endif
  14045. source.Expression,
  14046. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  14047. GetSourceExpression(other),
  14048. Expression.Constant(scheduler, typeof(IScheduler))
  14049. )
  14050. );
  14051. }
  14052. /// <summary>
  14053. /// Applies a timeout policy to the observable sequence based on an absolute time, using the specified scheduler to run timeout timers.
  14054. /// If the sequence doesn't terminate before the specified absolute due time, a TimeoutException is propagated to the observer.
  14055. /// </summary>
  14056. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14057. /// <param name="source">Source sequence to perform a timeout for.</param>
  14058. /// <param name="dueTime">Time when a timeout occurs. If this value is less than or equal to DateTimeOffset.UtcNow, the timeout occurs immediately.</param>
  14059. /// <param name="scheduler">Scheduler to run the timeout timers on.</param>
  14060. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  14061. /// <exception cref="T:System.ArgumentNullException">
  14062. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14063. /// <exception cref="T:System.TimeoutException">(Asynchronous) If the sequence hasn't terminated before <paramref name="dueTime" />.</exception>
  14064. /// <remarks>
  14065. /// In case you only want to timeout on the first element, consider using the <see cref="M:System.Reactive.Linq.Observable.Amb``1(System.IObservable{``0},System.IObservable{``0})" />
  14066. /// operator applied to the source sequence and a delayed <see cref="M:System.Reactive.Linq.Observable.Throw``1(System.Exception)" /> sequence. Alternatively, the general-purpose overload
  14067. /// of Timeout, <see cref="M:System.Reactive.Linq.Observable.Timeout``2(System.IObservable{``0},System.IObservable{``1},System.Func{``0,System.IObservable{``1}})" /> can be used.
  14068. /// </remarks>
  14069. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime, IScheduler scheduler)
  14070. {
  14071. if (source == null)
  14072. throw new ArgumentNullException("source");
  14073. if (scheduler == null)
  14074. throw new ArgumentNullException("scheduler");
  14075. return source.Provider.CreateQuery<TSource>(
  14076. Expression.Call(
  14077. null,
  14078. #if CRIPPLED_REFLECTION
  14079. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IScheduler))),
  14080. #else
  14081. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14082. #endif
  14083. source.Expression,
  14084. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  14085. Expression.Constant(scheduler, typeof(IScheduler))
  14086. )
  14087. );
  14088. }
  14089. /// <summary>
  14090. /// Applies a timeout policy for each element in the observable sequence.
  14091. /// If the next element isn't received within the specified timeout duration starting from its predecessor, a TimeoutException is propagated to the observer.
  14092. /// </summary>
  14093. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14094. /// <param name="source">Source sequence to perform a timeout for.</param>
  14095. /// <param name="dueTime">Maximum duration between values before a timeout occurs.</param>
  14096. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  14097. /// <exception cref="T:System.ArgumentNullException">
  14098. /// <paramref name="source" /> is null.</exception>
  14099. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14100. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14101. /// <exception cref="T:System.TimeoutException">(Asynchronous) If no element is produced within <paramref name="dueTime" /> from the previous element.</exception>
  14102. /// <remarks>
  14103. /// <para>
  14104. /// In case you only want to timeout on the first element, consider using the <see cref="M:System.Reactive.Linq.Observable.Amb``1(System.IObservable{``0},System.IObservable{``0})" />
  14105. /// operator applied to the source sequence and a delayed <see cref="M:System.Reactive.Linq.Observable.Throw``1(System.Exception)" /> sequence. Alternatively, the general-purpose overload
  14106. /// of Timeout, <see cref="M:System.Reactive.Linq.Observable.Timeout``2(System.IObservable{``0},System.IObservable{``1},System.Func{``0,System.IObservable{``1}})" /> can be used.
  14107. /// </para>
  14108. /// <para>
  14109. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing timeout timers to be scheduled that are due
  14110. /// 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
  14111. /// 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
  14112. /// arrive before the scheduler gets a chance to run the timeout action.
  14113. /// </para>
  14114. /// </remarks>
  14115. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, TimeSpan dueTime)
  14116. {
  14117. if (source == null)
  14118. throw new ArgumentNullException("source");
  14119. return source.Provider.CreateQuery<TSource>(
  14120. Expression.Call(
  14121. null,
  14122. #if CRIPPLED_REFLECTION
  14123. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  14124. #else
  14125. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14126. #endif
  14127. source.Expression,
  14128. Expression.Constant(dueTime, typeof(TimeSpan))
  14129. )
  14130. );
  14131. }
  14132. /// <summary>
  14133. /// Applies a timeout policy for each element in the observable sequence.
  14134. /// 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.
  14135. /// </summary>
  14136. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  14137. /// <param name="source">Source sequence to perform a timeout for.</param>
  14138. /// <param name="dueTime">Maximum duration between values before a timeout occurs.</param>
  14139. /// <param name="other">Sequence to return in case of a timeout.</param>
  14140. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  14141. /// <exception cref="T:System.ArgumentNullException">
  14142. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  14143. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14144. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14145. /// <remarks>
  14146. /// <para>
  14147. /// In case you only want to timeout on the first element, consider using the <see cref="M:System.Reactive.Linq.Observable.Amb``1(System.IObservable{``0},System.IObservable{``0})" />
  14148. /// operator applied to the source sequence and a delayed <see cref="M:System.Reactive.Linq.Observable.Throw``1(System.Exception)" /> sequence. Alternatively, the general-purpose overload
  14149. /// of Timeout, <see cref="M:System.Reactive.Linq.Observable.Timeout``2(System.IObservable{``0},System.IObservable{``1},System.Func{``0,System.IObservable{``1}})" /> can be used.
  14150. /// </para>
  14151. /// <para>
  14152. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing timeout timers to be scheduled that are due
  14153. /// 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
  14154. /// 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
  14155. /// arrive before the scheduler gets a chance to run the timeout action.
  14156. /// </para>
  14157. /// </remarks>
  14158. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IObservable<TSource> other)
  14159. {
  14160. if (source == null)
  14161. throw new ArgumentNullException("source");
  14162. if (other == null)
  14163. throw new ArgumentNullException("other");
  14164. return source.Provider.CreateQuery<TSource>(
  14165. Expression.Call(
  14166. null,
  14167. #if CRIPPLED_REFLECTION
  14168. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IObservable<TSource>))),
  14169. #else
  14170. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14171. #endif
  14172. source.Expression,
  14173. Expression.Constant(dueTime, typeof(TimeSpan)),
  14174. GetSourceExpression(other)
  14175. )
  14176. );
  14177. }
  14178. /// <summary>
  14179. /// Applies a timeout policy for each element in the observable sequence, using the specified scheduler to run timeout timers.
  14180. /// 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.
  14181. /// </summary>
  14182. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  14183. /// <param name="source">Source sequence to perform a timeout for.</param>
  14184. /// <param name="dueTime">Maximum duration between values before a timeout occurs.</param>
  14185. /// <param name="other">Sequence to return in case of a timeout.</param>
  14186. /// <param name="scheduler">Scheduler to run the timeout timers on.</param>
  14187. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  14188. /// <exception cref="T:System.ArgumentNullException">
  14189. /// <paramref name="source" /> or <paramref name="other" /> or <paramref name="scheduler" /> is null.</exception>
  14190. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14191. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14192. /// <remarks>
  14193. /// <para>
  14194. /// In case you only want to timeout on the first element, consider using the <see cref="M:System.Reactive.Linq.Observable.Amb``1(System.IObservable{``0},System.IObservable{``0})" />
  14195. /// operator applied to the source sequence and a delayed <see cref="M:System.Reactive.Linq.Observable.Throw``1(System.Exception)" /> sequence. Alternatively, the general-purpose overload
  14196. /// of Timeout, <see cref="M:System.Reactive.Linq.Observable.Timeout``2(System.IObservable{``0},System.IObservable{``1},System.Func{``0,System.IObservable{``1}})" /> can be used.
  14197. /// </para>
  14198. /// <para>
  14199. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing timeout timers to be scheduled that are due
  14200. /// 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
  14201. /// 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
  14202. /// arrive before the scheduler gets a chance to run the timeout action.
  14203. /// </para>
  14204. /// </remarks>
  14205. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IObservable<TSource> other, IScheduler scheduler)
  14206. {
  14207. if (source == null)
  14208. throw new ArgumentNullException("source");
  14209. if (other == null)
  14210. throw new ArgumentNullException("other");
  14211. if (scheduler == null)
  14212. throw new ArgumentNullException("scheduler");
  14213. return source.Provider.CreateQuery<TSource>(
  14214. Expression.Call(
  14215. null,
  14216. #if CRIPPLED_REFLECTION
  14217. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IObservable<TSource>), default(IScheduler))),
  14218. #else
  14219. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14220. #endif
  14221. source.Expression,
  14222. Expression.Constant(dueTime, typeof(TimeSpan)),
  14223. GetSourceExpression(other),
  14224. Expression.Constant(scheduler, typeof(IScheduler))
  14225. )
  14226. );
  14227. }
  14228. /// <summary>
  14229. /// Applies a timeout policy for each element in the observable sequence, using the specified scheduler to run timeout timers.
  14230. /// If the next element isn't received within the specified timeout duration starting from its predecessor, a TimeoutException is propagated to the observer.
  14231. /// </summary>
  14232. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14233. /// <param name="source">Source sequence to perform a timeout for.</param>
  14234. /// <param name="dueTime">Maximum duration between values before a timeout occurs.</param>
  14235. /// <param name="scheduler">Scheduler to run the timeout timers on.</param>
  14236. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  14237. /// <exception cref="T:System.ArgumentNullException">
  14238. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14239. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14240. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14241. /// <exception cref="T:System.TimeoutException">(Asynchronous) If no element is produced within <paramref name="dueTime" /> from the previous element.</exception>
  14242. /// <remarks>
  14243. /// <para>
  14244. /// In case you only want to timeout on the first element, consider using the <see cref="M:System.Reactive.Linq.Observable.Amb``1(System.IObservable{``0},System.IObservable{``0})" />
  14245. /// operator applied to the source sequence and a delayed <see cref="M:System.Reactive.Linq.Observable.Throw``1(System.Exception)" /> sequence. Alternatively, the general-purpose overload
  14246. /// of Timeout, <see cref="M:System.Reactive.Linq.Observable.Timeout``2(System.IObservable{``0},System.IObservable{``1},System.Func{``0,System.IObservable{``1}})" /> can be used.
  14247. /// </para>
  14248. /// <para>
  14249. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing timeout timers to be scheduled that are due
  14250. /// 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
  14251. /// 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
  14252. /// arrive before the scheduler gets a chance to run the timeout action.
  14253. /// </para>
  14254. /// </remarks>
  14255. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IScheduler scheduler)
  14256. {
  14257. if (source == null)
  14258. throw new ArgumentNullException("source");
  14259. if (scheduler == null)
  14260. throw new ArgumentNullException("scheduler");
  14261. return source.Provider.CreateQuery<TSource>(
  14262. Expression.Call(
  14263. null,
  14264. #if CRIPPLED_REFLECTION
  14265. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  14266. #else
  14267. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14268. #endif
  14269. source.Expression,
  14270. Expression.Constant(dueTime, typeof(TimeSpan)),
  14271. Expression.Constant(scheduler, typeof(IScheduler))
  14272. )
  14273. );
  14274. }
  14275. /// <summary>
  14276. /// 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.
  14277. /// If the next element isn't received within the computed duration starting from its predecessor, a TimeoutException is propagated to the observer.
  14278. /// </summary>
  14279. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14280. /// <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>
  14281. /// <param name="source">Source sequence to perform a timeout for.</param>
  14282. /// <param name="firstTimeout">Observable sequence that represents the timeout for the first element.</param>
  14283. /// <param name="timeoutDurationSelector">Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.</param>
  14284. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  14285. /// <exception cref="T:System.ArgumentNullException">
  14286. /// <paramref name="source" /> or <paramref name="firstTimeout" /> or <paramref name="timeoutDurationSelector" /> is null.</exception>
  14287. public static IQbservable<TSource> Timeout<TSource, TTimeout>(this IQbservable<TSource> source, IObservable<TTimeout> firstTimeout, Expression<Func<TSource, IObservable<TTimeout>>> timeoutDurationSelector)
  14288. {
  14289. if (source == null)
  14290. throw new ArgumentNullException("source");
  14291. if (firstTimeout == null)
  14292. throw new ArgumentNullException("firstTimeout");
  14293. if (timeoutDurationSelector == null)
  14294. throw new ArgumentNullException("timeoutDurationSelector");
  14295. return source.Provider.CreateQuery<TSource>(
  14296. Expression.Call(
  14297. null,
  14298. #if CRIPPLED_REFLECTION
  14299. InfoOf(() => Qbservable.Timeout<TSource, TTimeout>(default(IQbservable<TSource>), default(IObservable<TTimeout>), default(Expression<Func<TSource, IObservable<TTimeout>>>))),
  14300. #else
  14301. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTimeout)),
  14302. #endif
  14303. source.Expression,
  14304. GetSourceExpression(firstTimeout),
  14305. timeoutDurationSelector
  14306. )
  14307. );
  14308. }
  14309. /// <summary>
  14310. /// 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.
  14311. /// 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.
  14312. /// </summary>
  14313. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  14314. /// <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>
  14315. /// <param name="source">Source sequence to perform a timeout for.</param>
  14316. /// <param name="firstTimeout">Observable sequence that represents the timeout for the first element.</param>
  14317. /// <param name="timeoutDurationSelector">Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.</param>
  14318. /// <param name="other">Sequence to return in case of a timeout.</param>
  14319. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  14320. /// <exception cref="T:System.ArgumentNullException">
  14321. /// <paramref name="source" /> or <paramref name="firstTimeout" /> or <paramref name="timeoutDurationSelector" /> or <paramref name="other" /> is null.</exception>
  14322. public static IQbservable<TSource> Timeout<TSource, TTimeout>(this IQbservable<TSource> source, IObservable<TTimeout> firstTimeout, Expression<Func<TSource, IObservable<TTimeout>>> timeoutDurationSelector, IObservable<TSource> other)
  14323. {
  14324. if (source == null)
  14325. throw new ArgumentNullException("source");
  14326. if (firstTimeout == null)
  14327. throw new ArgumentNullException("firstTimeout");
  14328. if (timeoutDurationSelector == null)
  14329. throw new ArgumentNullException("timeoutDurationSelector");
  14330. if (other == null)
  14331. throw new ArgumentNullException("other");
  14332. return source.Provider.CreateQuery<TSource>(
  14333. Expression.Call(
  14334. null,
  14335. #if CRIPPLED_REFLECTION
  14336. InfoOf(() => Qbservable.Timeout<TSource, TTimeout>(default(IQbservable<TSource>), default(IObservable<TTimeout>), default(Expression<Func<TSource, IObservable<TTimeout>>>), default(IObservable<TSource>))),
  14337. #else
  14338. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTimeout)),
  14339. #endif
  14340. source.Expression,
  14341. GetSourceExpression(firstTimeout),
  14342. timeoutDurationSelector,
  14343. GetSourceExpression(other)
  14344. )
  14345. );
  14346. }
  14347. /// <summary>
  14348. /// Applies a timeout policy to the observable sequence based on a timeout duration computed for each element.
  14349. /// If the next element isn't received within the computed duration starting from its predecessor, a TimeoutException is propagated to the observer.
  14350. /// </summary>
  14351. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14352. /// <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>
  14353. /// <param name="source">Source sequence to perform a timeout for.</param>
  14354. /// <param name="timeoutDurationSelector">Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.</param>
  14355. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  14356. /// <exception cref="T:System.ArgumentNullException">
  14357. /// <paramref name="source" /> or <paramref name="timeoutDurationSelector" /> is null.</exception>
  14358. public static IQbservable<TSource> Timeout<TSource, TTimeout>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TTimeout>>> timeoutDurationSelector)
  14359. {
  14360. if (source == null)
  14361. throw new ArgumentNullException("source");
  14362. if (timeoutDurationSelector == null)
  14363. throw new ArgumentNullException("timeoutDurationSelector");
  14364. return source.Provider.CreateQuery<TSource>(
  14365. Expression.Call(
  14366. null,
  14367. #if CRIPPLED_REFLECTION
  14368. InfoOf(() => Qbservable.Timeout<TSource, TTimeout>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TTimeout>>>))),
  14369. #else
  14370. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTimeout)),
  14371. #endif
  14372. source.Expression,
  14373. timeoutDurationSelector
  14374. )
  14375. );
  14376. }
  14377. /// <summary>
  14378. /// Applies a timeout policy to the observable sequence based on a timeout duration computed for each element.
  14379. /// 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.
  14380. /// </summary>
  14381. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  14382. /// <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>
  14383. /// <param name="source">Source sequence to perform a timeout for.</param>
  14384. /// <param name="timeoutDurationSelector">Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.</param>
  14385. /// <param name="other">Sequence to return in case of a timeout.</param>
  14386. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  14387. /// <exception cref="T:System.ArgumentNullException">
  14388. /// <paramref name="source" /> or <paramref name="timeoutDurationSelector" /> or <paramref name="other" /> is null.</exception>
  14389. public static IQbservable<TSource> Timeout<TSource, TTimeout>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TTimeout>>> timeoutDurationSelector, IObservable<TSource> other)
  14390. {
  14391. if (source == null)
  14392. throw new ArgumentNullException("source");
  14393. if (timeoutDurationSelector == null)
  14394. throw new ArgumentNullException("timeoutDurationSelector");
  14395. if (other == null)
  14396. throw new ArgumentNullException("other");
  14397. return source.Provider.CreateQuery<TSource>(
  14398. Expression.Call(
  14399. null,
  14400. #if CRIPPLED_REFLECTION
  14401. InfoOf(() => Qbservable.Timeout<TSource, TTimeout>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TTimeout>>>), default(IObservable<TSource>))),
  14402. #else
  14403. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTimeout)),
  14404. #endif
  14405. source.Expression,
  14406. timeoutDurationSelector,
  14407. GetSourceExpression(other)
  14408. )
  14409. );
  14410. }
  14411. /// <summary>
  14412. /// Returns an observable sequence that produces a single value at the specified absolute due time.
  14413. /// </summary>
  14414. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  14415. /// <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>
  14416. /// <returns>An observable sequence that produces a value at due time.</returns>
  14417. public static IQbservable<long> Timer(this IQbservableProvider provider, DateTimeOffset dueTime)
  14418. {
  14419. if (provider == null)
  14420. throw new ArgumentNullException("provider");
  14421. return provider.CreateQuery<long>(
  14422. Expression.Call(
  14423. null,
  14424. #if CRIPPLED_REFLECTION
  14425. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(DateTimeOffset))),
  14426. #else
  14427. (MethodInfo)MethodInfo.GetCurrentMethod(),
  14428. #endif
  14429. Expression.Constant(provider, typeof(IQbservableProvider)),
  14430. Expression.Constant(dueTime, typeof(DateTimeOffset))
  14431. )
  14432. );
  14433. }
  14434. /// <summary>
  14435. /// Returns an observable sequence that periodically produces a value starting at the specified initial absolute due time.
  14436. /// </summary>
  14437. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  14438. /// <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>
  14439. /// <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>
  14440. /// <returns>An observable sequence that produces a value at due time and then after each period.</returns>
  14441. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14442. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  14443. public static IQbservable<long> Timer(this IQbservableProvider provider, DateTimeOffset dueTime, TimeSpan period)
  14444. {
  14445. if (provider == null)
  14446. throw new ArgumentNullException("provider");
  14447. return provider.CreateQuery<long>(
  14448. Expression.Call(
  14449. null,
  14450. #if CRIPPLED_REFLECTION
  14451. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(DateTimeOffset), default(TimeSpan))),
  14452. #else
  14453. (MethodInfo)MethodInfo.GetCurrentMethod(),
  14454. #endif
  14455. Expression.Constant(provider, typeof(IQbservableProvider)),
  14456. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  14457. Expression.Constant(period, typeof(TimeSpan))
  14458. )
  14459. );
  14460. }
  14461. /// <summary>
  14462. /// Returns an observable sequence that periodically produces a value starting at the specified initial absolute due time, using the specified scheduler to run timers.
  14463. /// </summary>
  14464. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  14465. /// <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>
  14466. /// <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>
  14467. /// <param name="scheduler">Scheduler to run timers on.</param>
  14468. /// <returns>An observable sequence that produces a value at due time and then after each period.</returns>
  14469. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14470. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  14471. /// <exception cref="T:System.ArgumentNullException">
  14472. /// <paramref name="scheduler" /> is null.</exception>
  14473. public static IQbservable<long> Timer(this IQbservableProvider provider, DateTimeOffset dueTime, TimeSpan period, IScheduler scheduler)
  14474. {
  14475. if (provider == null)
  14476. throw new ArgumentNullException("provider");
  14477. if (scheduler == null)
  14478. throw new ArgumentNullException("scheduler");
  14479. return provider.CreateQuery<long>(
  14480. Expression.Call(
  14481. null,
  14482. #if CRIPPLED_REFLECTION
  14483. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(DateTimeOffset), default(TimeSpan), default(IScheduler))),
  14484. #else
  14485. (MethodInfo)MethodInfo.GetCurrentMethod(),
  14486. #endif
  14487. Expression.Constant(provider, typeof(IQbservableProvider)),
  14488. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  14489. Expression.Constant(period, typeof(TimeSpan)),
  14490. Expression.Constant(scheduler, typeof(IScheduler))
  14491. )
  14492. );
  14493. }
  14494. /// <summary>
  14495. /// Returns an observable sequence that produces a single value at the specified absolute due time, using the specified scheduler to run the timer.
  14496. /// </summary>
  14497. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  14498. /// <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>
  14499. /// <param name="scheduler">Scheduler to run the timer on.</param>
  14500. /// <returns>An observable sequence that produces a value at due time.</returns>
  14501. /// <exception cref="T:System.ArgumentNullException">
  14502. /// <paramref name="scheduler" /> is null.</exception>
  14503. public static IQbservable<long> Timer(this IQbservableProvider provider, DateTimeOffset dueTime, IScheduler scheduler)
  14504. {
  14505. if (provider == null)
  14506. throw new ArgumentNullException("provider");
  14507. if (scheduler == null)
  14508. throw new ArgumentNullException("scheduler");
  14509. return provider.CreateQuery<long>(
  14510. Expression.Call(
  14511. null,
  14512. #if CRIPPLED_REFLECTION
  14513. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(DateTimeOffset), default(IScheduler))),
  14514. #else
  14515. (MethodInfo)MethodInfo.GetCurrentMethod(),
  14516. #endif
  14517. Expression.Constant(provider, typeof(IQbservableProvider)),
  14518. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  14519. Expression.Constant(scheduler, typeof(IScheduler))
  14520. )
  14521. );
  14522. }
  14523. /// <summary>
  14524. /// Returns an observable sequence that produces a single value after the specified relative due time has elapsed.
  14525. /// </summary>
  14526. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  14527. /// <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>
  14528. /// <returns>An observable sequence that produces a value after the due time has elapsed.</returns>
  14529. public static IQbservable<long> Timer(this IQbservableProvider provider, TimeSpan dueTime)
  14530. {
  14531. if (provider == null)
  14532. throw new ArgumentNullException("provider");
  14533. return provider.CreateQuery<long>(
  14534. Expression.Call(
  14535. null,
  14536. #if CRIPPLED_REFLECTION
  14537. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(TimeSpan))),
  14538. #else
  14539. (MethodInfo)MethodInfo.GetCurrentMethod(),
  14540. #endif
  14541. Expression.Constant(provider, typeof(IQbservableProvider)),
  14542. Expression.Constant(dueTime, typeof(TimeSpan))
  14543. )
  14544. );
  14545. }
  14546. /// <summary>
  14547. /// Returns an observable sequence that periodically produces a value after the specified initial relative due time has elapsed.
  14548. /// </summary>
  14549. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  14550. /// <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>
  14551. /// <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>
  14552. /// <returns>An observable sequence that produces a value after due time has elapsed and then after each period.</returns>
  14553. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14554. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  14555. public static IQbservable<long> Timer(this IQbservableProvider provider, TimeSpan dueTime, TimeSpan period)
  14556. {
  14557. if (provider == null)
  14558. throw new ArgumentNullException("provider");
  14559. return provider.CreateQuery<long>(
  14560. Expression.Call(
  14561. null,
  14562. #if CRIPPLED_REFLECTION
  14563. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(TimeSpan), default(TimeSpan))),
  14564. #else
  14565. (MethodInfo)MethodInfo.GetCurrentMethod(),
  14566. #endif
  14567. Expression.Constant(provider, typeof(IQbservableProvider)),
  14568. Expression.Constant(dueTime, typeof(TimeSpan)),
  14569. Expression.Constant(period, typeof(TimeSpan))
  14570. )
  14571. );
  14572. }
  14573. /// <summary>
  14574. /// 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.
  14575. /// </summary>
  14576. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  14577. /// <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>
  14578. /// <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>
  14579. /// <param name="scheduler">Scheduler to run timers on.</param>
  14580. /// <returns>An observable sequence that produces a value after due time has elapsed and then each period.</returns>
  14581. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14582. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  14583. /// <exception cref="T:System.ArgumentNullException">
  14584. /// <paramref name="scheduler" /> is null.</exception>
  14585. public static IQbservable<long> Timer(this IQbservableProvider provider, TimeSpan dueTime, TimeSpan period, IScheduler scheduler)
  14586. {
  14587. if (provider == null)
  14588. throw new ArgumentNullException("provider");
  14589. if (scheduler == null)
  14590. throw new ArgumentNullException("scheduler");
  14591. return provider.CreateQuery<long>(
  14592. Expression.Call(
  14593. null,
  14594. #if CRIPPLED_REFLECTION
  14595. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(TimeSpan), default(TimeSpan), default(IScheduler))),
  14596. #else
  14597. (MethodInfo)MethodInfo.GetCurrentMethod(),
  14598. #endif
  14599. Expression.Constant(provider, typeof(IQbservableProvider)),
  14600. Expression.Constant(dueTime, typeof(TimeSpan)),
  14601. Expression.Constant(period, typeof(TimeSpan)),
  14602. Expression.Constant(scheduler, typeof(IScheduler))
  14603. )
  14604. );
  14605. }
  14606. /// <summary>
  14607. /// 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.
  14608. /// </summary>
  14609. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  14610. /// <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>
  14611. /// <param name="scheduler">Scheduler to run the timer on.</param>
  14612. /// <returns>An observable sequence that produces a value after the due time has elapsed.</returns>
  14613. /// <exception cref="T:System.ArgumentNullException">
  14614. /// <paramref name="scheduler" /> is null.</exception>
  14615. public static IQbservable<long> Timer(this IQbservableProvider provider, TimeSpan dueTime, IScheduler scheduler)
  14616. {
  14617. if (provider == null)
  14618. throw new ArgumentNullException("provider");
  14619. if (scheduler == null)
  14620. throw new ArgumentNullException("scheduler");
  14621. return provider.CreateQuery<long>(
  14622. Expression.Call(
  14623. null,
  14624. #if CRIPPLED_REFLECTION
  14625. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(TimeSpan), default(IScheduler))),
  14626. #else
  14627. (MethodInfo)MethodInfo.GetCurrentMethod(),
  14628. #endif
  14629. Expression.Constant(provider, typeof(IQbservableProvider)),
  14630. Expression.Constant(dueTime, typeof(TimeSpan)),
  14631. Expression.Constant(scheduler, typeof(IScheduler))
  14632. )
  14633. );
  14634. }
  14635. /// <summary>
  14636. /// Timestamps each element in an observable sequence using the local system clock.
  14637. /// </summary>
  14638. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14639. /// <param name="source">Source sequence to timestamp elements for.</param>
  14640. /// <returns>An observable sequence with timestamp information on elements.</returns>
  14641. /// <exception cref="T:System.ArgumentNullException">
  14642. /// <paramref name="source" /> is null.</exception>
  14643. public static IQbservable<Timestamped<TSource>> Timestamp<TSource>(this IQbservable<TSource> source)
  14644. {
  14645. if (source == null)
  14646. throw new ArgumentNullException("source");
  14647. return source.Provider.CreateQuery<Timestamped<TSource>>(
  14648. Expression.Call(
  14649. null,
  14650. #if CRIPPLED_REFLECTION
  14651. InfoOf(() => Qbservable.Timestamp<TSource>(default(IQbservable<TSource>))),
  14652. #else
  14653. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14654. #endif
  14655. source.Expression
  14656. )
  14657. );
  14658. }
  14659. /// <summary>
  14660. /// Timestamp each element in an observable sequence using the clock of the specified scheduler.
  14661. /// </summary>
  14662. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14663. /// <param name="source">Source sequence to timestamp elements for.</param>
  14664. /// <param name="scheduler">Scheduler used to compute timestamps.</param>
  14665. /// <returns>An observable sequence with timestamp information on elements.</returns>
  14666. /// <exception cref="T:System.ArgumentNullException">
  14667. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14668. public static IQbservable<Timestamped<TSource>> Timestamp<TSource>(this IQbservable<TSource> source, IScheduler scheduler)
  14669. {
  14670. if (source == null)
  14671. throw new ArgumentNullException("source");
  14672. if (scheduler == null)
  14673. throw new ArgumentNullException("scheduler");
  14674. return source.Provider.CreateQuery<Timestamped<TSource>>(
  14675. Expression.Call(
  14676. null,
  14677. #if CRIPPLED_REFLECTION
  14678. InfoOf(() => Qbservable.Timestamp<TSource>(default(IQbservable<TSource>), default(IScheduler))),
  14679. #else
  14680. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14681. #endif
  14682. source.Expression,
  14683. Expression.Constant(scheduler, typeof(IScheduler))
  14684. )
  14685. );
  14686. }
  14687. /// <summary>
  14688. /// Creates an array from an observable sequence.
  14689. /// </summary>
  14690. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14691. /// <param name="source">The source observable sequence to get an array of elements for.</param>
  14692. /// <returns>An observable sequence containing a single element with an array containing all the elements of the source sequence.</returns>
  14693. /// <exception cref="T:System.ArgumentNullException">
  14694. /// <paramref name="source" /> is null.</exception>
  14695. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  14696. public static IQbservable<TSource[]> ToArray<TSource>(this IQbservable<TSource> source)
  14697. {
  14698. if (source == null)
  14699. throw new ArgumentNullException("source");
  14700. return source.Provider.CreateQuery<TSource[]>(
  14701. Expression.Call(
  14702. null,
  14703. #if CRIPPLED_REFLECTION
  14704. InfoOf(() => Qbservable.ToArray<TSource>(default(IQbservable<TSource>))),
  14705. #else
  14706. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14707. #endif
  14708. source.Expression
  14709. )
  14710. );
  14711. }
  14712. /// <summary>
  14713. /// Creates a dictionary from an observable sequence according to a specified key selector function.
  14714. /// </summary>
  14715. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14716. /// <typeparam name="TKey">The type of the dictionary key computed for each element in the source sequence.</typeparam>
  14717. /// <param name="source">An observable sequence to create a dictionary for.</param>
  14718. /// <param name="keySelector">A function to extract a key from each element.</param>
  14719. /// <returns>An observable sequence containing a single element with a dictionary mapping unique key values onto the corresponding source sequence's element.</returns>
  14720. /// <exception cref="T:System.ArgumentNullException">
  14721. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  14722. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  14723. public static IQbservable<IDictionary<TKey, TSource>> ToDictionary<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  14724. {
  14725. if (source == null)
  14726. throw new ArgumentNullException("source");
  14727. if (keySelector == null)
  14728. throw new ArgumentNullException("keySelector");
  14729. return source.Provider.CreateQuery<IDictionary<TKey, TSource>>(
  14730. Expression.Call(
  14731. null,
  14732. #if CRIPPLED_REFLECTION
  14733. InfoOf(() => Qbservable.ToDictionary<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  14734. #else
  14735. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  14736. #endif
  14737. source.Expression,
  14738. keySelector
  14739. )
  14740. );
  14741. }
  14742. /// <summary>
  14743. /// Creates a dictionary from an observable sequence according to a specified key selector function, and a comparer.
  14744. /// </summary>
  14745. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14746. /// <typeparam name="TKey">The type of the dictionary key computed for each element in the source sequence.</typeparam>
  14747. /// <param name="source">An observable sequence to create a dictionary for.</param>
  14748. /// <param name="keySelector">A function to extract a key from each element.</param>
  14749. /// <param name="comparer">An equality comparer to compare keys.</param>
  14750. /// <returns>An observable sequence containing a single element with a dictionary mapping unique key values onto the corresponding source sequence's element.</returns>
  14751. /// <exception cref="T:System.ArgumentNullException">
  14752. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  14753. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  14754. public static IQbservable<IDictionary<TKey, TSource>> ToDictionary<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  14755. {
  14756. if (source == null)
  14757. throw new ArgumentNullException("source");
  14758. if (keySelector == null)
  14759. throw new ArgumentNullException("keySelector");
  14760. if (comparer == null)
  14761. throw new ArgumentNullException("comparer");
  14762. return source.Provider.CreateQuery<IDictionary<TKey, TSource>>(
  14763. Expression.Call(
  14764. null,
  14765. #if CRIPPLED_REFLECTION
  14766. InfoOf(() => Qbservable.ToDictionary<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IEqualityComparer<TKey>))),
  14767. #else
  14768. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  14769. #endif
  14770. source.Expression,
  14771. keySelector,
  14772. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  14773. )
  14774. );
  14775. }
  14776. /// <summary>
  14777. /// Creates a dictionary from an observable sequence according to a specified key selector function, and an element selector function.
  14778. /// </summary>
  14779. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14780. /// <typeparam name="TKey">The type of the dictionary key computed for each element in the source sequence.</typeparam>
  14781. /// <typeparam name="TElement">The type of the dictionary value computed for each element in the source sequence.</typeparam>
  14782. /// <param name="source">An observable sequence to create a dictionary for.</param>
  14783. /// <param name="keySelector">A function to extract a key from each element.</param>
  14784. /// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
  14785. /// <returns>An observable sequence containing a single element with a dictionary mapping unique key values onto the corresponding source sequence's element.</returns>
  14786. /// <exception cref="T:System.ArgumentNullException">
  14787. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> is null.</exception>
  14788. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  14789. public static IQbservable<IDictionary<TKey, TElement>> ToDictionary<TSource, TKey, TElement>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector)
  14790. {
  14791. if (source == null)
  14792. throw new ArgumentNullException("source");
  14793. if (keySelector == null)
  14794. throw new ArgumentNullException("keySelector");
  14795. if (elementSelector == null)
  14796. throw new ArgumentNullException("elementSelector");
  14797. return source.Provider.CreateQuery<IDictionary<TKey, TElement>>(
  14798. Expression.Call(
  14799. null,
  14800. #if CRIPPLED_REFLECTION
  14801. InfoOf(() => Qbservable.ToDictionary<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>))),
  14802. #else
  14803. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  14804. #endif
  14805. source.Expression,
  14806. keySelector,
  14807. elementSelector
  14808. )
  14809. );
  14810. }
  14811. /// <summary>
  14812. /// Creates a dictionary from an observable sequence according to a specified key selector function, a comparer, and an element selector function.
  14813. /// </summary>
  14814. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14815. /// <typeparam name="TKey">The type of the dictionary key computed for each element in the source sequence.</typeparam>
  14816. /// <typeparam name="TElement">The type of the dictionary value computed for each element in the source sequence.</typeparam>
  14817. /// <param name="source">An observable sequence to create a dictionary for.</param>
  14818. /// <param name="keySelector">A function to extract a key from each element.</param>
  14819. /// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
  14820. /// <param name="comparer">An equality comparer to compare keys.</param>
  14821. /// <returns>An observable sequence containing a single element with a dictionary mapping unique key values onto the corresponding source sequence's element.</returns>
  14822. /// <exception cref="T:System.ArgumentNullException">
  14823. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="comparer" /> is null.</exception>
  14824. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  14825. 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)
  14826. {
  14827. if (source == null)
  14828. throw new ArgumentNullException("source");
  14829. if (keySelector == null)
  14830. throw new ArgumentNullException("keySelector");
  14831. if (elementSelector == null)
  14832. throw new ArgumentNullException("elementSelector");
  14833. if (comparer == null)
  14834. throw new ArgumentNullException("comparer");
  14835. return source.Provider.CreateQuery<IDictionary<TKey, TElement>>(
  14836. Expression.Call(
  14837. null,
  14838. #if CRIPPLED_REFLECTION
  14839. InfoOf(() => Qbservable.ToDictionary<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(IEqualityComparer<TKey>))),
  14840. #else
  14841. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  14842. #endif
  14843. source.Expression,
  14844. keySelector,
  14845. elementSelector,
  14846. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  14847. )
  14848. );
  14849. }
  14850. /// <summary>
  14851. /// Converts an observable sequence to an enumerable sequence.
  14852. /// </summary>
  14853. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14854. /// <param name="source">An observable sequence to convert to an enumerable sequence.</param>
  14855. /// <returns>The enumerable sequence containing the elements in the observable sequence.</returns>
  14856. /// <exception cref="T:System.ArgumentNullException">
  14857. /// <paramref name="source" /> is null.</exception>
  14858. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  14859. public static IQueryable<TSource> ToQueryable<TSource>(this IQbservable<TSource> source)
  14860. {
  14861. if (source == null)
  14862. throw new ArgumentNullException("source");
  14863. return ((IQueryProvider)source.Provider).CreateQuery<TSource>(
  14864. Expression.Call(
  14865. null,
  14866. #if CRIPPLED_REFLECTION
  14867. InfoOf(() => Qbservable.ToQueryable<TSource>(default(IQbservable<TSource>))),
  14868. #else
  14869. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14870. #endif
  14871. source.Expression
  14872. )
  14873. );
  14874. }
  14875. /// <summary>
  14876. /// Creates a list from an observable sequence.
  14877. /// </summary>
  14878. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14879. /// <param name="source">The source observable sequence to get a list of elements for.</param>
  14880. /// <returns>An observable sequence containing a single element with a list containing all the elements of the source sequence.</returns>
  14881. /// <exception cref="T:System.ArgumentNullException">
  14882. /// <paramref name="source" /> is null.</exception>
  14883. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  14884. public static IQbservable<IList<TSource>> ToList<TSource>(this IQbservable<TSource> source)
  14885. {
  14886. if (source == null)
  14887. throw new ArgumentNullException("source");
  14888. return source.Provider.CreateQuery<IList<TSource>>(
  14889. Expression.Call(
  14890. null,
  14891. #if CRIPPLED_REFLECTION
  14892. InfoOf(() => Qbservable.ToList<TSource>(default(IQbservable<TSource>))),
  14893. #else
  14894. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14895. #endif
  14896. source.Expression
  14897. )
  14898. );
  14899. }
  14900. /// <summary>
  14901. /// Creates a lookup from an observable sequence according to a specified key selector function.
  14902. /// </summary>
  14903. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14904. /// <typeparam name="TKey">The type of the lookup key computed for each element in the source sequence.</typeparam>
  14905. /// <param name="source">An observable sequence to create a lookup for.</param>
  14906. /// <param name="keySelector">A function to extract a key from each element.</param>
  14907. /// <returns>An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.</returns>
  14908. /// <exception cref="T:System.ArgumentNullException">
  14909. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  14910. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  14911. public static IQbservable<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  14912. {
  14913. if (source == null)
  14914. throw new ArgumentNullException("source");
  14915. if (keySelector == null)
  14916. throw new ArgumentNullException("keySelector");
  14917. return source.Provider.CreateQuery<ILookup<TKey, TSource>>(
  14918. Expression.Call(
  14919. null,
  14920. #if CRIPPLED_REFLECTION
  14921. InfoOf(() => Qbservable.ToLookup<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  14922. #else
  14923. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  14924. #endif
  14925. source.Expression,
  14926. keySelector
  14927. )
  14928. );
  14929. }
  14930. /// <summary>
  14931. /// Creates a lookup from an observable sequence according to a specified key selector function, and a comparer.
  14932. /// </summary>
  14933. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14934. /// <typeparam name="TKey">The type of the lookup key computed for each element in the source sequence.</typeparam>
  14935. /// <param name="source">An observable sequence to create a lookup for.</param>
  14936. /// <param name="keySelector">A function to extract a key from each element.</param>
  14937. /// <param name="comparer">An equality comparer to compare keys.</param>
  14938. /// <returns>An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.</returns>
  14939. /// <exception cref="T:System.ArgumentNullException">
  14940. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  14941. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  14942. public static IQbservable<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  14943. {
  14944. if (source == null)
  14945. throw new ArgumentNullException("source");
  14946. if (keySelector == null)
  14947. throw new ArgumentNullException("keySelector");
  14948. if (comparer == null)
  14949. throw new ArgumentNullException("comparer");
  14950. return source.Provider.CreateQuery<ILookup<TKey, TSource>>(
  14951. Expression.Call(
  14952. null,
  14953. #if CRIPPLED_REFLECTION
  14954. InfoOf(() => Qbservable.ToLookup<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IEqualityComparer<TKey>))),
  14955. #else
  14956. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  14957. #endif
  14958. source.Expression,
  14959. keySelector,
  14960. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  14961. )
  14962. );
  14963. }
  14964. /// <summary>
  14965. /// Creates a lookup from an observable sequence according to a specified key selector function, and an element selector function.
  14966. /// </summary>
  14967. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14968. /// <typeparam name="TKey">The type of the lookup key computed for each element in the source sequence.</typeparam>
  14969. /// <typeparam name="TElement">The type of the lookup value computed for each element in the source sequence.</typeparam>
  14970. /// <param name="source">An observable sequence to create a lookup for.</param>
  14971. /// <param name="keySelector">A function to extract a key from each element.</param>
  14972. /// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
  14973. /// <returns>An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.</returns>
  14974. /// <exception cref="T:System.ArgumentNullException">
  14975. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> is null.</exception>
  14976. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  14977. public static IQbservable<ILookup<TKey, TElement>> ToLookup<TSource, TKey, TElement>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector)
  14978. {
  14979. if (source == null)
  14980. throw new ArgumentNullException("source");
  14981. if (keySelector == null)
  14982. throw new ArgumentNullException("keySelector");
  14983. if (elementSelector == null)
  14984. throw new ArgumentNullException("elementSelector");
  14985. return source.Provider.CreateQuery<ILookup<TKey, TElement>>(
  14986. Expression.Call(
  14987. null,
  14988. #if CRIPPLED_REFLECTION
  14989. InfoOf(() => Qbservable.ToLookup<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>))),
  14990. #else
  14991. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  14992. #endif
  14993. source.Expression,
  14994. keySelector,
  14995. elementSelector
  14996. )
  14997. );
  14998. }
  14999. /// <summary>
  15000. /// Creates a lookup from an observable sequence according to a specified key selector function, a comparer, and an element selector function.
  15001. /// </summary>
  15002. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15003. /// <typeparam name="TKey">The type of the lookup key computed for each element in the source sequence.</typeparam>
  15004. /// <typeparam name="TElement">The type of the lookup value computed for each element in the source sequence.</typeparam>
  15005. /// <param name="source">An observable sequence to create a lookup for.</param>
  15006. /// <param name="keySelector">A function to extract a key from each element.</param>
  15007. /// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
  15008. /// <param name="comparer">An equality comparer to compare keys.</param>
  15009. /// <returns>An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.</returns>
  15010. /// <exception cref="T:System.ArgumentNullException">
  15011. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="comparer" /> is null.</exception>
  15012. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15013. 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)
  15014. {
  15015. if (source == null)
  15016. throw new ArgumentNullException("source");
  15017. if (keySelector == null)
  15018. throw new ArgumentNullException("keySelector");
  15019. if (elementSelector == null)
  15020. throw new ArgumentNullException("elementSelector");
  15021. if (comparer == null)
  15022. throw new ArgumentNullException("comparer");
  15023. return source.Provider.CreateQuery<ILookup<TKey, TElement>>(
  15024. Expression.Call(
  15025. null,
  15026. #if CRIPPLED_REFLECTION
  15027. InfoOf(() => Qbservable.ToLookup<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(IEqualityComparer<TKey>))),
  15028. #else
  15029. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  15030. #endif
  15031. source.Expression,
  15032. keySelector,
  15033. elementSelector,
  15034. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  15035. )
  15036. );
  15037. }
  15038. /// <summary>
  15039. /// Converts an enumerable sequence to an observable sequence.
  15040. /// </summary>
  15041. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  15042. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15043. /// <param name="source">Enumerable sequence to convert to an observable sequence.</param>
  15044. /// <returns>The observable sequence whose elements are pulled from the given enumerable sequence.</returns>
  15045. /// <exception cref="T:System.ArgumentNullException">
  15046. /// <paramref name="source" /> is null.</exception>
  15047. public static IQbservable<TSource> ToObservable<TSource>(this IQbservableProvider provider, IEnumerable<TSource> source)
  15048. {
  15049. if (provider == null)
  15050. throw new ArgumentNullException("provider");
  15051. if (source == null)
  15052. throw new ArgumentNullException("source");
  15053. return provider.CreateQuery<TSource>(
  15054. Expression.Call(
  15055. null,
  15056. #if CRIPPLED_REFLECTION
  15057. InfoOf(() => Qbservable.ToObservable<TSource>(default(IQbservableProvider), default(IEnumerable<TSource>))),
  15058. #else
  15059. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15060. #endif
  15061. Expression.Constant(provider, typeof(IQbservableProvider)),
  15062. GetSourceExpression(source)
  15063. )
  15064. );
  15065. }
  15066. /// <summary>
  15067. /// Converts an enumerable sequence to an observable sequence, using the specified scheduler to run the enumeration loop.
  15068. /// </summary>
  15069. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  15070. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15071. /// <param name="source">Enumerable sequence to convert to an observable sequence.</param>
  15072. /// <param name="scheduler">Scheduler to run the enumeration of the input sequence on.</param>
  15073. /// <returns>The observable sequence whose elements are pulled from the given enumerable sequence.</returns>
  15074. /// <exception cref="T:System.ArgumentNullException">
  15075. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  15076. public static IQbservable<TSource> ToObservable<TSource>(this IQbservableProvider provider, IEnumerable<TSource> source, IScheduler scheduler)
  15077. {
  15078. if (provider == null)
  15079. throw new ArgumentNullException("provider");
  15080. if (source == null)
  15081. throw new ArgumentNullException("source");
  15082. if (scheduler == null)
  15083. throw new ArgumentNullException("scheduler");
  15084. return provider.CreateQuery<TSource>(
  15085. Expression.Call(
  15086. null,
  15087. #if CRIPPLED_REFLECTION
  15088. InfoOf(() => Qbservable.ToObservable<TSource>(default(IQbservableProvider), default(IEnumerable<TSource>), default(IScheduler))),
  15089. #else
  15090. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15091. #endif
  15092. Expression.Constant(provider, typeof(IQbservableProvider)),
  15093. GetSourceExpression(source),
  15094. Expression.Constant(scheduler, typeof(IScheduler))
  15095. )
  15096. );
  15097. }
  15098. /// <summary>
  15099. /// Constructs an observable sequence that depends on a resource object, whose lifetime is tied to the resulting observable sequence's lifetime.
  15100. /// </summary>
  15101. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  15102. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  15103. /// <typeparam name="TResource">The type of the resource used during the generation of the resulting sequence. Needs to implement <see cref="T:System.IDisposable" />.</typeparam>
  15104. /// <param name="resourceFactory">Factory function to obtain a resource object.</param>
  15105. /// <param name="observableFactory">Factory function to obtain an observable sequence that depends on the obtained resource.</param>
  15106. /// <returns>An observable sequence whose lifetime controls the lifetime of the dependent resource object.</returns>
  15107. /// <exception cref="T:System.ArgumentNullException">
  15108. /// <paramref name="resourceFactory" /> or <paramref name="observableFactory" /> is null.</exception>
  15109. public static IQbservable<TResult> Using<TResult, TResource>(this IQbservableProvider provider, Expression<Func<TResource>> resourceFactory, Expression<Func<TResource, IObservable<TResult>>> observableFactory)
  15110. where TResource : IDisposable
  15111. {
  15112. if (provider == null)
  15113. throw new ArgumentNullException("provider");
  15114. if (resourceFactory == null)
  15115. throw new ArgumentNullException("resourceFactory");
  15116. if (observableFactory == null)
  15117. throw new ArgumentNullException("observableFactory");
  15118. return provider.CreateQuery<TResult>(
  15119. Expression.Call(
  15120. null,
  15121. #if CRIPPLED_REFLECTION
  15122. InfoOf(() => Qbservable.Using<TResult, TResource>(default(IQbservableProvider), default(Expression<Func<TResource>>), default(Expression<Func<TResource, IObservable<TResult>>>))),
  15123. #else
  15124. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult), typeof(TResource)),
  15125. #endif
  15126. Expression.Constant(provider, typeof(IQbservableProvider)),
  15127. resourceFactory,
  15128. observableFactory
  15129. )
  15130. );
  15131. }
  15132. #if !NO_TPL
  15133. /// <summary>
  15134. /// 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.
  15135. /// 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.
  15136. /// </summary>
  15137. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  15138. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  15139. /// <typeparam name="TResource">The type of the resource used during the generation of the resulting sequence. Needs to implement <see cref="T:System.IDisposable" />.</typeparam>
  15140. /// <param name="resourceFactoryAsync">Asynchronous factory function to obtain a resource object.</param>
  15141. /// <param name="observableFactoryAsync">Asynchronous factory function to obtain an observable sequence that depends on the obtained resource.</param>
  15142. /// <returns>An observable sequence whose lifetime controls the lifetime of the dependent resource object.</returns>
  15143. /// <exception cref="T:System.ArgumentNullException">
  15144. /// <paramref name="resourceFactoryAsync" /> or <paramref name="observableFactoryAsync" /> is null.</exception>
  15145. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  15146. /// <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>
  15147. public static IQbservable<TResult> Using<TResult, TResource>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<TResource>>> resourceFactoryAsync, Expression<Func<TResource, CancellationToken, Task<IObservable<TResult>>>> observableFactoryAsync)
  15148. where TResource : IDisposable
  15149. {
  15150. if (provider == null)
  15151. throw new ArgumentNullException("provider");
  15152. if (resourceFactoryAsync == null)
  15153. throw new ArgumentNullException("resourceFactoryAsync");
  15154. if (observableFactoryAsync == null)
  15155. throw new ArgumentNullException("observableFactoryAsync");
  15156. return provider.CreateQuery<TResult>(
  15157. Expression.Call(
  15158. null,
  15159. #if CRIPPLED_REFLECTION
  15160. InfoOf(() => Qbservable.Using<TResult, TResource>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<TResource>>>), default(Expression<Func<TResource, CancellationToken, Task<IObservable<TResult>>>>))),
  15161. #else
  15162. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult), typeof(TResource)),
  15163. #endif
  15164. Expression.Constant(provider, typeof(IQbservableProvider)),
  15165. resourceFactoryAsync,
  15166. observableFactoryAsync
  15167. )
  15168. );
  15169. }
  15170. #endif
  15171. /// <summary>
  15172. /// Filters the elements of an observable sequence based on a predicate.
  15173. /// </summary>
  15174. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15175. /// <param name="source">An observable sequence whose elements to filter.</param>
  15176. /// <param name="predicate">A function to test each source element for a condition.</param>
  15177. /// <returns>An observable sequence that contains elements from the input sequence that satisfy the condition.</returns>
  15178. /// <exception cref="T:System.ArgumentNullException">
  15179. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  15180. public static IQbservable<TSource> Where<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  15181. {
  15182. if (source == null)
  15183. throw new ArgumentNullException("source");
  15184. if (predicate == null)
  15185. throw new ArgumentNullException("predicate");
  15186. return source.Provider.CreateQuery<TSource>(
  15187. Expression.Call(
  15188. null,
  15189. #if CRIPPLED_REFLECTION
  15190. InfoOf(() => Qbservable.Where<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  15191. #else
  15192. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15193. #endif
  15194. source.Expression,
  15195. predicate
  15196. )
  15197. );
  15198. }
  15199. /// <summary>
  15200. /// Filters the elements of an observable sequence based on a predicate by incorporating the element's index.
  15201. /// </summary>
  15202. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15203. /// <param name="source">An observable sequence whose elements to filter.</param>
  15204. /// <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>
  15205. /// <returns>An observable sequence that contains elements from the input sequence that satisfy the condition.</returns>
  15206. /// <exception cref="T:System.ArgumentNullException">
  15207. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  15208. public static IQbservable<TSource> Where<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int, bool>> predicate)
  15209. {
  15210. if (source == null)
  15211. throw new ArgumentNullException("source");
  15212. if (predicate == null)
  15213. throw new ArgumentNullException("predicate");
  15214. return source.Provider.CreateQuery<TSource>(
  15215. Expression.Call(
  15216. null,
  15217. #if CRIPPLED_REFLECTION
  15218. InfoOf(() => Qbservable.Where<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, bool>>))),
  15219. #else
  15220. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15221. #endif
  15222. source.Expression,
  15223. predicate
  15224. )
  15225. );
  15226. }
  15227. /// <summary>
  15228. /// 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.
  15229. /// </summary>
  15230. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  15231. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15232. /// <param name="source">Source to repeat as long as the <paramref name="condition" /> function evaluates to true.</param>
  15233. /// <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>
  15234. /// <returns>The observable sequence obtained by concatenating the <paramref name="source" /> sequence as long as the <paramref name="condition" /> holds.</returns>
  15235. /// <exception cref="T:System.ArgumentNullException">
  15236. /// <paramref name="condition" /> or <paramref name="source" /> is null.</exception>
  15237. public static IQbservable<TSource> While<TSource>(this IQbservableProvider provider, Expression<Func<bool>> condition, IObservable<TSource> source)
  15238. {
  15239. if (provider == null)
  15240. throw new ArgumentNullException("provider");
  15241. if (condition == null)
  15242. throw new ArgumentNullException("condition");
  15243. if (source == null)
  15244. throw new ArgumentNullException("source");
  15245. return provider.CreateQuery<TSource>(
  15246. Expression.Call(
  15247. null,
  15248. #if CRIPPLED_REFLECTION
  15249. InfoOf(() => Qbservable.While<TSource>(default(IQbservableProvider), default(Expression<Func<bool>>), default(IObservable<TSource>))),
  15250. #else
  15251. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15252. #endif
  15253. Expression.Constant(provider, typeof(IQbservableProvider)),
  15254. condition,
  15255. GetSourceExpression(source)
  15256. )
  15257. );
  15258. }
  15259. /// <summary>
  15260. /// Projects each element of an observable sequence into consecutive non-overlapping windows which are produced based on element count information.
  15261. /// </summary>
  15262. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  15263. /// <param name="source">Source sequence to produce windows over.</param>
  15264. /// <param name="count">Length of each window.</param>
  15265. /// <returns>An observable sequence of windows.</returns>
  15266. /// <exception cref="T:System.ArgumentNullException">
  15267. /// <paramref name="source" /> is null.</exception>
  15268. /// <exception cref="T:System.ArgumentOutOfRangeException">
  15269. /// <paramref name="count" /> is less than or equal to zero.</exception>
  15270. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, int count)
  15271. {
  15272. if (source == null)
  15273. throw new ArgumentNullException("source");
  15274. return source.Provider.CreateQuery<IObservable<TSource>>(
  15275. Expression.Call(
  15276. null,
  15277. #if CRIPPLED_REFLECTION
  15278. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(int))),
  15279. #else
  15280. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15281. #endif
  15282. source.Expression,
  15283. Expression.Constant(count, typeof(int))
  15284. )
  15285. );
  15286. }
  15287. /// <summary>
  15288. /// Projects each element of an observable sequence into zero or more windows which are produced based on element count information.
  15289. /// </summary>
  15290. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  15291. /// <param name="source">Source sequence to produce windows over.</param>
  15292. /// <param name="count">Length of each window.</param>
  15293. /// <param name="skip">Number of elements to skip between creation of consecutive windows.</param>
  15294. /// <returns>An observable sequence of windows.</returns>
  15295. /// <exception cref="T:System.ArgumentNullException">
  15296. /// <paramref name="source" /> is null.</exception>
  15297. /// <exception cref="T:System.ArgumentOutOfRangeException">
  15298. /// <paramref name="count" /> or <paramref name="skip" /> is less than or equal to zero.</exception>
  15299. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, int count, int skip)
  15300. {
  15301. if (source == null)
  15302. throw new ArgumentNullException("source");
  15303. return source.Provider.CreateQuery<IObservable<TSource>>(
  15304. Expression.Call(
  15305. null,
  15306. #if CRIPPLED_REFLECTION
  15307. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(int), default(int))),
  15308. #else
  15309. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15310. #endif
  15311. source.Expression,
  15312. Expression.Constant(count, typeof(int)),
  15313. Expression.Constant(skip, typeof(int))
  15314. )
  15315. );
  15316. }
  15317. /// <summary>
  15318. /// Projects each element of an observable sequence into consecutive non-overlapping windows which are produced based on timing information.
  15319. /// </summary>
  15320. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  15321. /// <param name="source">Source sequence to produce windows over.</param>
  15322. /// <param name="timeSpan">Length of each window.</param>
  15323. /// <returns>The sequence of windows.</returns>
  15324. /// <exception cref="T:System.ArgumentNullException">
  15325. /// <paramref name="source" /> is null.</exception>
  15326. /// <exception cref="T:System.ArgumentOutOfRangeException">
  15327. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  15328. /// <remarks>
  15329. /// 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.
  15330. /// 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
  15331. /// 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.
  15332. /// </remarks>
  15333. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan)
  15334. {
  15335. if (source == null)
  15336. throw new ArgumentNullException("source");
  15337. return source.Provider.CreateQuery<IObservable<TSource>>(
  15338. Expression.Call(
  15339. null,
  15340. #if CRIPPLED_REFLECTION
  15341. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  15342. #else
  15343. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15344. #endif
  15345. source.Expression,
  15346. Expression.Constant(timeSpan, typeof(TimeSpan))
  15347. )
  15348. );
  15349. }
  15350. /// <summary>
  15351. /// 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.
  15352. /// 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.
  15353. /// </summary>
  15354. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  15355. /// <param name="source">Source sequence to produce windows over.</param>
  15356. /// <param name="timeSpan">Maximum time length of a window.</param>
  15357. /// <param name="count">Maximum element count of a window.</param>
  15358. /// <returns>An observable sequence of windows.</returns>
  15359. /// <exception cref="T:System.ArgumentNullException">
  15360. /// <paramref name="source" /> is null.</exception>
  15361. /// <exception cref="T:System.ArgumentOutOfRangeException">
  15362. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero. -or- <paramref name="count" /> is less than or equal to zero.</exception>
  15363. /// <remarks>
  15364. /// 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.
  15365. /// 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
  15366. /// 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.
  15367. /// </remarks>
  15368. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, int count)
  15369. {
  15370. if (source == null)
  15371. throw new ArgumentNullException("source");
  15372. return source.Provider.CreateQuery<IObservable<TSource>>(
  15373. Expression.Call(
  15374. null,
  15375. #if CRIPPLED_REFLECTION
  15376. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(int))),
  15377. #else
  15378. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15379. #endif
  15380. source.Expression,
  15381. Expression.Constant(timeSpan, typeof(TimeSpan)),
  15382. Expression.Constant(count, typeof(int))
  15383. )
  15384. );
  15385. }
  15386. /// <summary>
  15387. /// 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.
  15388. /// 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.
  15389. /// </summary>
  15390. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  15391. /// <param name="source">Source sequence to produce windows over.</param>
  15392. /// <param name="timeSpan">Maximum time length of a window.</param>
  15393. /// <param name="count">Maximum element count of a window.</param>
  15394. /// <param name="scheduler">Scheduler to run windowing timers on.</param>
  15395. /// <returns>An observable sequence of windows.</returns>
  15396. /// <exception cref="T:System.ArgumentNullException">
  15397. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  15398. /// <exception cref="T:System.ArgumentOutOfRangeException">
  15399. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero. -or- <paramref name="count" /> is less than or equal to zero.</exception>
  15400. /// <remarks>
  15401. /// 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.
  15402. /// 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
  15403. /// 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.
  15404. /// </remarks>
  15405. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, int count, IScheduler scheduler)
  15406. {
  15407. if (source == null)
  15408. throw new ArgumentNullException("source");
  15409. if (scheduler == null)
  15410. throw new ArgumentNullException("scheduler");
  15411. return source.Provider.CreateQuery<IObservable<TSource>>(
  15412. Expression.Call(
  15413. null,
  15414. #if CRIPPLED_REFLECTION
  15415. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(int), default(IScheduler))),
  15416. #else
  15417. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15418. #endif
  15419. source.Expression,
  15420. Expression.Constant(timeSpan, typeof(TimeSpan)),
  15421. Expression.Constant(count, typeof(int)),
  15422. Expression.Constant(scheduler, typeof(IScheduler))
  15423. )
  15424. );
  15425. }
  15426. /// <summary>
  15427. /// 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.
  15428. /// </summary>
  15429. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  15430. /// <param name="source">Source sequence to produce windows over.</param>
  15431. /// <param name="timeSpan">Length of each window.</param>
  15432. /// <param name="scheduler">Scheduler to run windowing timers on.</param>
  15433. /// <returns>An observable sequence of windows.</returns>
  15434. /// <exception cref="T:System.ArgumentNullException">
  15435. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  15436. /// <exception cref="T:System.ArgumentOutOfRangeException">
  15437. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  15438. /// <remarks>
  15439. /// 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.
  15440. /// 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
  15441. /// 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.
  15442. /// </remarks>
  15443. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, IScheduler scheduler)
  15444. {
  15445. if (source == null)
  15446. throw new ArgumentNullException("source");
  15447. if (scheduler == null)
  15448. throw new ArgumentNullException("scheduler");
  15449. return source.Provider.CreateQuery<IObservable<TSource>>(
  15450. Expression.Call(
  15451. null,
  15452. #if CRIPPLED_REFLECTION
  15453. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  15454. #else
  15455. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15456. #endif
  15457. source.Expression,
  15458. Expression.Constant(timeSpan, typeof(TimeSpan)),
  15459. Expression.Constant(scheduler, typeof(IScheduler))
  15460. )
  15461. );
  15462. }
  15463. /// <summary>
  15464. /// Projects each element of an observable sequence into zero or more windows which are produced based on timing information.
  15465. /// </summary>
  15466. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  15467. /// <param name="source">Source sequence to produce windows over.</param>
  15468. /// <param name="timeSpan">Length of each window.</param>
  15469. /// <param name="timeShift">Interval between creation of consecutive windows.</param>
  15470. /// <returns>An observable sequence of windows.</returns>
  15471. /// <exception cref="T:System.ArgumentNullException">
  15472. /// <paramref name="source" /> is null.</exception>
  15473. /// <exception cref="T:System.ArgumentOutOfRangeException">
  15474. /// <paramref name="timeSpan" /> or <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  15475. /// <remarks>
  15476. /// <para>
  15477. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create windows with minimum duration
  15478. /// 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
  15479. /// current window may not execute immediately, despite the TimeSpan.Zero due time.
  15480. /// </para>
  15481. /// <para>
  15482. /// 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.
  15483. /// 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,
  15484. /// where the action to create a new window may not execute immediately, despite the TimeSpan.Zero due time.
  15485. /// </para>
  15486. /// </remarks>
  15487. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, TimeSpan timeShift)
  15488. {
  15489. if (source == null)
  15490. throw new ArgumentNullException("source");
  15491. return source.Provider.CreateQuery<IObservable<TSource>>(
  15492. Expression.Call(
  15493. null,
  15494. #if CRIPPLED_REFLECTION
  15495. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(TimeSpan))),
  15496. #else
  15497. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15498. #endif
  15499. source.Expression,
  15500. Expression.Constant(timeSpan, typeof(TimeSpan)),
  15501. Expression.Constant(timeShift, typeof(TimeSpan))
  15502. )
  15503. );
  15504. }
  15505. /// <summary>
  15506. /// 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.
  15507. /// </summary>
  15508. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  15509. /// <param name="source">Source sequence to produce windows over.</param>
  15510. /// <param name="timeSpan">Length of each window.</param>
  15511. /// <param name="timeShift">Interval between creation of consecutive windows.</param>
  15512. /// <param name="scheduler">Scheduler to run windowing timers on.</param>
  15513. /// <returns>An observable sequence of windows.</returns>
  15514. /// <exception cref="T:System.ArgumentNullException">
  15515. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  15516. /// <exception cref="T:System.ArgumentOutOfRangeException">
  15517. /// <paramref name="timeSpan" /> or <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  15518. /// <remarks>
  15519. /// <para>
  15520. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create windows with minimum duration
  15521. /// 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
  15522. /// current window may not execute immediately, despite the TimeSpan.Zero due time.
  15523. /// </para>
  15524. /// <para>
  15525. /// 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.
  15526. /// 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,
  15527. /// where the action to create a new window may not execute immediately, despite the TimeSpan.Zero due time.
  15528. /// </para>
  15529. /// </remarks>
  15530. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, TimeSpan timeShift, IScheduler scheduler)
  15531. {
  15532. if (source == null)
  15533. throw new ArgumentNullException("source");
  15534. if (scheduler == null)
  15535. throw new ArgumentNullException("scheduler");
  15536. return source.Provider.CreateQuery<IObservable<TSource>>(
  15537. Expression.Call(
  15538. null,
  15539. #if CRIPPLED_REFLECTION
  15540. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(TimeSpan), default(IScheduler))),
  15541. #else
  15542. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15543. #endif
  15544. source.Expression,
  15545. Expression.Constant(timeSpan, typeof(TimeSpan)),
  15546. Expression.Constant(timeShift, typeof(TimeSpan)),
  15547. Expression.Constant(scheduler, typeof(IScheduler))
  15548. )
  15549. );
  15550. }
  15551. /// <summary>
  15552. /// Projects each element of an observable sequence into consecutive non-overlapping windows.
  15553. /// </summary>
  15554. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  15555. /// <typeparam name="TWindowBoundary">The type of the elements in the sequences indicating window boundary events.</typeparam>
  15556. /// <param name="source">Source sequence to produce windows over.</param>
  15557. /// <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>
  15558. /// <returns>An observable sequence of windows.</returns>
  15559. /// <exception cref="T:System.ArgumentNullException">
  15560. /// <paramref name="source" /> or <paramref name="windowBoundaries" /> is null.</exception>
  15561. public static IQbservable<IObservable<TSource>> Window<TSource, TWindowBoundary>(this IQbservable<TSource> source, IObservable<TWindowBoundary> windowBoundaries)
  15562. {
  15563. if (source == null)
  15564. throw new ArgumentNullException("source");
  15565. if (windowBoundaries == null)
  15566. throw new ArgumentNullException("windowBoundaries");
  15567. return source.Provider.CreateQuery<IObservable<TSource>>(
  15568. Expression.Call(
  15569. null,
  15570. #if CRIPPLED_REFLECTION
  15571. InfoOf(() => Qbservable.Window<TSource, TWindowBoundary>(default(IQbservable<TSource>), default(IObservable<TWindowBoundary>))),
  15572. #else
  15573. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TWindowBoundary)),
  15574. #endif
  15575. source.Expression,
  15576. GetSourceExpression(windowBoundaries)
  15577. )
  15578. );
  15579. }
  15580. /// <summary>
  15581. /// Projects each element of an observable sequence into consecutive non-overlapping windows.
  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. /// <typeparam name="TWindowClosing">The type of the elements in the sequences indicating window closing events.</typeparam>
  15585. /// <param name="source">Source sequence to produce windows over.</param>
  15586. /// <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>
  15587. /// <returns>An observable sequence of windows.</returns>
  15588. /// <exception cref="T:System.ArgumentNullException">
  15589. /// <paramref name="source" /> or <paramref name="windowClosingSelector" /> is null.</exception>
  15590. public static IQbservable<IObservable<TSource>> Window<TSource, TWindowClosing>(this IQbservable<TSource> source, Expression<Func<IObservable<TWindowClosing>>> windowClosingSelector)
  15591. {
  15592. if (source == null)
  15593. throw new ArgumentNullException("source");
  15594. if (windowClosingSelector == null)
  15595. throw new ArgumentNullException("windowClosingSelector");
  15596. return source.Provider.CreateQuery<IObservable<TSource>>(
  15597. Expression.Call(
  15598. null,
  15599. #if CRIPPLED_REFLECTION
  15600. InfoOf(() => Qbservable.Window<TSource, TWindowClosing>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TWindowClosing>>>))),
  15601. #else
  15602. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TWindowClosing)),
  15603. #endif
  15604. source.Expression,
  15605. windowClosingSelector
  15606. )
  15607. );
  15608. }
  15609. /// <summary>
  15610. /// Projects each element of an observable sequence into zero or more windows.
  15611. /// </summary>
  15612. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  15613. /// <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>
  15614. /// <typeparam name="TWindowClosing">The type of the elements in the sequences indicating window closing events.</typeparam>
  15615. /// <param name="source">Source sequence to produce windows over.</param>
  15616. /// <param name="windowOpenings">Observable sequence whose elements denote the creation of new windows.</param>
  15617. /// <param name="windowClosingSelector">A function invoked to define the closing of each produced window.</param>
  15618. /// <returns>An observable sequence of windows.</returns>
  15619. /// <exception cref="T:System.ArgumentNullException">
  15620. /// <paramref name="source" /> or <paramref name="windowOpenings" /> or <paramref name="windowClosingSelector" /> is null.</exception>
  15621. public static IQbservable<IObservable<TSource>> Window<TSource, TWindowOpening, TWindowClosing>(this IQbservable<TSource> source, IObservable<TWindowOpening> windowOpenings, Expression<Func<TWindowOpening, IObservable<TWindowClosing>>> windowClosingSelector)
  15622. {
  15623. if (source == null)
  15624. throw new ArgumentNullException("source");
  15625. if (windowOpenings == null)
  15626. throw new ArgumentNullException("windowOpenings");
  15627. if (windowClosingSelector == null)
  15628. throw new ArgumentNullException("windowClosingSelector");
  15629. return source.Provider.CreateQuery<IObservable<TSource>>(
  15630. Expression.Call(
  15631. null,
  15632. #if CRIPPLED_REFLECTION
  15633. InfoOf(() => Qbservable.Window<TSource, TWindowOpening, TWindowClosing>(default(IQbservable<TSource>), default(IObservable<TWindowOpening>), default(Expression<Func<TWindowOpening, IObservable<TWindowClosing>>>))),
  15634. #else
  15635. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TWindowOpening), typeof(TWindowClosing)),
  15636. #endif
  15637. source.Expression,
  15638. GetSourceExpression(windowOpenings),
  15639. windowClosingSelector
  15640. )
  15641. );
  15642. }
  15643. /// <summary>
  15644. /// Merges the specified observable sequences into one observable sequence by emitting a list with the elements of the observable sequences at corresponding indexes.
  15645. /// </summary>
  15646. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  15647. /// <typeparam name="TSource">The type of the elements in the source sequences, and in the lists in the result sequence.</typeparam>
  15648. /// <param name="sources">Observable sources.</param>
  15649. /// <returns>An observable sequence containing lists of elements at corresponding indexes.</returns>
  15650. /// <exception cref="T:System.ArgumentNullException">
  15651. /// <paramref name="sources" /> is null.</exception>
  15652. public static IQbservable<IList<TSource>> Zip<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  15653. {
  15654. if (provider == null)
  15655. throw new ArgumentNullException("provider");
  15656. if (sources == null)
  15657. throw new ArgumentNullException("sources");
  15658. return provider.CreateQuery<IList<TSource>>(
  15659. Expression.Call(
  15660. null,
  15661. #if CRIPPLED_REFLECTION
  15662. InfoOf(() => Qbservable.Zip<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  15663. #else
  15664. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15665. #endif
  15666. Expression.Constant(provider, typeof(IQbservableProvider)),
  15667. GetSourceExpression(sources)
  15668. )
  15669. );
  15670. }
  15671. /// <summary>
  15672. /// Merges the specified observable sequences into one observable sequence by emitting a list with the elements of the observable sequences at corresponding indexes.
  15673. /// </summary>
  15674. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  15675. /// <typeparam name="TSource">The type of the elements in the source sequences, and in the lists in the result sequence.</typeparam>
  15676. /// <param name="sources">Observable sources.</param>
  15677. /// <returns>An observable sequence containing lists of elements at corresponding indexes.</returns>
  15678. /// <exception cref="T:System.ArgumentNullException">
  15679. /// <paramref name="sources" /> is null.</exception>
  15680. public static IQbservable<IList<TSource>> Zip<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  15681. {
  15682. if (provider == null)
  15683. throw new ArgumentNullException("provider");
  15684. if (sources == null)
  15685. throw new ArgumentNullException("sources");
  15686. return provider.CreateQuery<IList<TSource>>(
  15687. Expression.Call(
  15688. null,
  15689. #if CRIPPLED_REFLECTION
  15690. InfoOf(() => Qbservable.Zip<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  15691. #else
  15692. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15693. #endif
  15694. Expression.Constant(provider, typeof(IQbservableProvider)),
  15695. GetSourceExpression(sources)
  15696. )
  15697. );
  15698. }
  15699. /// <summary>
  15700. /// 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.
  15701. /// </summary>
  15702. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  15703. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  15704. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  15705. /// <param name="sources">Observable sources.</param>
  15706. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  15707. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  15708. /// <exception cref="T:System.ArgumentNullException">
  15709. /// <paramref name="sources" /> or <paramref name="resultSelector" /> is null.</exception>
  15710. public static IQbservable<TResult> Zip<TSource, TResult>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, Expression<Func<IList<TSource>, TResult>> resultSelector)
  15711. {
  15712. if (provider == null)
  15713. throw new ArgumentNullException("provider");
  15714. if (sources == null)
  15715. throw new ArgumentNullException("sources");
  15716. if (resultSelector == null)
  15717. throw new ArgumentNullException("resultSelector");
  15718. return provider.CreateQuery<TResult>(
  15719. Expression.Call(
  15720. null,
  15721. #if CRIPPLED_REFLECTION
  15722. InfoOf(() => Qbservable.Zip<TSource, TResult>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(Expression<Func<IList<TSource>, TResult>>))),
  15723. #else
  15724. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  15725. #endif
  15726. Expression.Constant(provider, typeof(IQbservableProvider)),
  15727. GetSourceExpression(sources),
  15728. resultSelector
  15729. )
  15730. );
  15731. }
  15732. /// <summary>
  15733. /// Merges two observable sequences into one observable sequence by combining their elements in a pairwise fashion.
  15734. /// </summary>
  15735. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  15736. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  15737. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  15738. /// <param name="first">First observable source.</param>
  15739. /// <param name="second">Second observable source.</param>
  15740. /// <param name="resultSelector">Function to invoke for each consecutive pair of elements from the first and second source.</param>
  15741. /// <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>
  15742. /// <exception cref="T:System.ArgumentNullException">
  15743. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="resultSelector" /> is null.</exception>
  15744. public static IQbservable<TResult> Zip<TSource1, TSource2, TResult>(this IQbservable<TSource1> first, IObservable<TSource2> second, Expression<Func<TSource1, TSource2, TResult>> resultSelector)
  15745. {
  15746. if (first == null)
  15747. throw new ArgumentNullException("first");
  15748. if (second == null)
  15749. throw new ArgumentNullException("second");
  15750. if (resultSelector == null)
  15751. throw new ArgumentNullException("resultSelector");
  15752. return first.Provider.CreateQuery<TResult>(
  15753. Expression.Call(
  15754. null,
  15755. #if CRIPPLED_REFLECTION
  15756. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(Expression<Func<TSource1, TSource2, TResult>>))),
  15757. #else
  15758. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TResult)),
  15759. #endif
  15760. first.Expression,
  15761. GetSourceExpression(second),
  15762. resultSelector
  15763. )
  15764. );
  15765. }
  15766. /// <summary>
  15767. /// Merges an observable sequence and an enumerable sequence into one observable sequence by using the selector function.
  15768. /// </summary>
  15769. /// <typeparam name="TSource1">The type of the elements in the first observable source sequence.</typeparam>
  15770. /// <typeparam name="TSource2">The type of the elements in the second enumerable source sequence.</typeparam>
  15771. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  15772. /// <param name="first">First observable source.</param>
  15773. /// <param name="second">Second enumerable source.</param>
  15774. /// <param name="resultSelector">Function to invoke for each consecutive pair of elements from the first and second source.</param>
  15775. /// <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>
  15776. /// <exception cref="T:System.ArgumentNullException">
  15777. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="resultSelector" /> is null.</exception>
  15778. public static IQbservable<TResult> Zip<TSource1, TSource2, TResult>(this IQbservable<TSource1> first, IEnumerable<TSource2> second, Expression<Func<TSource1, TSource2, TResult>> resultSelector)
  15779. {
  15780. if (first == null)
  15781. throw new ArgumentNullException("first");
  15782. if (second == null)
  15783. throw new ArgumentNullException("second");
  15784. if (resultSelector == null)
  15785. throw new ArgumentNullException("resultSelector");
  15786. return first.Provider.CreateQuery<TResult>(
  15787. Expression.Call(
  15788. null,
  15789. #if CRIPPLED_REFLECTION
  15790. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TResult>(default(IQbservable<TSource1>), default(IEnumerable<TSource2>), default(Expression<Func<TSource1, TSource2, TResult>>))),
  15791. #else
  15792. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TResult)),
  15793. #endif
  15794. first.Expression,
  15795. GetSourceExpression(second),
  15796. resultSelector
  15797. )
  15798. );
  15799. }
  15800. /// <summary>
  15801. /// 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.
  15802. /// </summary>
  15803. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  15804. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  15805. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  15806. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  15807. /// <param name="source1">First observable source.</param>
  15808. /// <param name="source2">Second observable source.</param>
  15809. /// <param name="source3">Third observable source.</param>
  15810. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  15811. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  15812. /// <exception cref="T:System.ArgumentNullException">
  15813. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="resultSelector" /> is null.</exception>
  15814. 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)
  15815. {
  15816. if (source1 == null)
  15817. throw new ArgumentNullException("source1");
  15818. if (source2 == null)
  15819. throw new ArgumentNullException("source2");
  15820. if (source3 == null)
  15821. throw new ArgumentNullException("source3");
  15822. if (resultSelector == null)
  15823. throw new ArgumentNullException("resultSelector");
  15824. return source1.Provider.CreateQuery<TResult>(
  15825. Expression.Call(
  15826. null,
  15827. #if CRIPPLED_REFLECTION
  15828. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TSource3, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(Expression<Func<TSource1, TSource2, TSource3, TResult>>))),
  15829. #else
  15830. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TResult)),
  15831. #endif
  15832. source1.Expression,
  15833. GetSourceExpression(source2),
  15834. GetSourceExpression(source3),
  15835. resultSelector
  15836. )
  15837. );
  15838. }
  15839. /// <summary>
  15840. /// 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.
  15841. /// </summary>
  15842. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  15843. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  15844. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  15845. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  15846. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  15847. /// <param name="source1">First observable source.</param>
  15848. /// <param name="source2">Second observable source.</param>
  15849. /// <param name="source3">Third observable source.</param>
  15850. /// <param name="source4">Fourth observable source.</param>
  15851. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  15852. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  15853. /// <exception cref="T:System.ArgumentNullException">
  15854. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="resultSelector" /> is null.</exception>
  15855. 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)
  15856. {
  15857. if (source1 == null)
  15858. throw new ArgumentNullException("source1");
  15859. if (source2 == null)
  15860. throw new ArgumentNullException("source2");
  15861. if (source3 == null)
  15862. throw new ArgumentNullException("source3");
  15863. if (source4 == null)
  15864. throw new ArgumentNullException("source4");
  15865. if (resultSelector == null)
  15866. throw new ArgumentNullException("resultSelector");
  15867. return source1.Provider.CreateQuery<TResult>(
  15868. Expression.Call(
  15869. null,
  15870. #if CRIPPLED_REFLECTION
  15871. 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>>))),
  15872. #else
  15873. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TResult)),
  15874. #endif
  15875. source1.Expression,
  15876. GetSourceExpression(source2),
  15877. GetSourceExpression(source3),
  15878. GetSourceExpression(source4),
  15879. resultSelector
  15880. )
  15881. );
  15882. }
  15883. #if !NO_LARGEARITY
  15884. /// <summary>
  15885. /// 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.
  15886. /// </summary>
  15887. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  15888. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  15889. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  15890. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  15891. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  15892. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  15893. /// <param name="source1">First observable source.</param>
  15894. /// <param name="source2">Second observable source.</param>
  15895. /// <param name="source3">Third observable source.</param>
  15896. /// <param name="source4">Fourth observable source.</param>
  15897. /// <param name="source5">Fifth observable source.</param>
  15898. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  15899. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  15900. /// <exception cref="T:System.ArgumentNullException">
  15901. /// <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>
  15902. 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)
  15903. {
  15904. if (source1 == null)
  15905. throw new ArgumentNullException("source1");
  15906. if (source2 == null)
  15907. throw new ArgumentNullException("source2");
  15908. if (source3 == null)
  15909. throw new ArgumentNullException("source3");
  15910. if (source4 == null)
  15911. throw new ArgumentNullException("source4");
  15912. if (source5 == null)
  15913. throw new ArgumentNullException("source5");
  15914. if (resultSelector == null)
  15915. throw new ArgumentNullException("resultSelector");
  15916. return source1.Provider.CreateQuery<TResult>(
  15917. Expression.Call(
  15918. null,
  15919. #if CRIPPLED_REFLECTION
  15920. 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>>))),
  15921. #else
  15922. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TResult)),
  15923. #endif
  15924. source1.Expression,
  15925. GetSourceExpression(source2),
  15926. GetSourceExpression(source3),
  15927. GetSourceExpression(source4),
  15928. GetSourceExpression(source5),
  15929. resultSelector
  15930. )
  15931. );
  15932. }
  15933. #endif
  15934. #if !NO_LARGEARITY
  15935. /// <summary>
  15936. /// 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.
  15937. /// </summary>
  15938. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  15939. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  15940. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  15941. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  15942. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  15943. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  15944. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  15945. /// <param name="source1">First observable source.</param>
  15946. /// <param name="source2">Second observable source.</param>
  15947. /// <param name="source3">Third observable source.</param>
  15948. /// <param name="source4">Fourth observable source.</param>
  15949. /// <param name="source5">Fifth observable source.</param>
  15950. /// <param name="source6">Sixth observable source.</param>
  15951. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  15952. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  15953. /// <exception cref="T:System.ArgumentNullException">
  15954. /// <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>
  15955. 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)
  15956. {
  15957. if (source1 == null)
  15958. throw new ArgumentNullException("source1");
  15959. if (source2 == null)
  15960. throw new ArgumentNullException("source2");
  15961. if (source3 == null)
  15962. throw new ArgumentNullException("source3");
  15963. if (source4 == null)
  15964. throw new ArgumentNullException("source4");
  15965. if (source5 == null)
  15966. throw new ArgumentNullException("source5");
  15967. if (source6 == null)
  15968. throw new ArgumentNullException("source6");
  15969. if (resultSelector == null)
  15970. throw new ArgumentNullException("resultSelector");
  15971. return source1.Provider.CreateQuery<TResult>(
  15972. Expression.Call(
  15973. null,
  15974. #if CRIPPLED_REFLECTION
  15975. 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>>))),
  15976. #else
  15977. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TResult)),
  15978. #endif
  15979. source1.Expression,
  15980. GetSourceExpression(source2),
  15981. GetSourceExpression(source3),
  15982. GetSourceExpression(source4),
  15983. GetSourceExpression(source5),
  15984. GetSourceExpression(source6),
  15985. resultSelector
  15986. )
  15987. );
  15988. }
  15989. #endif
  15990. #if !NO_LARGEARITY
  15991. /// <summary>
  15992. /// 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.
  15993. /// </summary>
  15994. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  15995. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  15996. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  15997. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  15998. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  15999. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16000. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16001. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16002. /// <param name="source1">First observable source.</param>
  16003. /// <param name="source2">Second observable source.</param>
  16004. /// <param name="source3">Third observable source.</param>
  16005. /// <param name="source4">Fourth observable source.</param>
  16006. /// <param name="source5">Fifth observable source.</param>
  16007. /// <param name="source6">Sixth observable source.</param>
  16008. /// <param name="source7">Seventh observable source.</param>
  16009. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16010. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16011. /// <exception cref="T:System.ArgumentNullException">
  16012. /// <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>
  16013. 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)
  16014. {
  16015. if (source1 == null)
  16016. throw new ArgumentNullException("source1");
  16017. if (source2 == null)
  16018. throw new ArgumentNullException("source2");
  16019. if (source3 == null)
  16020. throw new ArgumentNullException("source3");
  16021. if (source4 == null)
  16022. throw new ArgumentNullException("source4");
  16023. if (source5 == null)
  16024. throw new ArgumentNullException("source5");
  16025. if (source6 == null)
  16026. throw new ArgumentNullException("source6");
  16027. if (source7 == null)
  16028. throw new ArgumentNullException("source7");
  16029. if (resultSelector == null)
  16030. throw new ArgumentNullException("resultSelector");
  16031. return source1.Provider.CreateQuery<TResult>(
  16032. Expression.Call(
  16033. null,
  16034. #if CRIPPLED_REFLECTION
  16035. 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>>))),
  16036. #else
  16037. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TResult)),
  16038. #endif
  16039. source1.Expression,
  16040. GetSourceExpression(source2),
  16041. GetSourceExpression(source3),
  16042. GetSourceExpression(source4),
  16043. GetSourceExpression(source5),
  16044. GetSourceExpression(source6),
  16045. GetSourceExpression(source7),
  16046. resultSelector
  16047. )
  16048. );
  16049. }
  16050. #endif
  16051. #if !NO_LARGEARITY
  16052. /// <summary>
  16053. /// 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.
  16054. /// </summary>
  16055. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16056. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16057. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16058. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16059. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16060. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16061. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16062. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  16063. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16064. /// <param name="source1">First observable source.</param>
  16065. /// <param name="source2">Second observable source.</param>
  16066. /// <param name="source3">Third observable source.</param>
  16067. /// <param name="source4">Fourth observable source.</param>
  16068. /// <param name="source5">Fifth observable source.</param>
  16069. /// <param name="source6">Sixth observable source.</param>
  16070. /// <param name="source7">Seventh observable source.</param>
  16071. /// <param name="source8">Eighth observable source.</param>
  16072. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16073. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16074. /// <exception cref="T:System.ArgumentNullException">
  16075. /// <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>
  16076. 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)
  16077. {
  16078. if (source1 == null)
  16079. throw new ArgumentNullException("source1");
  16080. if (source2 == null)
  16081. throw new ArgumentNullException("source2");
  16082. if (source3 == null)
  16083. throw new ArgumentNullException("source3");
  16084. if (source4 == null)
  16085. throw new ArgumentNullException("source4");
  16086. if (source5 == null)
  16087. throw new ArgumentNullException("source5");
  16088. if (source6 == null)
  16089. throw new ArgumentNullException("source6");
  16090. if (source7 == null)
  16091. throw new ArgumentNullException("source7");
  16092. if (source8 == null)
  16093. throw new ArgumentNullException("source8");
  16094. if (resultSelector == null)
  16095. throw new ArgumentNullException("resultSelector");
  16096. return source1.Provider.CreateQuery<TResult>(
  16097. Expression.Call(
  16098. null,
  16099. #if CRIPPLED_REFLECTION
  16100. 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>>))),
  16101. #else
  16102. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TResult)),
  16103. #endif
  16104. source1.Expression,
  16105. GetSourceExpression(source2),
  16106. GetSourceExpression(source3),
  16107. GetSourceExpression(source4),
  16108. GetSourceExpression(source5),
  16109. GetSourceExpression(source6),
  16110. GetSourceExpression(source7),
  16111. GetSourceExpression(source8),
  16112. resultSelector
  16113. )
  16114. );
  16115. }
  16116. #endif
  16117. #if !NO_LARGEARITY
  16118. /// <summary>
  16119. /// 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.
  16120. /// </summary>
  16121. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16122. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16123. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16124. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16125. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16126. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16127. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16128. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  16129. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  16130. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16131. /// <param name="source1">First observable source.</param>
  16132. /// <param name="source2">Second observable source.</param>
  16133. /// <param name="source3">Third observable source.</param>
  16134. /// <param name="source4">Fourth observable source.</param>
  16135. /// <param name="source5">Fifth observable source.</param>
  16136. /// <param name="source6">Sixth observable source.</param>
  16137. /// <param name="source7">Seventh observable source.</param>
  16138. /// <param name="source8">Eighth observable source.</param>
  16139. /// <param name="source9">Ninth observable source.</param>
  16140. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16141. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16142. /// <exception cref="T:System.ArgumentNullException">
  16143. /// <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>
  16144. 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)
  16145. {
  16146. if (source1 == null)
  16147. throw new ArgumentNullException("source1");
  16148. if (source2 == null)
  16149. throw new ArgumentNullException("source2");
  16150. if (source3 == null)
  16151. throw new ArgumentNullException("source3");
  16152. if (source4 == null)
  16153. throw new ArgumentNullException("source4");
  16154. if (source5 == null)
  16155. throw new ArgumentNullException("source5");
  16156. if (source6 == null)
  16157. throw new ArgumentNullException("source6");
  16158. if (source7 == null)
  16159. throw new ArgumentNullException("source7");
  16160. if (source8 == null)
  16161. throw new ArgumentNullException("source8");
  16162. if (source9 == null)
  16163. throw new ArgumentNullException("source9");
  16164. if (resultSelector == null)
  16165. throw new ArgumentNullException("resultSelector");
  16166. return source1.Provider.CreateQuery<TResult>(
  16167. Expression.Call(
  16168. null,
  16169. #if CRIPPLED_REFLECTION
  16170. 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>>))),
  16171. #else
  16172. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TSource9), typeof(TResult)),
  16173. #endif
  16174. source1.Expression,
  16175. GetSourceExpression(source2),
  16176. GetSourceExpression(source3),
  16177. GetSourceExpression(source4),
  16178. GetSourceExpression(source5),
  16179. GetSourceExpression(source6),
  16180. GetSourceExpression(source7),
  16181. GetSourceExpression(source8),
  16182. GetSourceExpression(source9),
  16183. resultSelector
  16184. )
  16185. );
  16186. }
  16187. #endif
  16188. #if !NO_LARGEARITY
  16189. /// <summary>
  16190. /// 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.
  16191. /// </summary>
  16192. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16193. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16194. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16195. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16196. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16197. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16198. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16199. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  16200. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  16201. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  16202. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16203. /// <param name="source1">First observable source.</param>
  16204. /// <param name="source2">Second observable source.</param>
  16205. /// <param name="source3">Third observable source.</param>
  16206. /// <param name="source4">Fourth observable source.</param>
  16207. /// <param name="source5">Fifth observable source.</param>
  16208. /// <param name="source6">Sixth observable source.</param>
  16209. /// <param name="source7">Seventh observable source.</param>
  16210. /// <param name="source8">Eighth observable source.</param>
  16211. /// <param name="source9">Ninth observable source.</param>
  16212. /// <param name="source10">Tenth observable source.</param>
  16213. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16214. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16215. /// <exception cref="T:System.ArgumentNullException">
  16216. /// <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>
  16217. 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)
  16218. {
  16219. if (source1 == null)
  16220. throw new ArgumentNullException("source1");
  16221. if (source2 == null)
  16222. throw new ArgumentNullException("source2");
  16223. if (source3 == null)
  16224. throw new ArgumentNullException("source3");
  16225. if (source4 == null)
  16226. throw new ArgumentNullException("source4");
  16227. if (source5 == null)
  16228. throw new ArgumentNullException("source5");
  16229. if (source6 == null)
  16230. throw new ArgumentNullException("source6");
  16231. if (source7 == null)
  16232. throw new ArgumentNullException("source7");
  16233. if (source8 == null)
  16234. throw new ArgumentNullException("source8");
  16235. if (source9 == null)
  16236. throw new ArgumentNullException("source9");
  16237. if (source10 == null)
  16238. throw new ArgumentNullException("source10");
  16239. if (resultSelector == null)
  16240. throw new ArgumentNullException("resultSelector");
  16241. return source1.Provider.CreateQuery<TResult>(
  16242. Expression.Call(
  16243. null,
  16244. #if CRIPPLED_REFLECTION
  16245. 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>>))),
  16246. #else
  16247. ((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)),
  16248. #endif
  16249. source1.Expression,
  16250. GetSourceExpression(source2),
  16251. GetSourceExpression(source3),
  16252. GetSourceExpression(source4),
  16253. GetSourceExpression(source5),
  16254. GetSourceExpression(source6),
  16255. GetSourceExpression(source7),
  16256. GetSourceExpression(source8),
  16257. GetSourceExpression(source9),
  16258. GetSourceExpression(source10),
  16259. resultSelector
  16260. )
  16261. );
  16262. }
  16263. #endif
  16264. #if !NO_LARGEARITY
  16265. /// <summary>
  16266. /// 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.
  16267. /// </summary>
  16268. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16269. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16270. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16271. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16272. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16273. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16274. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16275. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  16276. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  16277. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  16278. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  16279. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16280. /// <param name="source1">First observable source.</param>
  16281. /// <param name="source2">Second observable source.</param>
  16282. /// <param name="source3">Third observable source.</param>
  16283. /// <param name="source4">Fourth observable source.</param>
  16284. /// <param name="source5">Fifth observable source.</param>
  16285. /// <param name="source6">Sixth observable source.</param>
  16286. /// <param name="source7">Seventh observable source.</param>
  16287. /// <param name="source8">Eighth observable source.</param>
  16288. /// <param name="source9">Ninth observable source.</param>
  16289. /// <param name="source10">Tenth observable source.</param>
  16290. /// <param name="source11">Eleventh observable source.</param>
  16291. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16292. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16293. /// <exception cref="T:System.ArgumentNullException">
  16294. /// <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>
  16295. 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)
  16296. {
  16297. if (source1 == null)
  16298. throw new ArgumentNullException("source1");
  16299. if (source2 == null)
  16300. throw new ArgumentNullException("source2");
  16301. if (source3 == null)
  16302. throw new ArgumentNullException("source3");
  16303. if (source4 == null)
  16304. throw new ArgumentNullException("source4");
  16305. if (source5 == null)
  16306. throw new ArgumentNullException("source5");
  16307. if (source6 == null)
  16308. throw new ArgumentNullException("source6");
  16309. if (source7 == null)
  16310. throw new ArgumentNullException("source7");
  16311. if (source8 == null)
  16312. throw new ArgumentNullException("source8");
  16313. if (source9 == null)
  16314. throw new ArgumentNullException("source9");
  16315. if (source10 == null)
  16316. throw new ArgumentNullException("source10");
  16317. if (source11 == null)
  16318. throw new ArgumentNullException("source11");
  16319. if (resultSelector == null)
  16320. throw new ArgumentNullException("resultSelector");
  16321. return source1.Provider.CreateQuery<TResult>(
  16322. Expression.Call(
  16323. null,
  16324. #if CRIPPLED_REFLECTION
  16325. 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>>))),
  16326. #else
  16327. ((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)),
  16328. #endif
  16329. source1.Expression,
  16330. GetSourceExpression(source2),
  16331. GetSourceExpression(source3),
  16332. GetSourceExpression(source4),
  16333. GetSourceExpression(source5),
  16334. GetSourceExpression(source6),
  16335. GetSourceExpression(source7),
  16336. GetSourceExpression(source8),
  16337. GetSourceExpression(source9),
  16338. GetSourceExpression(source10),
  16339. GetSourceExpression(source11),
  16340. resultSelector
  16341. )
  16342. );
  16343. }
  16344. #endif
  16345. #if !NO_LARGEARITY
  16346. /// <summary>
  16347. /// 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.
  16348. /// </summary>
  16349. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16350. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16351. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16352. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16353. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16354. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16355. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16356. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  16357. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  16358. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  16359. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  16360. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  16361. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16362. /// <param name="source1">First observable source.</param>
  16363. /// <param name="source2">Second observable source.</param>
  16364. /// <param name="source3">Third observable source.</param>
  16365. /// <param name="source4">Fourth observable source.</param>
  16366. /// <param name="source5">Fifth observable source.</param>
  16367. /// <param name="source6">Sixth observable source.</param>
  16368. /// <param name="source7">Seventh observable source.</param>
  16369. /// <param name="source8">Eighth observable source.</param>
  16370. /// <param name="source9">Ninth observable source.</param>
  16371. /// <param name="source10">Tenth observable source.</param>
  16372. /// <param name="source11">Eleventh observable source.</param>
  16373. /// <param name="source12">Twelfth observable source.</param>
  16374. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16375. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16376. /// <exception cref="T:System.ArgumentNullException">
  16377. /// <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>
  16378. 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)
  16379. {
  16380. if (source1 == null)
  16381. throw new ArgumentNullException("source1");
  16382. if (source2 == null)
  16383. throw new ArgumentNullException("source2");
  16384. if (source3 == null)
  16385. throw new ArgumentNullException("source3");
  16386. if (source4 == null)
  16387. throw new ArgumentNullException("source4");
  16388. if (source5 == null)
  16389. throw new ArgumentNullException("source5");
  16390. if (source6 == null)
  16391. throw new ArgumentNullException("source6");
  16392. if (source7 == null)
  16393. throw new ArgumentNullException("source7");
  16394. if (source8 == null)
  16395. throw new ArgumentNullException("source8");
  16396. if (source9 == null)
  16397. throw new ArgumentNullException("source9");
  16398. if (source10 == null)
  16399. throw new ArgumentNullException("source10");
  16400. if (source11 == null)
  16401. throw new ArgumentNullException("source11");
  16402. if (source12 == null)
  16403. throw new ArgumentNullException("source12");
  16404. if (resultSelector == null)
  16405. throw new ArgumentNullException("resultSelector");
  16406. return source1.Provider.CreateQuery<TResult>(
  16407. Expression.Call(
  16408. null,
  16409. #if CRIPPLED_REFLECTION
  16410. 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>>))),
  16411. #else
  16412. ((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)),
  16413. #endif
  16414. source1.Expression,
  16415. GetSourceExpression(source2),
  16416. GetSourceExpression(source3),
  16417. GetSourceExpression(source4),
  16418. GetSourceExpression(source5),
  16419. GetSourceExpression(source6),
  16420. GetSourceExpression(source7),
  16421. GetSourceExpression(source8),
  16422. GetSourceExpression(source9),
  16423. GetSourceExpression(source10),
  16424. GetSourceExpression(source11),
  16425. GetSourceExpression(source12),
  16426. resultSelector
  16427. )
  16428. );
  16429. }
  16430. #endif
  16431. #if !NO_LARGEARITY
  16432. /// <summary>
  16433. /// 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.
  16434. /// </summary>
  16435. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16436. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16437. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16438. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16439. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16440. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16441. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16442. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  16443. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  16444. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  16445. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  16446. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  16447. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  16448. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16449. /// <param name="source1">First observable source.</param>
  16450. /// <param name="source2">Second observable source.</param>
  16451. /// <param name="source3">Third observable source.</param>
  16452. /// <param name="source4">Fourth observable source.</param>
  16453. /// <param name="source5">Fifth observable source.</param>
  16454. /// <param name="source6">Sixth observable source.</param>
  16455. /// <param name="source7">Seventh observable source.</param>
  16456. /// <param name="source8">Eighth observable source.</param>
  16457. /// <param name="source9">Ninth observable source.</param>
  16458. /// <param name="source10">Tenth observable source.</param>
  16459. /// <param name="source11">Eleventh observable source.</param>
  16460. /// <param name="source12">Twelfth observable source.</param>
  16461. /// <param name="source13">Thirteenth observable source.</param>
  16462. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16463. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16464. /// <exception cref="T:System.ArgumentNullException">
  16465. /// <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>
  16466. 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)
  16467. {
  16468. if (source1 == null)
  16469. throw new ArgumentNullException("source1");
  16470. if (source2 == null)
  16471. throw new ArgumentNullException("source2");
  16472. if (source3 == null)
  16473. throw new ArgumentNullException("source3");
  16474. if (source4 == null)
  16475. throw new ArgumentNullException("source4");
  16476. if (source5 == null)
  16477. throw new ArgumentNullException("source5");
  16478. if (source6 == null)
  16479. throw new ArgumentNullException("source6");
  16480. if (source7 == null)
  16481. throw new ArgumentNullException("source7");
  16482. if (source8 == null)
  16483. throw new ArgumentNullException("source8");
  16484. if (source9 == null)
  16485. throw new ArgumentNullException("source9");
  16486. if (source10 == null)
  16487. throw new ArgumentNullException("source10");
  16488. if (source11 == null)
  16489. throw new ArgumentNullException("source11");
  16490. if (source12 == null)
  16491. throw new ArgumentNullException("source12");
  16492. if (source13 == null)
  16493. throw new ArgumentNullException("source13");
  16494. if (resultSelector == null)
  16495. throw new ArgumentNullException("resultSelector");
  16496. return source1.Provider.CreateQuery<TResult>(
  16497. Expression.Call(
  16498. null,
  16499. #if CRIPPLED_REFLECTION
  16500. 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>>))),
  16501. #else
  16502. ((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)),
  16503. #endif
  16504. source1.Expression,
  16505. GetSourceExpression(source2),
  16506. GetSourceExpression(source3),
  16507. GetSourceExpression(source4),
  16508. GetSourceExpression(source5),
  16509. GetSourceExpression(source6),
  16510. GetSourceExpression(source7),
  16511. GetSourceExpression(source8),
  16512. GetSourceExpression(source9),
  16513. GetSourceExpression(source10),
  16514. GetSourceExpression(source11),
  16515. GetSourceExpression(source12),
  16516. GetSourceExpression(source13),
  16517. resultSelector
  16518. )
  16519. );
  16520. }
  16521. #endif
  16522. #if !NO_LARGEARITY
  16523. /// <summary>
  16524. /// 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.
  16525. /// </summary>
  16526. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16527. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16528. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16529. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16530. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16531. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16532. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16533. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  16534. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  16535. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  16536. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  16537. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  16538. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  16539. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  16540. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16541. /// <param name="source1">First observable source.</param>
  16542. /// <param name="source2">Second observable source.</param>
  16543. /// <param name="source3">Third observable source.</param>
  16544. /// <param name="source4">Fourth observable source.</param>
  16545. /// <param name="source5">Fifth observable source.</param>
  16546. /// <param name="source6">Sixth observable source.</param>
  16547. /// <param name="source7">Seventh observable source.</param>
  16548. /// <param name="source8">Eighth observable source.</param>
  16549. /// <param name="source9">Ninth observable source.</param>
  16550. /// <param name="source10">Tenth observable source.</param>
  16551. /// <param name="source11">Eleventh observable source.</param>
  16552. /// <param name="source12">Twelfth observable source.</param>
  16553. /// <param name="source13">Thirteenth observable source.</param>
  16554. /// <param name="source14">Fourteenth observable source.</param>
  16555. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16556. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16557. /// <exception cref="T:System.ArgumentNullException">
  16558. /// <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>
  16559. 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)
  16560. {
  16561. if (source1 == null)
  16562. throw new ArgumentNullException("source1");
  16563. if (source2 == null)
  16564. throw new ArgumentNullException("source2");
  16565. if (source3 == null)
  16566. throw new ArgumentNullException("source3");
  16567. if (source4 == null)
  16568. throw new ArgumentNullException("source4");
  16569. if (source5 == null)
  16570. throw new ArgumentNullException("source5");
  16571. if (source6 == null)
  16572. throw new ArgumentNullException("source6");
  16573. if (source7 == null)
  16574. throw new ArgumentNullException("source7");
  16575. if (source8 == null)
  16576. throw new ArgumentNullException("source8");
  16577. if (source9 == null)
  16578. throw new ArgumentNullException("source9");
  16579. if (source10 == null)
  16580. throw new ArgumentNullException("source10");
  16581. if (source11 == null)
  16582. throw new ArgumentNullException("source11");
  16583. if (source12 == null)
  16584. throw new ArgumentNullException("source12");
  16585. if (source13 == null)
  16586. throw new ArgumentNullException("source13");
  16587. if (source14 == null)
  16588. throw new ArgumentNullException("source14");
  16589. if (resultSelector == null)
  16590. throw new ArgumentNullException("resultSelector");
  16591. return source1.Provider.CreateQuery<TResult>(
  16592. Expression.Call(
  16593. null,
  16594. #if CRIPPLED_REFLECTION
  16595. 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>>))),
  16596. #else
  16597. ((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)),
  16598. #endif
  16599. source1.Expression,
  16600. GetSourceExpression(source2),
  16601. GetSourceExpression(source3),
  16602. GetSourceExpression(source4),
  16603. GetSourceExpression(source5),
  16604. GetSourceExpression(source6),
  16605. GetSourceExpression(source7),
  16606. GetSourceExpression(source8),
  16607. GetSourceExpression(source9),
  16608. GetSourceExpression(source10),
  16609. GetSourceExpression(source11),
  16610. GetSourceExpression(source12),
  16611. GetSourceExpression(source13),
  16612. GetSourceExpression(source14),
  16613. resultSelector
  16614. )
  16615. );
  16616. }
  16617. #endif
  16618. #if !NO_LARGEARITY
  16619. /// <summary>
  16620. /// 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.
  16621. /// </summary>
  16622. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16623. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16624. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16625. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16626. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16627. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16628. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16629. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  16630. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  16631. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  16632. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  16633. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  16634. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  16635. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  16636. /// <typeparam name="TSource15">The type of the elements in the fifteenth source sequence.</typeparam>
  16637. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16638. /// <param name="source1">First observable source.</param>
  16639. /// <param name="source2">Second observable source.</param>
  16640. /// <param name="source3">Third observable source.</param>
  16641. /// <param name="source4">Fourth observable source.</param>
  16642. /// <param name="source5">Fifth observable source.</param>
  16643. /// <param name="source6">Sixth observable source.</param>
  16644. /// <param name="source7">Seventh observable source.</param>
  16645. /// <param name="source8">Eighth observable source.</param>
  16646. /// <param name="source9">Ninth observable source.</param>
  16647. /// <param name="source10">Tenth observable source.</param>
  16648. /// <param name="source11">Eleventh observable source.</param>
  16649. /// <param name="source12">Twelfth observable source.</param>
  16650. /// <param name="source13">Thirteenth observable source.</param>
  16651. /// <param name="source14">Fourteenth observable source.</param>
  16652. /// <param name="source15">Fifteenth observable source.</param>
  16653. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16654. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16655. /// <exception cref="T:System.ArgumentNullException">
  16656. /// <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>
  16657. 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)
  16658. {
  16659. if (source1 == null)
  16660. throw new ArgumentNullException("source1");
  16661. if (source2 == null)
  16662. throw new ArgumentNullException("source2");
  16663. if (source3 == null)
  16664. throw new ArgumentNullException("source3");
  16665. if (source4 == null)
  16666. throw new ArgumentNullException("source4");
  16667. if (source5 == null)
  16668. throw new ArgumentNullException("source5");
  16669. if (source6 == null)
  16670. throw new ArgumentNullException("source6");
  16671. if (source7 == null)
  16672. throw new ArgumentNullException("source7");
  16673. if (source8 == null)
  16674. throw new ArgumentNullException("source8");
  16675. if (source9 == null)
  16676. throw new ArgumentNullException("source9");
  16677. if (source10 == null)
  16678. throw new ArgumentNullException("source10");
  16679. if (source11 == null)
  16680. throw new ArgumentNullException("source11");
  16681. if (source12 == null)
  16682. throw new ArgumentNullException("source12");
  16683. if (source13 == null)
  16684. throw new ArgumentNullException("source13");
  16685. if (source14 == null)
  16686. throw new ArgumentNullException("source14");
  16687. if (source15 == null)
  16688. throw new ArgumentNullException("source15");
  16689. if (resultSelector == null)
  16690. throw new ArgumentNullException("resultSelector");
  16691. return source1.Provider.CreateQuery<TResult>(
  16692. Expression.Call(
  16693. null,
  16694. #if CRIPPLED_REFLECTION
  16695. 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>>))),
  16696. #else
  16697. ((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)),
  16698. #endif
  16699. source1.Expression,
  16700. GetSourceExpression(source2),
  16701. GetSourceExpression(source3),
  16702. GetSourceExpression(source4),
  16703. GetSourceExpression(source5),
  16704. GetSourceExpression(source6),
  16705. GetSourceExpression(source7),
  16706. GetSourceExpression(source8),
  16707. GetSourceExpression(source9),
  16708. GetSourceExpression(source10),
  16709. GetSourceExpression(source11),
  16710. GetSourceExpression(source12),
  16711. GetSourceExpression(source13),
  16712. GetSourceExpression(source14),
  16713. GetSourceExpression(source15),
  16714. resultSelector
  16715. )
  16716. );
  16717. }
  16718. #endif
  16719. #if !NO_LARGEARITY
  16720. /// <summary>
  16721. /// 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.
  16722. /// </summary>
  16723. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16724. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16725. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16726. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16727. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16728. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16729. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16730. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  16731. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  16732. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  16733. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  16734. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  16735. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  16736. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  16737. /// <typeparam name="TSource15">The type of the elements in the fifteenth source sequence.</typeparam>
  16738. /// <typeparam name="TSource16">The type of the elements in the sixteenth source sequence.</typeparam>
  16739. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16740. /// <param name="source1">First observable source.</param>
  16741. /// <param name="source2">Second observable source.</param>
  16742. /// <param name="source3">Third observable source.</param>
  16743. /// <param name="source4">Fourth observable source.</param>
  16744. /// <param name="source5">Fifth observable source.</param>
  16745. /// <param name="source6">Sixth observable source.</param>
  16746. /// <param name="source7">Seventh observable source.</param>
  16747. /// <param name="source8">Eighth observable source.</param>
  16748. /// <param name="source9">Ninth observable source.</param>
  16749. /// <param name="source10">Tenth observable source.</param>
  16750. /// <param name="source11">Eleventh observable source.</param>
  16751. /// <param name="source12">Twelfth observable source.</param>
  16752. /// <param name="source13">Thirteenth observable source.</param>
  16753. /// <param name="source14">Fourteenth observable source.</param>
  16754. /// <param name="source15">Fifteenth observable source.</param>
  16755. /// <param name="source16">Sixteenth observable source.</param>
  16756. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16757. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16758. /// <exception cref="T:System.ArgumentNullException">
  16759. /// <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>
  16760. 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)
  16761. {
  16762. if (source1 == null)
  16763. throw new ArgumentNullException("source1");
  16764. if (source2 == null)
  16765. throw new ArgumentNullException("source2");
  16766. if (source3 == null)
  16767. throw new ArgumentNullException("source3");
  16768. if (source4 == null)
  16769. throw new ArgumentNullException("source4");
  16770. if (source5 == null)
  16771. throw new ArgumentNullException("source5");
  16772. if (source6 == null)
  16773. throw new ArgumentNullException("source6");
  16774. if (source7 == null)
  16775. throw new ArgumentNullException("source7");
  16776. if (source8 == null)
  16777. throw new ArgumentNullException("source8");
  16778. if (source9 == null)
  16779. throw new ArgumentNullException("source9");
  16780. if (source10 == null)
  16781. throw new ArgumentNullException("source10");
  16782. if (source11 == null)
  16783. throw new ArgumentNullException("source11");
  16784. if (source12 == null)
  16785. throw new ArgumentNullException("source12");
  16786. if (source13 == null)
  16787. throw new ArgumentNullException("source13");
  16788. if (source14 == null)
  16789. throw new ArgumentNullException("source14");
  16790. if (source15 == null)
  16791. throw new ArgumentNullException("source15");
  16792. if (source16 == null)
  16793. throw new ArgumentNullException("source16");
  16794. if (resultSelector == null)
  16795. throw new ArgumentNullException("resultSelector");
  16796. return source1.Provider.CreateQuery<TResult>(
  16797. Expression.Call(
  16798. null,
  16799. #if CRIPPLED_REFLECTION
  16800. 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>>))),
  16801. #else
  16802. ((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)),
  16803. #endif
  16804. source1.Expression,
  16805. GetSourceExpression(source2),
  16806. GetSourceExpression(source3),
  16807. GetSourceExpression(source4),
  16808. GetSourceExpression(source5),
  16809. GetSourceExpression(source6),
  16810. GetSourceExpression(source7),
  16811. GetSourceExpression(source8),
  16812. GetSourceExpression(source9),
  16813. GetSourceExpression(source10),
  16814. GetSourceExpression(source11),
  16815. GetSourceExpression(source12),
  16816. GetSourceExpression(source13),
  16817. GetSourceExpression(source14),
  16818. GetSourceExpression(source15),
  16819. GetSourceExpression(source16),
  16820. resultSelector
  16821. )
  16822. );
  16823. }
  16824. #endif
  16825. /// <summary>
  16826. /// 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.
  16827. /// </summary>
  16828. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  16829. /// <param name="action">Action to convert to an asynchronous action.</param>
  16830. /// <returns>Asynchronous action.</returns>
  16831. /// <exception cref="T:System.ArgumentNullException">
  16832. /// <paramref name="action" /> is null.</exception>
  16833. public static Func<IQbservable<Unit>> ToAsync(this IQbservableProvider provider, Expression<Action> action)
  16834. {
  16835. if (provider == null)
  16836. throw new ArgumentNullException("provider");
  16837. if (action == null)
  16838. throw new ArgumentNullException("action");
  16839. #if CRIPPLED_REFLECTION
  16840. var m = InfoOf(() => Qbservable.ToAsync(default(IQbservableProvider), default(Expression<Action>)));
  16841. #else
  16842. var m = (MethodInfo)MethodInfo.GetCurrentMethod();
  16843. #endif
  16844. return () => provider.CreateQuery<Unit>(
  16845. Expression.Invoke(
  16846. Expression.Call(
  16847. null,
  16848. m,
  16849. Expression.Constant(provider, typeof(IQbservableProvider)),
  16850. action
  16851. )
  16852. )
  16853. );
  16854. }
  16855. /// <summary>
  16856. /// 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.
  16857. /// </summary>
  16858. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  16859. /// <param name="action">Action to convert to an asynchronous action.</param>
  16860. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  16861. /// <returns>Asynchronous action.</returns>
  16862. /// <exception cref="T:System.ArgumentNullException">
  16863. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  16864. public static Func<IQbservable<Unit>> ToAsync(this IQbservableProvider provider, Expression<Action> action, IScheduler scheduler)
  16865. {
  16866. if (provider == null)
  16867. throw new ArgumentNullException("provider");
  16868. if (action == null)
  16869. throw new ArgumentNullException("action");
  16870. if (scheduler == null)
  16871. throw new ArgumentNullException("scheduler");
  16872. #if CRIPPLED_REFLECTION
  16873. var m = InfoOf(() => Qbservable.ToAsync(default(IQbservableProvider), default(Expression<Action>), default(IScheduler)));
  16874. #else
  16875. var m = (MethodInfo)MethodInfo.GetCurrentMethod();
  16876. #endif
  16877. return () => provider.CreateQuery<Unit>(
  16878. Expression.Invoke(
  16879. Expression.Call(
  16880. null,
  16881. m,
  16882. Expression.Constant(provider, typeof(IQbservableProvider)),
  16883. action,
  16884. Expression.Constant(scheduler, typeof(IScheduler))
  16885. )
  16886. )
  16887. );
  16888. }
  16889. /// <summary>
  16890. /// 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.
  16891. /// </summary>
  16892. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  16893. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  16894. /// <param name="action">Action to convert to an asynchronous action.</param>
  16895. /// <returns>Asynchronous action.</returns>
  16896. /// <exception cref="T:System.ArgumentNullException">
  16897. /// <paramref name="action" /> is null.</exception>
  16898. public static Func<TArg1, IQbservable<Unit>> ToAsync<TArg1>(this IQbservableProvider provider, Expression<Action<TArg1>> action)
  16899. {
  16900. if (provider == null)
  16901. throw new ArgumentNullException("provider");
  16902. if (action == null)
  16903. throw new ArgumentNullException("action");
  16904. #if CRIPPLED_REFLECTION
  16905. var m = InfoOf(() => Qbservable.ToAsync<TArg1>(default(IQbservableProvider), default(Expression<Action<TArg1>>)));
  16906. #else
  16907. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1));
  16908. #endif
  16909. return (t1) => provider.CreateQuery<Unit>(
  16910. Expression.Invoke(
  16911. Expression.Call(
  16912. null,
  16913. m,
  16914. Expression.Constant(provider, typeof(IQbservableProvider)),
  16915. action
  16916. ),
  16917. Expression.Constant(t1, typeof(TArg1))
  16918. )
  16919. );
  16920. }
  16921. /// <summary>
  16922. /// 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.
  16923. /// </summary>
  16924. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  16925. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  16926. /// <param name="action">Action to convert to an asynchronous action.</param>
  16927. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  16928. /// <returns>Asynchronous action.</returns>
  16929. /// <exception cref="T:System.ArgumentNullException">
  16930. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  16931. public static Func<TArg1, IQbservable<Unit>> ToAsync<TArg1>(this IQbservableProvider provider, Expression<Action<TArg1>> action, IScheduler scheduler)
  16932. {
  16933. if (provider == null)
  16934. throw new ArgumentNullException("provider");
  16935. if (action == null)
  16936. throw new ArgumentNullException("action");
  16937. if (scheduler == null)
  16938. throw new ArgumentNullException("scheduler");
  16939. #if CRIPPLED_REFLECTION
  16940. var m = InfoOf(() => Qbservable.ToAsync<TArg1>(default(IQbservableProvider), default(Expression<Action<TArg1>>), default(IScheduler)));
  16941. #else
  16942. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1));
  16943. #endif
  16944. return (t1) => provider.CreateQuery<Unit>(
  16945. Expression.Invoke(
  16946. Expression.Call(
  16947. null,
  16948. m,
  16949. Expression.Constant(provider, typeof(IQbservableProvider)),
  16950. action,
  16951. Expression.Constant(scheduler, typeof(IScheduler))
  16952. ),
  16953. Expression.Constant(t1, typeof(TArg1))
  16954. )
  16955. );
  16956. }
  16957. /// <summary>
  16958. /// 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.
  16959. /// </summary>
  16960. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  16961. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  16962. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  16963. /// <param name="action">Action to convert to an asynchronous action.</param>
  16964. /// <returns>Asynchronous action.</returns>
  16965. /// <exception cref="T:System.ArgumentNullException">
  16966. /// <paramref name="action" /> is null.</exception>
  16967. public static Func<TArg1, TArg2, IQbservable<Unit>> ToAsync<TArg1, TArg2>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2>> action)
  16968. {
  16969. if (provider == null)
  16970. throw new ArgumentNullException("provider");
  16971. if (action == null)
  16972. throw new ArgumentNullException("action");
  16973. #if CRIPPLED_REFLECTION
  16974. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2>>)));
  16975. #else
  16976. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2));
  16977. #endif
  16978. return (t1, t2) => provider.CreateQuery<Unit>(
  16979. Expression.Invoke(
  16980. Expression.Call(
  16981. null,
  16982. m,
  16983. Expression.Constant(provider, typeof(IQbservableProvider)),
  16984. action
  16985. ),
  16986. Expression.Constant(t1, typeof(TArg1)),
  16987. Expression.Constant(t2, typeof(TArg2))
  16988. )
  16989. );
  16990. }
  16991. /// <summary>
  16992. /// 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.
  16993. /// </summary>
  16994. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  16995. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  16996. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  16997. /// <param name="action">Action to convert to an asynchronous action.</param>
  16998. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  16999. /// <returns>Asynchronous action.</returns>
  17000. /// <exception cref="T:System.ArgumentNullException">
  17001. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17002. public static Func<TArg1, TArg2, IQbservable<Unit>> ToAsync<TArg1, TArg2>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2>> action, IScheduler scheduler)
  17003. {
  17004. if (provider == null)
  17005. throw new ArgumentNullException("provider");
  17006. if (action == null)
  17007. throw new ArgumentNullException("action");
  17008. if (scheduler == null)
  17009. throw new ArgumentNullException("scheduler");
  17010. #if CRIPPLED_REFLECTION
  17011. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2>>), default(IScheduler)));
  17012. #else
  17013. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2));
  17014. #endif
  17015. return (t1, t2) => provider.CreateQuery<Unit>(
  17016. Expression.Invoke(
  17017. Expression.Call(
  17018. null,
  17019. m,
  17020. Expression.Constant(provider, typeof(IQbservableProvider)),
  17021. action,
  17022. Expression.Constant(scheduler, typeof(IScheduler))
  17023. ),
  17024. Expression.Constant(t1, typeof(TArg1)),
  17025. Expression.Constant(t2, typeof(TArg2))
  17026. )
  17027. );
  17028. }
  17029. /// <summary>
  17030. /// 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.
  17031. /// </summary>
  17032. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17033. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17034. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17035. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17036. /// <param name="action">Action to convert to an asynchronous action.</param>
  17037. /// <returns>Asynchronous action.</returns>
  17038. /// <exception cref="T:System.ArgumentNullException">
  17039. /// <paramref name="action" /> is null.</exception>
  17040. public static Func<TArg1, TArg2, TArg3, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3>> action)
  17041. {
  17042. if (provider == null)
  17043. throw new ArgumentNullException("provider");
  17044. if (action == null)
  17045. throw new ArgumentNullException("action");
  17046. #if CRIPPLED_REFLECTION
  17047. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3>>)));
  17048. #else
  17049. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3));
  17050. #endif
  17051. return (t1, t2, t3) => provider.CreateQuery<Unit>(
  17052. Expression.Invoke(
  17053. Expression.Call(
  17054. null,
  17055. m,
  17056. Expression.Constant(provider, typeof(IQbservableProvider)),
  17057. action
  17058. ),
  17059. Expression.Constant(t1, typeof(TArg1)),
  17060. Expression.Constant(t2, typeof(TArg2)),
  17061. Expression.Constant(t3, typeof(TArg3))
  17062. )
  17063. );
  17064. }
  17065. /// <summary>
  17066. /// 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.
  17067. /// </summary>
  17068. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17069. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17070. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17071. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17072. /// <param name="action">Action to convert to an asynchronous action.</param>
  17073. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17074. /// <returns>Asynchronous action.</returns>
  17075. /// <exception cref="T:System.ArgumentNullException">
  17076. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17077. public static Func<TArg1, TArg2, TArg3, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3>> action, IScheduler scheduler)
  17078. {
  17079. if (provider == null)
  17080. throw new ArgumentNullException("provider");
  17081. if (action == null)
  17082. throw new ArgumentNullException("action");
  17083. if (scheduler == null)
  17084. throw new ArgumentNullException("scheduler");
  17085. #if CRIPPLED_REFLECTION
  17086. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3>>), default(IScheduler)));
  17087. #else
  17088. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3));
  17089. #endif
  17090. return (t1, t2, t3) => provider.CreateQuery<Unit>(
  17091. Expression.Invoke(
  17092. Expression.Call(
  17093. null,
  17094. m,
  17095. Expression.Constant(provider, typeof(IQbservableProvider)),
  17096. action,
  17097. Expression.Constant(scheduler, typeof(IScheduler))
  17098. ),
  17099. Expression.Constant(t1, typeof(TArg1)),
  17100. Expression.Constant(t2, typeof(TArg2)),
  17101. Expression.Constant(t3, typeof(TArg3))
  17102. )
  17103. );
  17104. }
  17105. /// <summary>
  17106. /// 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.
  17107. /// </summary>
  17108. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17109. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17110. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17111. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17112. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17113. /// <param name="action">Action to convert to an asynchronous action.</param>
  17114. /// <returns>Asynchronous action.</returns>
  17115. /// <exception cref="T:System.ArgumentNullException">
  17116. /// <paramref name="action" /> is null.</exception>
  17117. public static Func<TArg1, TArg2, TArg3, TArg4, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3, TArg4>> action)
  17118. {
  17119. if (provider == null)
  17120. throw new ArgumentNullException("provider");
  17121. if (action == null)
  17122. throw new ArgumentNullException("action");
  17123. #if CRIPPLED_REFLECTION
  17124. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4>>)));
  17125. #else
  17126. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4));
  17127. #endif
  17128. return (t1, t2, t3, t4) => provider.CreateQuery<Unit>(
  17129. Expression.Invoke(
  17130. Expression.Call(
  17131. null,
  17132. m,
  17133. Expression.Constant(provider, typeof(IQbservableProvider)),
  17134. action
  17135. ),
  17136. Expression.Constant(t1, typeof(TArg1)),
  17137. Expression.Constant(t2, typeof(TArg2)),
  17138. Expression.Constant(t3, typeof(TArg3)),
  17139. Expression.Constant(t4, typeof(TArg4))
  17140. )
  17141. );
  17142. }
  17143. /// <summary>
  17144. /// 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.
  17145. /// </summary>
  17146. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17147. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17148. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17149. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17150. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17151. /// <param name="action">Action to convert to an asynchronous action.</param>
  17152. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17153. /// <returns>Asynchronous action.</returns>
  17154. /// <exception cref="T:System.ArgumentNullException">
  17155. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17156. 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)
  17157. {
  17158. if (provider == null)
  17159. throw new ArgumentNullException("provider");
  17160. if (action == null)
  17161. throw new ArgumentNullException("action");
  17162. if (scheduler == null)
  17163. throw new ArgumentNullException("scheduler");
  17164. #if CRIPPLED_REFLECTION
  17165. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4>>), default(IScheduler)));
  17166. #else
  17167. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4));
  17168. #endif
  17169. return (t1, t2, t3, t4) => provider.CreateQuery<Unit>(
  17170. Expression.Invoke(
  17171. Expression.Call(
  17172. null,
  17173. m,
  17174. Expression.Constant(provider, typeof(IQbservableProvider)),
  17175. action,
  17176. Expression.Constant(scheduler, typeof(IScheduler))
  17177. ),
  17178. Expression.Constant(t1, typeof(TArg1)),
  17179. Expression.Constant(t2, typeof(TArg2)),
  17180. Expression.Constant(t3, typeof(TArg3)),
  17181. Expression.Constant(t4, typeof(TArg4))
  17182. )
  17183. );
  17184. }
  17185. #if !NO_LARGEARITY
  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 default scheduler.
  17188. /// </summary>
  17189. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17190. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17191. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17192. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17193. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17194. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17195. /// <param name="action">Action to convert to an asynchronous action.</param>
  17196. /// <returns>Asynchronous action.</returns>
  17197. /// <exception cref="T:System.ArgumentNullException">
  17198. /// <paramref name="action" /> is null.</exception>
  17199. 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)
  17200. {
  17201. if (provider == null)
  17202. throw new ArgumentNullException("provider");
  17203. if (action == null)
  17204. throw new ArgumentNullException("action");
  17205. #if CRIPPLED_REFLECTION
  17206. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5>>)));
  17207. #else
  17208. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5));
  17209. #endif
  17210. return (t1, t2, t3, t4, t5) => provider.CreateQuery<Unit>(
  17211. Expression.Invoke(
  17212. Expression.Call(
  17213. null,
  17214. m,
  17215. Expression.Constant(provider, typeof(IQbservableProvider)),
  17216. action
  17217. ),
  17218. Expression.Constant(t1, typeof(TArg1)),
  17219. Expression.Constant(t2, typeof(TArg2)),
  17220. Expression.Constant(t3, typeof(TArg3)),
  17221. Expression.Constant(t4, typeof(TArg4)),
  17222. Expression.Constant(t5, typeof(TArg5))
  17223. )
  17224. );
  17225. }
  17226. /// <summary>
  17227. /// 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.
  17228. /// </summary>
  17229. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17230. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17231. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17232. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17233. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17234. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17235. /// <param name="action">Action to convert to an asynchronous action.</param>
  17236. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17237. /// <returns>Asynchronous action.</returns>
  17238. /// <exception cref="T:System.ArgumentNullException">
  17239. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17240. 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)
  17241. {
  17242. if (provider == null)
  17243. throw new ArgumentNullException("provider");
  17244. if (action == null)
  17245. throw new ArgumentNullException("action");
  17246. if (scheduler == null)
  17247. throw new ArgumentNullException("scheduler");
  17248. #if CRIPPLED_REFLECTION
  17249. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5>>), default(IScheduler)));
  17250. #else
  17251. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5));
  17252. #endif
  17253. return (t1, t2, t3, t4, t5) => provider.CreateQuery<Unit>(
  17254. Expression.Invoke(
  17255. Expression.Call(
  17256. null,
  17257. m,
  17258. Expression.Constant(provider, typeof(IQbservableProvider)),
  17259. action,
  17260. Expression.Constant(scheduler, typeof(IScheduler))
  17261. ),
  17262. Expression.Constant(t1, typeof(TArg1)),
  17263. Expression.Constant(t2, typeof(TArg2)),
  17264. Expression.Constant(t3, typeof(TArg3)),
  17265. Expression.Constant(t4, typeof(TArg4)),
  17266. Expression.Constant(t5, typeof(TArg5))
  17267. )
  17268. );
  17269. }
  17270. /// <summary>
  17271. /// 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.
  17272. /// </summary>
  17273. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17274. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17275. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17276. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17277. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17278. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17279. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  17280. /// <param name="action">Action to convert to an asynchronous action.</param>
  17281. /// <returns>Asynchronous action.</returns>
  17282. /// <exception cref="T:System.ArgumentNullException">
  17283. /// <paramref name="action" /> is null.</exception>
  17284. 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)
  17285. {
  17286. if (provider == null)
  17287. throw new ArgumentNullException("provider");
  17288. if (action == null)
  17289. throw new ArgumentNullException("action");
  17290. #if CRIPPLED_REFLECTION
  17291. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>>)));
  17292. #else
  17293. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6));
  17294. #endif
  17295. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<Unit>(
  17296. Expression.Invoke(
  17297. Expression.Call(
  17298. null,
  17299. m,
  17300. Expression.Constant(provider, typeof(IQbservableProvider)),
  17301. action
  17302. ),
  17303. Expression.Constant(t1, typeof(TArg1)),
  17304. Expression.Constant(t2, typeof(TArg2)),
  17305. Expression.Constant(t3, typeof(TArg3)),
  17306. Expression.Constant(t4, typeof(TArg4)),
  17307. Expression.Constant(t5, typeof(TArg5)),
  17308. Expression.Constant(t6, typeof(TArg6))
  17309. )
  17310. );
  17311. }
  17312. /// <summary>
  17313. /// 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.
  17314. /// </summary>
  17315. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17316. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17317. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17318. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17319. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17320. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17321. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  17322. /// <param name="action">Action to convert to an asynchronous action.</param>
  17323. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17324. /// <returns>Asynchronous action.</returns>
  17325. /// <exception cref="T:System.ArgumentNullException">
  17326. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17327. 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)
  17328. {
  17329. if (provider == null)
  17330. throw new ArgumentNullException("provider");
  17331. if (action == null)
  17332. throw new ArgumentNullException("action");
  17333. if (scheduler == null)
  17334. throw new ArgumentNullException("scheduler");
  17335. #if CRIPPLED_REFLECTION
  17336. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>>), default(IScheduler)));
  17337. #else
  17338. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6));
  17339. #endif
  17340. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<Unit>(
  17341. Expression.Invoke(
  17342. Expression.Call(
  17343. null,
  17344. m,
  17345. Expression.Constant(provider, typeof(IQbservableProvider)),
  17346. action,
  17347. Expression.Constant(scheduler, typeof(IScheduler))
  17348. ),
  17349. Expression.Constant(t1, typeof(TArg1)),
  17350. Expression.Constant(t2, typeof(TArg2)),
  17351. Expression.Constant(t3, typeof(TArg3)),
  17352. Expression.Constant(t4, typeof(TArg4)),
  17353. Expression.Constant(t5, typeof(TArg5)),
  17354. Expression.Constant(t6, typeof(TArg6))
  17355. )
  17356. );
  17357. }
  17358. /// <summary>
  17359. /// 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.
  17360. /// </summary>
  17361. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17362. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17363. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17364. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17365. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17366. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17367. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  17368. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  17369. /// <param name="action">Action to convert to an asynchronous action.</param>
  17370. /// <returns>Asynchronous action.</returns>
  17371. /// <exception cref="T:System.ArgumentNullException">
  17372. /// <paramref name="action" /> is null.</exception>
  17373. 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)
  17374. {
  17375. if (provider == null)
  17376. throw new ArgumentNullException("provider");
  17377. if (action == null)
  17378. throw new ArgumentNullException("action");
  17379. #if CRIPPLED_REFLECTION
  17380. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7>>)));
  17381. #else
  17382. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7));
  17383. #endif
  17384. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<Unit>(
  17385. Expression.Invoke(
  17386. Expression.Call(
  17387. null,
  17388. m,
  17389. Expression.Constant(provider, typeof(IQbservableProvider)),
  17390. action
  17391. ),
  17392. Expression.Constant(t1, typeof(TArg1)),
  17393. Expression.Constant(t2, typeof(TArg2)),
  17394. Expression.Constant(t3, typeof(TArg3)),
  17395. Expression.Constant(t4, typeof(TArg4)),
  17396. Expression.Constant(t5, typeof(TArg5)),
  17397. Expression.Constant(t6, typeof(TArg6)),
  17398. Expression.Constant(t7, typeof(TArg7))
  17399. )
  17400. );
  17401. }
  17402. /// <summary>
  17403. /// 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.
  17404. /// </summary>
  17405. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17406. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17407. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17408. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17409. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17410. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17411. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  17412. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  17413. /// <param name="action">Action to convert to an asynchronous action.</param>
  17414. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17415. /// <returns>Asynchronous action.</returns>
  17416. /// <exception cref="T:System.ArgumentNullException">
  17417. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17418. 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)
  17419. {
  17420. if (provider == null)
  17421. throw new ArgumentNullException("provider");
  17422. if (action == null)
  17423. throw new ArgumentNullException("action");
  17424. if (scheduler == null)
  17425. throw new ArgumentNullException("scheduler");
  17426. #if CRIPPLED_REFLECTION
  17427. 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)));
  17428. #else
  17429. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7));
  17430. #endif
  17431. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<Unit>(
  17432. Expression.Invoke(
  17433. Expression.Call(
  17434. null,
  17435. m,
  17436. Expression.Constant(provider, typeof(IQbservableProvider)),
  17437. action,
  17438. Expression.Constant(scheduler, typeof(IScheduler))
  17439. ),
  17440. Expression.Constant(t1, typeof(TArg1)),
  17441. Expression.Constant(t2, typeof(TArg2)),
  17442. Expression.Constant(t3, typeof(TArg3)),
  17443. Expression.Constant(t4, typeof(TArg4)),
  17444. Expression.Constant(t5, typeof(TArg5)),
  17445. Expression.Constant(t6, typeof(TArg6)),
  17446. Expression.Constant(t7, typeof(TArg7))
  17447. )
  17448. );
  17449. }
  17450. /// <summary>
  17451. /// 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.
  17452. /// </summary>
  17453. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17454. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17455. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17456. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17457. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17458. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17459. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  17460. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  17461. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  17462. /// <param name="action">Action to convert to an asynchronous action.</param>
  17463. /// <returns>Asynchronous action.</returns>
  17464. /// <exception cref="T:System.ArgumentNullException">
  17465. /// <paramref name="action" /> is null.</exception>
  17466. 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)
  17467. {
  17468. if (provider == null)
  17469. throw new ArgumentNullException("provider");
  17470. if (action == null)
  17471. throw new ArgumentNullException("action");
  17472. #if CRIPPLED_REFLECTION
  17473. 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>>)));
  17474. #else
  17475. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8));
  17476. #endif
  17477. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<Unit>(
  17478. Expression.Invoke(
  17479. Expression.Call(
  17480. null,
  17481. m,
  17482. Expression.Constant(provider, typeof(IQbservableProvider)),
  17483. action
  17484. ),
  17485. Expression.Constant(t1, typeof(TArg1)),
  17486. Expression.Constant(t2, typeof(TArg2)),
  17487. Expression.Constant(t3, typeof(TArg3)),
  17488. Expression.Constant(t4, typeof(TArg4)),
  17489. Expression.Constant(t5, typeof(TArg5)),
  17490. Expression.Constant(t6, typeof(TArg6)),
  17491. Expression.Constant(t7, typeof(TArg7)),
  17492. Expression.Constant(t8, typeof(TArg8))
  17493. )
  17494. );
  17495. }
  17496. /// <summary>
  17497. /// 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.
  17498. /// </summary>
  17499. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17500. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17501. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17502. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17503. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17504. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17505. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  17506. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  17507. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  17508. /// <param name="action">Action to convert to an asynchronous action.</param>
  17509. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17510. /// <returns>Asynchronous action.</returns>
  17511. /// <exception cref="T:System.ArgumentNullException">
  17512. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17513. 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)
  17514. {
  17515. if (provider == null)
  17516. throw new ArgumentNullException("provider");
  17517. if (action == null)
  17518. throw new ArgumentNullException("action");
  17519. if (scheduler == null)
  17520. throw new ArgumentNullException("scheduler");
  17521. #if CRIPPLED_REFLECTION
  17522. 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)));
  17523. #else
  17524. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8));
  17525. #endif
  17526. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<Unit>(
  17527. Expression.Invoke(
  17528. Expression.Call(
  17529. null,
  17530. m,
  17531. Expression.Constant(provider, typeof(IQbservableProvider)),
  17532. action,
  17533. Expression.Constant(scheduler, typeof(IScheduler))
  17534. ),
  17535. Expression.Constant(t1, typeof(TArg1)),
  17536. Expression.Constant(t2, typeof(TArg2)),
  17537. Expression.Constant(t3, typeof(TArg3)),
  17538. Expression.Constant(t4, typeof(TArg4)),
  17539. Expression.Constant(t5, typeof(TArg5)),
  17540. Expression.Constant(t6, typeof(TArg6)),
  17541. Expression.Constant(t7, typeof(TArg7)),
  17542. Expression.Constant(t8, typeof(TArg8))
  17543. )
  17544. );
  17545. }
  17546. /// <summary>
  17547. /// 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.
  17548. /// </summary>
  17549. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17550. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17551. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17552. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17553. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17554. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17555. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  17556. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  17557. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  17558. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  17559. /// <param name="action">Action to convert to an asynchronous action.</param>
  17560. /// <returns>Asynchronous action.</returns>
  17561. /// <exception cref="T:System.ArgumentNullException">
  17562. /// <paramref name="action" /> is null.</exception>
  17563. 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)
  17564. {
  17565. if (provider == null)
  17566. throw new ArgumentNullException("provider");
  17567. if (action == null)
  17568. throw new ArgumentNullException("action");
  17569. #if CRIPPLED_REFLECTION
  17570. 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>>)));
  17571. #else
  17572. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9));
  17573. #endif
  17574. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<Unit>(
  17575. Expression.Invoke(
  17576. Expression.Call(
  17577. null,
  17578. m,
  17579. Expression.Constant(provider, typeof(IQbservableProvider)),
  17580. action
  17581. ),
  17582. Expression.Constant(t1, typeof(TArg1)),
  17583. Expression.Constant(t2, typeof(TArg2)),
  17584. Expression.Constant(t3, typeof(TArg3)),
  17585. Expression.Constant(t4, typeof(TArg4)),
  17586. Expression.Constant(t5, typeof(TArg5)),
  17587. Expression.Constant(t6, typeof(TArg6)),
  17588. Expression.Constant(t7, typeof(TArg7)),
  17589. Expression.Constant(t8, typeof(TArg8)),
  17590. Expression.Constant(t9, typeof(TArg9))
  17591. )
  17592. );
  17593. }
  17594. /// <summary>
  17595. /// 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.
  17596. /// </summary>
  17597. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17598. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17599. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17600. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17601. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17602. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17603. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  17604. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  17605. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  17606. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  17607. /// <param name="action">Action to convert to an asynchronous action.</param>
  17608. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17609. /// <returns>Asynchronous action.</returns>
  17610. /// <exception cref="T:System.ArgumentNullException">
  17611. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17612. 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)
  17613. {
  17614. if (provider == null)
  17615. throw new ArgumentNullException("provider");
  17616. if (action == null)
  17617. throw new ArgumentNullException("action");
  17618. if (scheduler == null)
  17619. throw new ArgumentNullException("scheduler");
  17620. #if CRIPPLED_REFLECTION
  17621. 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)));
  17622. #else
  17623. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9));
  17624. #endif
  17625. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<Unit>(
  17626. Expression.Invoke(
  17627. Expression.Call(
  17628. null,
  17629. m,
  17630. Expression.Constant(provider, typeof(IQbservableProvider)),
  17631. action,
  17632. Expression.Constant(scheduler, typeof(IScheduler))
  17633. ),
  17634. Expression.Constant(t1, typeof(TArg1)),
  17635. Expression.Constant(t2, typeof(TArg2)),
  17636. Expression.Constant(t3, typeof(TArg3)),
  17637. Expression.Constant(t4, typeof(TArg4)),
  17638. Expression.Constant(t5, typeof(TArg5)),
  17639. Expression.Constant(t6, typeof(TArg6)),
  17640. Expression.Constant(t7, typeof(TArg7)),
  17641. Expression.Constant(t8, typeof(TArg8)),
  17642. Expression.Constant(t9, typeof(TArg9))
  17643. )
  17644. );
  17645. }
  17646. /// <summary>
  17647. /// 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.
  17648. /// </summary>
  17649. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17650. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17651. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17652. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17653. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17654. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17655. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  17656. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  17657. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  17658. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  17659. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  17660. /// <param name="action">Action to convert to an asynchronous action.</param>
  17661. /// <returns>Asynchronous action.</returns>
  17662. /// <exception cref="T:System.ArgumentNullException">
  17663. /// <paramref name="action" /> is null.</exception>
  17664. 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)
  17665. {
  17666. if (provider == null)
  17667. throw new ArgumentNullException("provider");
  17668. if (action == null)
  17669. throw new ArgumentNullException("action");
  17670. #if CRIPPLED_REFLECTION
  17671. 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>>)));
  17672. #else
  17673. 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));
  17674. #endif
  17675. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<Unit>(
  17676. Expression.Invoke(
  17677. Expression.Call(
  17678. null,
  17679. m,
  17680. Expression.Constant(provider, typeof(IQbservableProvider)),
  17681. action
  17682. ),
  17683. Expression.Constant(t1, typeof(TArg1)),
  17684. Expression.Constant(t2, typeof(TArg2)),
  17685. Expression.Constant(t3, typeof(TArg3)),
  17686. Expression.Constant(t4, typeof(TArg4)),
  17687. Expression.Constant(t5, typeof(TArg5)),
  17688. Expression.Constant(t6, typeof(TArg6)),
  17689. Expression.Constant(t7, typeof(TArg7)),
  17690. Expression.Constant(t8, typeof(TArg8)),
  17691. Expression.Constant(t9, typeof(TArg9)),
  17692. Expression.Constant(t10, typeof(TArg10))
  17693. )
  17694. );
  17695. }
  17696. /// <summary>
  17697. /// 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.
  17698. /// </summary>
  17699. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17700. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17701. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17702. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17703. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17704. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17705. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  17706. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  17707. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  17708. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  17709. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  17710. /// <param name="action">Action to convert to an asynchronous action.</param>
  17711. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17712. /// <returns>Asynchronous action.</returns>
  17713. /// <exception cref="T:System.ArgumentNullException">
  17714. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17715. 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)
  17716. {
  17717. if (provider == null)
  17718. throw new ArgumentNullException("provider");
  17719. if (action == null)
  17720. throw new ArgumentNullException("action");
  17721. if (scheduler == null)
  17722. throw new ArgumentNullException("scheduler");
  17723. #if CRIPPLED_REFLECTION
  17724. 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)));
  17725. #else
  17726. 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));
  17727. #endif
  17728. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<Unit>(
  17729. Expression.Invoke(
  17730. Expression.Call(
  17731. null,
  17732. m,
  17733. Expression.Constant(provider, typeof(IQbservableProvider)),
  17734. action,
  17735. Expression.Constant(scheduler, typeof(IScheduler))
  17736. ),
  17737. Expression.Constant(t1, typeof(TArg1)),
  17738. Expression.Constant(t2, typeof(TArg2)),
  17739. Expression.Constant(t3, typeof(TArg3)),
  17740. Expression.Constant(t4, typeof(TArg4)),
  17741. Expression.Constant(t5, typeof(TArg5)),
  17742. Expression.Constant(t6, typeof(TArg6)),
  17743. Expression.Constant(t7, typeof(TArg7)),
  17744. Expression.Constant(t8, typeof(TArg8)),
  17745. Expression.Constant(t9, typeof(TArg9)),
  17746. Expression.Constant(t10, typeof(TArg10))
  17747. )
  17748. );
  17749. }
  17750. /// <summary>
  17751. /// 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.
  17752. /// </summary>
  17753. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17754. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17755. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17756. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17757. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17758. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17759. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  17760. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  17761. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  17762. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  17763. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  17764. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  17765. /// <param name="action">Action to convert to an asynchronous action.</param>
  17766. /// <returns>Asynchronous action.</returns>
  17767. /// <exception cref="T:System.ArgumentNullException">
  17768. /// <paramref name="action" /> is null.</exception>
  17769. 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)
  17770. {
  17771. if (provider == null)
  17772. throw new ArgumentNullException("provider");
  17773. if (action == null)
  17774. throw new ArgumentNullException("action");
  17775. #if CRIPPLED_REFLECTION
  17776. 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>>)));
  17777. #else
  17778. 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));
  17779. #endif
  17780. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<Unit>(
  17781. Expression.Invoke(
  17782. Expression.Call(
  17783. null,
  17784. m,
  17785. Expression.Constant(provider, typeof(IQbservableProvider)),
  17786. action
  17787. ),
  17788. Expression.Constant(t1, typeof(TArg1)),
  17789. Expression.Constant(t2, typeof(TArg2)),
  17790. Expression.Constant(t3, typeof(TArg3)),
  17791. Expression.Constant(t4, typeof(TArg4)),
  17792. Expression.Constant(t5, typeof(TArg5)),
  17793. Expression.Constant(t6, typeof(TArg6)),
  17794. Expression.Constant(t7, typeof(TArg7)),
  17795. Expression.Constant(t8, typeof(TArg8)),
  17796. Expression.Constant(t9, typeof(TArg9)),
  17797. Expression.Constant(t10, typeof(TArg10)),
  17798. Expression.Constant(t11, typeof(TArg11))
  17799. )
  17800. );
  17801. }
  17802. /// <summary>
  17803. /// 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.
  17804. /// </summary>
  17805. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17806. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17807. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17808. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17809. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17810. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17811. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  17812. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  17813. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  17814. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  17815. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  17816. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  17817. /// <param name="action">Action to convert to an asynchronous action.</param>
  17818. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17819. /// <returns>Asynchronous action.</returns>
  17820. /// <exception cref="T:System.ArgumentNullException">
  17821. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17822. 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)
  17823. {
  17824. if (provider == null)
  17825. throw new ArgumentNullException("provider");
  17826. if (action == null)
  17827. throw new ArgumentNullException("action");
  17828. if (scheduler == null)
  17829. throw new ArgumentNullException("scheduler");
  17830. #if CRIPPLED_REFLECTION
  17831. 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)));
  17832. #else
  17833. 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));
  17834. #endif
  17835. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<Unit>(
  17836. Expression.Invoke(
  17837. Expression.Call(
  17838. null,
  17839. m,
  17840. Expression.Constant(provider, typeof(IQbservableProvider)),
  17841. action,
  17842. Expression.Constant(scheduler, typeof(IScheduler))
  17843. ),
  17844. Expression.Constant(t1, typeof(TArg1)),
  17845. Expression.Constant(t2, typeof(TArg2)),
  17846. Expression.Constant(t3, typeof(TArg3)),
  17847. Expression.Constant(t4, typeof(TArg4)),
  17848. Expression.Constant(t5, typeof(TArg5)),
  17849. Expression.Constant(t6, typeof(TArg6)),
  17850. Expression.Constant(t7, typeof(TArg7)),
  17851. Expression.Constant(t8, typeof(TArg8)),
  17852. Expression.Constant(t9, typeof(TArg9)),
  17853. Expression.Constant(t10, typeof(TArg10)),
  17854. Expression.Constant(t11, typeof(TArg11))
  17855. )
  17856. );
  17857. }
  17858. /// <summary>
  17859. /// 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.
  17860. /// </summary>
  17861. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17862. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17863. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17864. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17865. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17866. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17867. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  17868. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  17869. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  17870. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  17871. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  17872. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  17873. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  17874. /// <param name="action">Action to convert to an asynchronous action.</param>
  17875. /// <returns>Asynchronous action.</returns>
  17876. /// <exception cref="T:System.ArgumentNullException">
  17877. /// <paramref name="action" /> is null.</exception>
  17878. 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)
  17879. {
  17880. if (provider == null)
  17881. throw new ArgumentNullException("provider");
  17882. if (action == null)
  17883. throw new ArgumentNullException("action");
  17884. #if CRIPPLED_REFLECTION
  17885. 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>>)));
  17886. #else
  17887. 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));
  17888. #endif
  17889. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<Unit>(
  17890. Expression.Invoke(
  17891. Expression.Call(
  17892. null,
  17893. m,
  17894. Expression.Constant(provider, typeof(IQbservableProvider)),
  17895. action
  17896. ),
  17897. Expression.Constant(t1, typeof(TArg1)),
  17898. Expression.Constant(t2, typeof(TArg2)),
  17899. Expression.Constant(t3, typeof(TArg3)),
  17900. Expression.Constant(t4, typeof(TArg4)),
  17901. Expression.Constant(t5, typeof(TArg5)),
  17902. Expression.Constant(t6, typeof(TArg6)),
  17903. Expression.Constant(t7, typeof(TArg7)),
  17904. Expression.Constant(t8, typeof(TArg8)),
  17905. Expression.Constant(t9, typeof(TArg9)),
  17906. Expression.Constant(t10, typeof(TArg10)),
  17907. Expression.Constant(t11, typeof(TArg11)),
  17908. Expression.Constant(t12, typeof(TArg12))
  17909. )
  17910. );
  17911. }
  17912. /// <summary>
  17913. /// 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.
  17914. /// </summary>
  17915. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17916. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17917. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17918. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17919. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17920. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17921. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  17922. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  17923. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  17924. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  17925. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  17926. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  17927. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  17928. /// <param name="action">Action to convert to an asynchronous action.</param>
  17929. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17930. /// <returns>Asynchronous action.</returns>
  17931. /// <exception cref="T:System.ArgumentNullException">
  17932. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17933. 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)
  17934. {
  17935. if (provider == null)
  17936. throw new ArgumentNullException("provider");
  17937. if (action == null)
  17938. throw new ArgumentNullException("action");
  17939. if (scheduler == null)
  17940. throw new ArgumentNullException("scheduler");
  17941. #if CRIPPLED_REFLECTION
  17942. 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)));
  17943. #else
  17944. 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));
  17945. #endif
  17946. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<Unit>(
  17947. Expression.Invoke(
  17948. Expression.Call(
  17949. null,
  17950. m,
  17951. Expression.Constant(provider, typeof(IQbservableProvider)),
  17952. action,
  17953. Expression.Constant(scheduler, typeof(IScheduler))
  17954. ),
  17955. Expression.Constant(t1, typeof(TArg1)),
  17956. Expression.Constant(t2, typeof(TArg2)),
  17957. Expression.Constant(t3, typeof(TArg3)),
  17958. Expression.Constant(t4, typeof(TArg4)),
  17959. Expression.Constant(t5, typeof(TArg5)),
  17960. Expression.Constant(t6, typeof(TArg6)),
  17961. Expression.Constant(t7, typeof(TArg7)),
  17962. Expression.Constant(t8, typeof(TArg8)),
  17963. Expression.Constant(t9, typeof(TArg9)),
  17964. Expression.Constant(t10, typeof(TArg10)),
  17965. Expression.Constant(t11, typeof(TArg11)),
  17966. Expression.Constant(t12, typeof(TArg12))
  17967. )
  17968. );
  17969. }
  17970. /// <summary>
  17971. /// 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.
  17972. /// </summary>
  17973. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17974. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17975. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17976. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17977. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17978. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17979. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  17980. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  17981. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  17982. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  17983. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  17984. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  17985. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  17986. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  17987. /// <param name="action">Action to convert to an asynchronous action.</param>
  17988. /// <returns>Asynchronous action.</returns>
  17989. /// <exception cref="T:System.ArgumentNullException">
  17990. /// <paramref name="action" /> is null.</exception>
  17991. 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)
  17992. {
  17993. if (provider == null)
  17994. throw new ArgumentNullException("provider");
  17995. if (action == null)
  17996. throw new ArgumentNullException("action");
  17997. #if CRIPPLED_REFLECTION
  17998. 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>>)));
  17999. #else
  18000. 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));
  18001. #endif
  18002. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<Unit>(
  18003. Expression.Invoke(
  18004. Expression.Call(
  18005. null,
  18006. m,
  18007. Expression.Constant(provider, typeof(IQbservableProvider)),
  18008. action
  18009. ),
  18010. Expression.Constant(t1, typeof(TArg1)),
  18011. Expression.Constant(t2, typeof(TArg2)),
  18012. Expression.Constant(t3, typeof(TArg3)),
  18013. Expression.Constant(t4, typeof(TArg4)),
  18014. Expression.Constant(t5, typeof(TArg5)),
  18015. Expression.Constant(t6, typeof(TArg6)),
  18016. Expression.Constant(t7, typeof(TArg7)),
  18017. Expression.Constant(t8, typeof(TArg8)),
  18018. Expression.Constant(t9, typeof(TArg9)),
  18019. Expression.Constant(t10, typeof(TArg10)),
  18020. Expression.Constant(t11, typeof(TArg11)),
  18021. Expression.Constant(t12, typeof(TArg12)),
  18022. Expression.Constant(t13, typeof(TArg13))
  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 IQbservable&lt;T&gt; 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. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18041. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18042. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18043. /// <param name="action">Action to convert to an asynchronous action.</param>
  18044. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18045. /// <returns>Asynchronous action.</returns>
  18046. /// <exception cref="T:System.ArgumentNullException">
  18047. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18048. 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)
  18049. {
  18050. if (provider == null)
  18051. throw new ArgumentNullException("provider");
  18052. if (action == null)
  18053. throw new ArgumentNullException("action");
  18054. if (scheduler == null)
  18055. throw new ArgumentNullException("scheduler");
  18056. #if CRIPPLED_REFLECTION
  18057. 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)));
  18058. #else
  18059. 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));
  18060. #endif
  18061. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<Unit>(
  18062. Expression.Invoke(
  18063. Expression.Call(
  18064. null,
  18065. m,
  18066. Expression.Constant(provider, typeof(IQbservableProvider)),
  18067. action,
  18068. Expression.Constant(scheduler, typeof(IScheduler))
  18069. ),
  18070. Expression.Constant(t1, typeof(TArg1)),
  18071. Expression.Constant(t2, typeof(TArg2)),
  18072. Expression.Constant(t3, typeof(TArg3)),
  18073. Expression.Constant(t4, typeof(TArg4)),
  18074. Expression.Constant(t5, typeof(TArg5)),
  18075. Expression.Constant(t6, typeof(TArg6)),
  18076. Expression.Constant(t7, typeof(TArg7)),
  18077. Expression.Constant(t8, typeof(TArg8)),
  18078. Expression.Constant(t9, typeof(TArg9)),
  18079. Expression.Constant(t10, typeof(TArg10)),
  18080. Expression.Constant(t11, typeof(TArg11)),
  18081. Expression.Constant(t12, typeof(TArg12)),
  18082. Expression.Constant(t13, typeof(TArg13))
  18083. )
  18084. );
  18085. }
  18086. /// <summary>
  18087. /// 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.
  18088. /// </summary>
  18089. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18090. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18091. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18092. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18093. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18094. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18095. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18096. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18097. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18098. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18099. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18100. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18101. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18102. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18103. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  18104. /// <param name="action">Action to convert to an asynchronous action.</param>
  18105. /// <returns>Asynchronous action.</returns>
  18106. /// <exception cref="T:System.ArgumentNullException">
  18107. /// <paramref name="action" /> is null.</exception>
  18108. 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)
  18109. {
  18110. if (provider == null)
  18111. throw new ArgumentNullException("provider");
  18112. if (action == null)
  18113. throw new ArgumentNullException("action");
  18114. #if CRIPPLED_REFLECTION
  18115. 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>>)));
  18116. #else
  18117. 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));
  18118. #endif
  18119. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<Unit>(
  18120. Expression.Invoke(
  18121. Expression.Call(
  18122. null,
  18123. m,
  18124. Expression.Constant(provider, typeof(IQbservableProvider)),
  18125. action
  18126. ),
  18127. Expression.Constant(t1, typeof(TArg1)),
  18128. Expression.Constant(t2, typeof(TArg2)),
  18129. Expression.Constant(t3, typeof(TArg3)),
  18130. Expression.Constant(t4, typeof(TArg4)),
  18131. Expression.Constant(t5, typeof(TArg5)),
  18132. Expression.Constant(t6, typeof(TArg6)),
  18133. Expression.Constant(t7, typeof(TArg7)),
  18134. Expression.Constant(t8, typeof(TArg8)),
  18135. Expression.Constant(t9, typeof(TArg9)),
  18136. Expression.Constant(t10, typeof(TArg10)),
  18137. Expression.Constant(t11, typeof(TArg11)),
  18138. Expression.Constant(t12, typeof(TArg12)),
  18139. Expression.Constant(t13, typeof(TArg13)),
  18140. Expression.Constant(t14, typeof(TArg14))
  18141. )
  18142. );
  18143. }
  18144. /// <summary>
  18145. /// 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.
  18146. /// </summary>
  18147. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18148. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18149. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18150. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18151. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18152. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18153. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18154. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18155. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18156. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18157. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18158. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18159. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18160. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18161. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  18162. /// <param name="action">Action to convert to an asynchronous action.</param>
  18163. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18164. /// <returns>Asynchronous action.</returns>
  18165. /// <exception cref="T:System.ArgumentNullException">
  18166. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18167. 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)
  18168. {
  18169. if (provider == null)
  18170. throw new ArgumentNullException("provider");
  18171. if (action == null)
  18172. throw new ArgumentNullException("action");
  18173. if (scheduler == null)
  18174. throw new ArgumentNullException("scheduler");
  18175. #if CRIPPLED_REFLECTION
  18176. 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)));
  18177. #else
  18178. 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));
  18179. #endif
  18180. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<Unit>(
  18181. Expression.Invoke(
  18182. Expression.Call(
  18183. null,
  18184. m,
  18185. Expression.Constant(provider, typeof(IQbservableProvider)),
  18186. action,
  18187. Expression.Constant(scheduler, typeof(IScheduler))
  18188. ),
  18189. Expression.Constant(t1, typeof(TArg1)),
  18190. Expression.Constant(t2, typeof(TArg2)),
  18191. Expression.Constant(t3, typeof(TArg3)),
  18192. Expression.Constant(t4, typeof(TArg4)),
  18193. Expression.Constant(t5, typeof(TArg5)),
  18194. Expression.Constant(t6, typeof(TArg6)),
  18195. Expression.Constant(t7, typeof(TArg7)),
  18196. Expression.Constant(t8, typeof(TArg8)),
  18197. Expression.Constant(t9, typeof(TArg9)),
  18198. Expression.Constant(t10, typeof(TArg10)),
  18199. Expression.Constant(t11, typeof(TArg11)),
  18200. Expression.Constant(t12, typeof(TArg12)),
  18201. Expression.Constant(t13, typeof(TArg13)),
  18202. Expression.Constant(t14, typeof(TArg14))
  18203. )
  18204. );
  18205. }
  18206. /// <summary>
  18207. /// 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.
  18208. /// </summary>
  18209. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18210. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18211. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18212. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18213. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18214. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18215. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18216. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18217. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18218. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18219. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18220. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18221. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18222. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18223. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  18224. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the action.</typeparam>
  18225. /// <param name="action">Action to convert to an asynchronous action.</param>
  18226. /// <returns>Asynchronous action.</returns>
  18227. /// <exception cref="T:System.ArgumentNullException">
  18228. /// <paramref name="action" /> is null.</exception>
  18229. 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)
  18230. {
  18231. if (provider == null)
  18232. throw new ArgumentNullException("provider");
  18233. if (action == null)
  18234. throw new ArgumentNullException("action");
  18235. #if CRIPPLED_REFLECTION
  18236. 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>>)));
  18237. #else
  18238. 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));
  18239. #endif
  18240. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) => provider.CreateQuery<Unit>(
  18241. Expression.Invoke(
  18242. Expression.Call(
  18243. null,
  18244. m,
  18245. Expression.Constant(provider, typeof(IQbservableProvider)),
  18246. action
  18247. ),
  18248. Expression.Constant(t1, typeof(TArg1)),
  18249. Expression.Constant(t2, typeof(TArg2)),
  18250. Expression.Constant(t3, typeof(TArg3)),
  18251. Expression.Constant(t4, typeof(TArg4)),
  18252. Expression.Constant(t5, typeof(TArg5)),
  18253. Expression.Constant(t6, typeof(TArg6)),
  18254. Expression.Constant(t7, typeof(TArg7)),
  18255. Expression.Constant(t8, typeof(TArg8)),
  18256. Expression.Constant(t9, typeof(TArg9)),
  18257. Expression.Constant(t10, typeof(TArg10)),
  18258. Expression.Constant(t11, typeof(TArg11)),
  18259. Expression.Constant(t12, typeof(TArg12)),
  18260. Expression.Constant(t13, typeof(TArg13)),
  18261. Expression.Constant(t14, typeof(TArg14)),
  18262. Expression.Constant(t15, typeof(TArg15))
  18263. )
  18264. );
  18265. }
  18266. /// <summary>
  18267. /// 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.
  18268. /// </summary>
  18269. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18270. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18271. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18272. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18273. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18274. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18275. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18276. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18277. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18278. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18279. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18280. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18281. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18282. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18283. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  18284. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the action.</typeparam>
  18285. /// <param name="action">Action to convert to an asynchronous action.</param>
  18286. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18287. /// <returns>Asynchronous action.</returns>
  18288. /// <exception cref="T:System.ArgumentNullException">
  18289. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18290. 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)
  18291. {
  18292. if (provider == null)
  18293. throw new ArgumentNullException("provider");
  18294. if (action == null)
  18295. throw new ArgumentNullException("action");
  18296. if (scheduler == null)
  18297. throw new ArgumentNullException("scheduler");
  18298. #if CRIPPLED_REFLECTION
  18299. 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)));
  18300. #else
  18301. 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));
  18302. #endif
  18303. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) => provider.CreateQuery<Unit>(
  18304. Expression.Invoke(
  18305. Expression.Call(
  18306. null,
  18307. m,
  18308. Expression.Constant(provider, typeof(IQbservableProvider)),
  18309. action,
  18310. Expression.Constant(scheduler, typeof(IScheduler))
  18311. ),
  18312. Expression.Constant(t1, typeof(TArg1)),
  18313. Expression.Constant(t2, typeof(TArg2)),
  18314. Expression.Constant(t3, typeof(TArg3)),
  18315. Expression.Constant(t4, typeof(TArg4)),
  18316. Expression.Constant(t5, typeof(TArg5)),
  18317. Expression.Constant(t6, typeof(TArg6)),
  18318. Expression.Constant(t7, typeof(TArg7)),
  18319. Expression.Constant(t8, typeof(TArg8)),
  18320. Expression.Constant(t9, typeof(TArg9)),
  18321. Expression.Constant(t10, typeof(TArg10)),
  18322. Expression.Constant(t11, typeof(TArg11)),
  18323. Expression.Constant(t12, typeof(TArg12)),
  18324. Expression.Constant(t13, typeof(TArg13)),
  18325. Expression.Constant(t14, typeof(TArg14)),
  18326. Expression.Constant(t15, typeof(TArg15))
  18327. )
  18328. );
  18329. }
  18330. /// <summary>
  18331. /// 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.
  18332. /// </summary>
  18333. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18334. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18335. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18336. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18337. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18338. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18339. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18340. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18341. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18342. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18343. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18344. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18345. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18346. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18347. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  18348. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the action.</typeparam>
  18349. /// <typeparam name="TArg16">The type of the sixteenth argument passed to the action.</typeparam>
  18350. /// <param name="action">Action to convert to an asynchronous action.</param>
  18351. /// <returns>Asynchronous action.</returns>
  18352. /// <exception cref="T:System.ArgumentNullException">
  18353. /// <paramref name="action" /> is null.</exception>
  18354. 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)
  18355. {
  18356. if (provider == null)
  18357. throw new ArgumentNullException("provider");
  18358. if (action == null)
  18359. throw new ArgumentNullException("action");
  18360. #if CRIPPLED_REFLECTION
  18361. 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>>)));
  18362. #else
  18363. 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));
  18364. #endif
  18365. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) => provider.CreateQuery<Unit>(
  18366. Expression.Invoke(
  18367. Expression.Call(
  18368. null,
  18369. m,
  18370. Expression.Constant(provider, typeof(IQbservableProvider)),
  18371. action
  18372. ),
  18373. Expression.Constant(t1, typeof(TArg1)),
  18374. Expression.Constant(t2, typeof(TArg2)),
  18375. Expression.Constant(t3, typeof(TArg3)),
  18376. Expression.Constant(t4, typeof(TArg4)),
  18377. Expression.Constant(t5, typeof(TArg5)),
  18378. Expression.Constant(t6, typeof(TArg6)),
  18379. Expression.Constant(t7, typeof(TArg7)),
  18380. Expression.Constant(t8, typeof(TArg8)),
  18381. Expression.Constant(t9, typeof(TArg9)),
  18382. Expression.Constant(t10, typeof(TArg10)),
  18383. Expression.Constant(t11, typeof(TArg11)),
  18384. Expression.Constant(t12, typeof(TArg12)),
  18385. Expression.Constant(t13, typeof(TArg13)),
  18386. Expression.Constant(t14, typeof(TArg14)),
  18387. Expression.Constant(t15, typeof(TArg15)),
  18388. Expression.Constant(t16, typeof(TArg16))
  18389. )
  18390. );
  18391. }
  18392. /// <summary>
  18393. /// 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.
  18394. /// </summary>
  18395. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18396. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18397. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18398. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18399. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18400. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18401. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18402. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18403. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18404. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18405. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18406. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18407. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18408. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18409. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  18410. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the action.</typeparam>
  18411. /// <typeparam name="TArg16">The type of the sixteenth argument passed to the action.</typeparam>
  18412. /// <param name="action">Action to convert to an asynchronous action.</param>
  18413. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18414. /// <returns>Asynchronous action.</returns>
  18415. /// <exception cref="T:System.ArgumentNullException">
  18416. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18417. 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)
  18418. {
  18419. if (provider == null)
  18420. throw new ArgumentNullException("provider");
  18421. if (action == null)
  18422. throw new ArgumentNullException("action");
  18423. if (scheduler == null)
  18424. throw new ArgumentNullException("scheduler");
  18425. #if CRIPPLED_REFLECTION
  18426. 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)));
  18427. #else
  18428. 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));
  18429. #endif
  18430. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) => provider.CreateQuery<Unit>(
  18431. Expression.Invoke(
  18432. Expression.Call(
  18433. null,
  18434. m,
  18435. Expression.Constant(provider, typeof(IQbservableProvider)),
  18436. action,
  18437. Expression.Constant(scheduler, typeof(IScheduler))
  18438. ),
  18439. Expression.Constant(t1, typeof(TArg1)),
  18440. Expression.Constant(t2, typeof(TArg2)),
  18441. Expression.Constant(t3, typeof(TArg3)),
  18442. Expression.Constant(t4, typeof(TArg4)),
  18443. Expression.Constant(t5, typeof(TArg5)),
  18444. Expression.Constant(t6, typeof(TArg6)),
  18445. Expression.Constant(t7, typeof(TArg7)),
  18446. Expression.Constant(t8, typeof(TArg8)),
  18447. Expression.Constant(t9, typeof(TArg9)),
  18448. Expression.Constant(t10, typeof(TArg10)),
  18449. Expression.Constant(t11, typeof(TArg11)),
  18450. Expression.Constant(t12, typeof(TArg12)),
  18451. Expression.Constant(t13, typeof(TArg13)),
  18452. Expression.Constant(t14, typeof(TArg14)),
  18453. Expression.Constant(t15, typeof(TArg15)),
  18454. Expression.Constant(t16, typeof(TArg16))
  18455. )
  18456. );
  18457. }
  18458. #endif
  18459. /// <summary>
  18460. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  18461. /// </summary>
  18462. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18463. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  18464. /// <param name="function">Function to convert to an asynchronous function.</param>
  18465. /// <returns>Asynchronous function.</returns>
  18466. /// <exception cref="T:System.ArgumentNullException">
  18467. /// <paramref name="function" /> is null.</exception>
  18468. public static Func<IQbservable<TResult>> ToAsync<TResult>(this IQbservableProvider provider, Expression<Func<TResult>> function)
  18469. {
  18470. if (provider == null)
  18471. throw new ArgumentNullException("provider");
  18472. if (function == null)
  18473. throw new ArgumentNullException("function");
  18474. #if CRIPPLED_REFLECTION
  18475. var m = InfoOf(() => Qbservable.ToAsync<TResult>(default(IQbservableProvider), default(Expression<Func<TResult>>)));
  18476. #else
  18477. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult));
  18478. #endif
  18479. return () => provider.CreateQuery<TResult>(
  18480. Expression.Invoke(
  18481. Expression.Call(
  18482. null,
  18483. m,
  18484. Expression.Constant(provider, typeof(IQbservableProvider)),
  18485. function
  18486. )
  18487. )
  18488. );
  18489. }
  18490. /// <summary>
  18491. /// 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.
  18492. /// </summary>
  18493. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18494. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  18495. /// <param name="function">Function to convert to an asynchronous function.</param>
  18496. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  18497. /// <returns>Asynchronous function.</returns>
  18498. /// <exception cref="T:System.ArgumentNullException">
  18499. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  18500. public static Func<IQbservable<TResult>> ToAsync<TResult>(this IQbservableProvider provider, Expression<Func<TResult>> function, IScheduler scheduler)
  18501. {
  18502. if (provider == null)
  18503. throw new ArgumentNullException("provider");
  18504. if (function == null)
  18505. throw new ArgumentNullException("function");
  18506. if (scheduler == null)
  18507. throw new ArgumentNullException("scheduler");
  18508. #if CRIPPLED_REFLECTION
  18509. var m = InfoOf(() => Qbservable.ToAsync<TResult>(default(IQbservableProvider), default(Expression<Func<TResult>>), default(IScheduler)));
  18510. #else
  18511. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult));
  18512. #endif
  18513. return () => provider.CreateQuery<TResult>(
  18514. Expression.Invoke(
  18515. Expression.Call(
  18516. null,
  18517. m,
  18518. Expression.Constant(provider, typeof(IQbservableProvider)),
  18519. function,
  18520. Expression.Constant(scheduler, typeof(IScheduler))
  18521. )
  18522. )
  18523. );
  18524. }
  18525. /// <summary>
  18526. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  18527. /// </summary>
  18528. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18529. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  18530. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  18531. /// <param name="function">Function to convert to an asynchronous function.</param>
  18532. /// <returns>Asynchronous function.</returns>
  18533. /// <exception cref="T:System.ArgumentNullException">
  18534. /// <paramref name="function" /> is null.</exception>
  18535. public static Func<TArg1, IQbservable<TResult>> ToAsync<TArg1, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TResult>> function)
  18536. {
  18537. if (provider == null)
  18538. throw new ArgumentNullException("provider");
  18539. if (function == null)
  18540. throw new ArgumentNullException("function");
  18541. #if CRIPPLED_REFLECTION
  18542. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TResult>>)));
  18543. #else
  18544. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TResult));
  18545. #endif
  18546. return (t1) => provider.CreateQuery<TResult>(
  18547. Expression.Invoke(
  18548. Expression.Call(
  18549. null,
  18550. m,
  18551. Expression.Constant(provider, typeof(IQbservableProvider)),
  18552. function
  18553. ),
  18554. Expression.Constant(t1, typeof(TArg1))
  18555. )
  18556. );
  18557. }
  18558. /// <summary>
  18559. /// 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.
  18560. /// </summary>
  18561. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18562. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  18563. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  18564. /// <param name="function">Function to convert to an asynchronous function.</param>
  18565. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  18566. /// <returns>Asynchronous function.</returns>
  18567. /// <exception cref="T:System.ArgumentNullException">
  18568. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  18569. public static Func<TArg1, IQbservable<TResult>> ToAsync<TArg1, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TResult>> function, IScheduler scheduler)
  18570. {
  18571. if (provider == null)
  18572. throw new ArgumentNullException("provider");
  18573. if (function == null)
  18574. throw new ArgumentNullException("function");
  18575. if (scheduler == null)
  18576. throw new ArgumentNullException("scheduler");
  18577. #if CRIPPLED_REFLECTION
  18578. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TResult>>), default(IScheduler)));
  18579. #else
  18580. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TResult));
  18581. #endif
  18582. return (t1) => provider.CreateQuery<TResult>(
  18583. Expression.Invoke(
  18584. Expression.Call(
  18585. null,
  18586. m,
  18587. Expression.Constant(provider, typeof(IQbservableProvider)),
  18588. function,
  18589. Expression.Constant(scheduler, typeof(IScheduler))
  18590. ),
  18591. Expression.Constant(t1, typeof(TArg1))
  18592. )
  18593. );
  18594. }
  18595. /// <summary>
  18596. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  18597. /// </summary>
  18598. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18599. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  18600. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  18601. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  18602. /// <param name="function">Function to convert to an asynchronous function.</param>
  18603. /// <returns>Asynchronous function.</returns>
  18604. /// <exception cref="T:System.ArgumentNullException">
  18605. /// <paramref name="function" /> is null.</exception>
  18606. public static Func<TArg1, TArg2, IQbservable<TResult>> ToAsync<TArg1, TArg2, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TResult>> function)
  18607. {
  18608. if (provider == null)
  18609. throw new ArgumentNullException("provider");
  18610. if (function == null)
  18611. throw new ArgumentNullException("function");
  18612. #if CRIPPLED_REFLECTION
  18613. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TResult>>)));
  18614. #else
  18615. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TResult));
  18616. #endif
  18617. return (t1, t2) => provider.CreateQuery<TResult>(
  18618. Expression.Invoke(
  18619. Expression.Call(
  18620. null,
  18621. m,
  18622. Expression.Constant(provider, typeof(IQbservableProvider)),
  18623. function
  18624. ),
  18625. Expression.Constant(t1, typeof(TArg1)),
  18626. Expression.Constant(t2, typeof(TArg2))
  18627. )
  18628. );
  18629. }
  18630. /// <summary>
  18631. /// 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.
  18632. /// </summary>
  18633. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18634. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  18635. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  18636. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  18637. /// <param name="function">Function to convert to an asynchronous function.</param>
  18638. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  18639. /// <returns>Asynchronous function.</returns>
  18640. /// <exception cref="T:System.ArgumentNullException">
  18641. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  18642. public static Func<TArg1, TArg2, IQbservable<TResult>> ToAsync<TArg1, TArg2, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TResult>> function, IScheduler scheduler)
  18643. {
  18644. if (provider == null)
  18645. throw new ArgumentNullException("provider");
  18646. if (function == null)
  18647. throw new ArgumentNullException("function");
  18648. if (scheduler == null)
  18649. throw new ArgumentNullException("scheduler");
  18650. #if CRIPPLED_REFLECTION
  18651. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TResult>>), default(IScheduler)));
  18652. #else
  18653. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TResult));
  18654. #endif
  18655. return (t1, t2) => provider.CreateQuery<TResult>(
  18656. Expression.Invoke(
  18657. Expression.Call(
  18658. null,
  18659. m,
  18660. Expression.Constant(provider, typeof(IQbservableProvider)),
  18661. function,
  18662. Expression.Constant(scheduler, typeof(IScheduler))
  18663. ),
  18664. Expression.Constant(t1, typeof(TArg1)),
  18665. Expression.Constant(t2, typeof(TArg2))
  18666. )
  18667. );
  18668. }
  18669. /// <summary>
  18670. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  18671. /// </summary>
  18672. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18673. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  18674. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  18675. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  18676. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  18677. /// <param name="function">Function to convert to an asynchronous function.</param>
  18678. /// <returns>Asynchronous function.</returns>
  18679. /// <exception cref="T:System.ArgumentNullException">
  18680. /// <paramref name="function" /> is null.</exception>
  18681. public static Func<TArg1, TArg2, TArg3, IQbservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TResult>> function)
  18682. {
  18683. if (provider == null)
  18684. throw new ArgumentNullException("provider");
  18685. if (function == null)
  18686. throw new ArgumentNullException("function");
  18687. #if CRIPPLED_REFLECTION
  18688. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TResult>>)));
  18689. #else
  18690. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TResult));
  18691. #endif
  18692. return (t1, t2, t3) => provider.CreateQuery<TResult>(
  18693. Expression.Invoke(
  18694. Expression.Call(
  18695. null,
  18696. m,
  18697. Expression.Constant(provider, typeof(IQbservableProvider)),
  18698. function
  18699. ),
  18700. Expression.Constant(t1, typeof(TArg1)),
  18701. Expression.Constant(t2, typeof(TArg2)),
  18702. Expression.Constant(t3, typeof(TArg3))
  18703. )
  18704. );
  18705. }
  18706. /// <summary>
  18707. /// 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.
  18708. /// </summary>
  18709. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18710. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  18711. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  18712. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  18713. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  18714. /// <param name="function">Function to convert to an asynchronous function.</param>
  18715. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  18716. /// <returns>Asynchronous function.</returns>
  18717. /// <exception cref="T:System.ArgumentNullException">
  18718. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  18719. 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)
  18720. {
  18721. if (provider == null)
  18722. throw new ArgumentNullException("provider");
  18723. if (function == null)
  18724. throw new ArgumentNullException("function");
  18725. if (scheduler == null)
  18726. throw new ArgumentNullException("scheduler");
  18727. #if CRIPPLED_REFLECTION
  18728. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TResult>>), default(IScheduler)));
  18729. #else
  18730. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TResult));
  18731. #endif
  18732. return (t1, t2, t3) => provider.CreateQuery<TResult>(
  18733. Expression.Invoke(
  18734. Expression.Call(
  18735. null,
  18736. m,
  18737. Expression.Constant(provider, typeof(IQbservableProvider)),
  18738. function,
  18739. Expression.Constant(scheduler, typeof(IScheduler))
  18740. ),
  18741. Expression.Constant(t1, typeof(TArg1)),
  18742. Expression.Constant(t2, typeof(TArg2)),
  18743. Expression.Constant(t3, typeof(TArg3))
  18744. )
  18745. );
  18746. }
  18747. /// <summary>
  18748. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  18749. /// </summary>
  18750. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18751. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  18752. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  18753. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  18754. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  18755. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  18756. /// <param name="function">Function to convert to an asynchronous function.</param>
  18757. /// <returns>Asynchronous function.</returns>
  18758. /// <exception cref="T:System.ArgumentNullException">
  18759. /// <paramref name="function" /> is null.</exception>
  18760. 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)
  18761. {
  18762. if (provider == null)
  18763. throw new ArgumentNullException("provider");
  18764. if (function == null)
  18765. throw new ArgumentNullException("function");
  18766. #if CRIPPLED_REFLECTION
  18767. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TResult>>)));
  18768. #else
  18769. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TResult));
  18770. #endif
  18771. return (t1, t2, t3, t4) => provider.CreateQuery<TResult>(
  18772. Expression.Invoke(
  18773. Expression.Call(
  18774. null,
  18775. m,
  18776. Expression.Constant(provider, typeof(IQbservableProvider)),
  18777. function
  18778. ),
  18779. Expression.Constant(t1, typeof(TArg1)),
  18780. Expression.Constant(t2, typeof(TArg2)),
  18781. Expression.Constant(t3, typeof(TArg3)),
  18782. Expression.Constant(t4, typeof(TArg4))
  18783. )
  18784. );
  18785. }
  18786. /// <summary>
  18787. /// 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.
  18788. /// </summary>
  18789. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18790. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  18791. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  18792. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  18793. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  18794. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  18795. /// <param name="function">Function to convert to an asynchronous function.</param>
  18796. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  18797. /// <returns>Asynchronous function.</returns>
  18798. /// <exception cref="T:System.ArgumentNullException">
  18799. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  18800. 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)
  18801. {
  18802. if (provider == null)
  18803. throw new ArgumentNullException("provider");
  18804. if (function == null)
  18805. throw new ArgumentNullException("function");
  18806. if (scheduler == null)
  18807. throw new ArgumentNullException("scheduler");
  18808. #if CRIPPLED_REFLECTION
  18809. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TResult>>), default(IScheduler)));
  18810. #else
  18811. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TResult));
  18812. #endif
  18813. return (t1, t2, t3, t4) => provider.CreateQuery<TResult>(
  18814. Expression.Invoke(
  18815. Expression.Call(
  18816. null,
  18817. m,
  18818. Expression.Constant(provider, typeof(IQbservableProvider)),
  18819. function,
  18820. Expression.Constant(scheduler, typeof(IScheduler))
  18821. ),
  18822. Expression.Constant(t1, typeof(TArg1)),
  18823. Expression.Constant(t2, typeof(TArg2)),
  18824. Expression.Constant(t3, typeof(TArg3)),
  18825. Expression.Constant(t4, typeof(TArg4))
  18826. )
  18827. );
  18828. }
  18829. #if !NO_LARGEARITY
  18830. /// <summary>
  18831. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  18832. /// </summary>
  18833. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18834. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  18835. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  18836. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  18837. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  18838. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  18839. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  18840. /// <param name="function">Function to convert to an asynchronous function.</param>
  18841. /// <returns>Asynchronous function.</returns>
  18842. /// <exception cref="T:System.ArgumentNullException">
  18843. /// <paramref name="function" /> is null.</exception>
  18844. 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)
  18845. {
  18846. if (provider == null)
  18847. throw new ArgumentNullException("provider");
  18848. if (function == null)
  18849. throw new ArgumentNullException("function");
  18850. #if CRIPPLED_REFLECTION
  18851. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>>)));
  18852. #else
  18853. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TResult));
  18854. #endif
  18855. return (t1, t2, t3, t4, t5) => provider.CreateQuery<TResult>(
  18856. Expression.Invoke(
  18857. Expression.Call(
  18858. null,
  18859. m,
  18860. Expression.Constant(provider, typeof(IQbservableProvider)),
  18861. function
  18862. ),
  18863. Expression.Constant(t1, typeof(TArg1)),
  18864. Expression.Constant(t2, typeof(TArg2)),
  18865. Expression.Constant(t3, typeof(TArg3)),
  18866. Expression.Constant(t4, typeof(TArg4)),
  18867. Expression.Constant(t5, typeof(TArg5))
  18868. )
  18869. );
  18870. }
  18871. /// <summary>
  18872. /// 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.
  18873. /// </summary>
  18874. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18875. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  18876. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  18877. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  18878. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  18879. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  18880. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  18881. /// <param name="function">Function to convert to an asynchronous function.</param>
  18882. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  18883. /// <returns>Asynchronous function.</returns>
  18884. /// <exception cref="T:System.ArgumentNullException">
  18885. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  18886. 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)
  18887. {
  18888. if (provider == null)
  18889. throw new ArgumentNullException("provider");
  18890. if (function == null)
  18891. throw new ArgumentNullException("function");
  18892. if (scheduler == null)
  18893. throw new ArgumentNullException("scheduler");
  18894. #if CRIPPLED_REFLECTION
  18895. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>>), default(IScheduler)));
  18896. #else
  18897. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TResult));
  18898. #endif
  18899. return (t1, t2, t3, t4, t5) => provider.CreateQuery<TResult>(
  18900. Expression.Invoke(
  18901. Expression.Call(
  18902. null,
  18903. m,
  18904. Expression.Constant(provider, typeof(IQbservableProvider)),
  18905. function,
  18906. Expression.Constant(scheduler, typeof(IScheduler))
  18907. ),
  18908. Expression.Constant(t1, typeof(TArg1)),
  18909. Expression.Constant(t2, typeof(TArg2)),
  18910. Expression.Constant(t3, typeof(TArg3)),
  18911. Expression.Constant(t4, typeof(TArg4)),
  18912. Expression.Constant(t5, typeof(TArg5))
  18913. )
  18914. );
  18915. }
  18916. /// <summary>
  18917. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  18918. /// </summary>
  18919. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18920. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  18921. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  18922. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  18923. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  18924. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  18925. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  18926. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  18927. /// <param name="function">Function to convert to an asynchronous function.</param>
  18928. /// <returns>Asynchronous function.</returns>
  18929. /// <exception cref="T:System.ArgumentNullException">
  18930. /// <paramref name="function" /> is null.</exception>
  18931. 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)
  18932. {
  18933. if (provider == null)
  18934. throw new ArgumentNullException("provider");
  18935. if (function == null)
  18936. throw new ArgumentNullException("function");
  18937. #if CRIPPLED_REFLECTION
  18938. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TResult>>)));
  18939. #else
  18940. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TResult));
  18941. #endif
  18942. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<TResult>(
  18943. Expression.Invoke(
  18944. Expression.Call(
  18945. null,
  18946. m,
  18947. Expression.Constant(provider, typeof(IQbservableProvider)),
  18948. function
  18949. ),
  18950. Expression.Constant(t1, typeof(TArg1)),
  18951. Expression.Constant(t2, typeof(TArg2)),
  18952. Expression.Constant(t3, typeof(TArg3)),
  18953. Expression.Constant(t4, typeof(TArg4)),
  18954. Expression.Constant(t5, typeof(TArg5)),
  18955. Expression.Constant(t6, typeof(TArg6))
  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 IQbservable&lt;T&gt; 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="TArg3">The type of the third argument passed to the function.</typeparam>
  18966. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  18967. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  18968. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  18969. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  18970. /// <param name="function">Function to convert to an asynchronous function.</param>
  18971. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  18972. /// <returns>Asynchronous function.</returns>
  18973. /// <exception cref="T:System.ArgumentNullException">
  18974. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  18975. 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)
  18976. {
  18977. if (provider == null)
  18978. throw new ArgumentNullException("provider");
  18979. if (function == null)
  18980. throw new ArgumentNullException("function");
  18981. if (scheduler == null)
  18982. throw new ArgumentNullException("scheduler");
  18983. #if CRIPPLED_REFLECTION
  18984. 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)));
  18985. #else
  18986. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TResult));
  18987. #endif
  18988. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<TResult>(
  18989. Expression.Invoke(
  18990. Expression.Call(
  18991. null,
  18992. m,
  18993. Expression.Constant(provider, typeof(IQbservableProvider)),
  18994. function,
  18995. Expression.Constant(scheduler, typeof(IScheduler))
  18996. ),
  18997. Expression.Constant(t1, typeof(TArg1)),
  18998. Expression.Constant(t2, typeof(TArg2)),
  18999. Expression.Constant(t3, typeof(TArg3)),
  19000. Expression.Constant(t4, typeof(TArg4)),
  19001. Expression.Constant(t5, typeof(TArg5)),
  19002. Expression.Constant(t6, typeof(TArg6))
  19003. )
  19004. );
  19005. }
  19006. /// <summary>
  19007. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19008. /// </summary>
  19009. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19010. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19011. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19012. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19013. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19014. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19015. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19016. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19017. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19018. /// <param name="function">Function to convert to an asynchronous function.</param>
  19019. /// <returns>Asynchronous function.</returns>
  19020. /// <exception cref="T:System.ArgumentNullException">
  19021. /// <paramref name="function" /> is null.</exception>
  19022. 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)
  19023. {
  19024. if (provider == null)
  19025. throw new ArgumentNullException("provider");
  19026. if (function == null)
  19027. throw new ArgumentNullException("function");
  19028. #if CRIPPLED_REFLECTION
  19029. 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>>)));
  19030. #else
  19031. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TResult));
  19032. #endif
  19033. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<TResult>(
  19034. Expression.Invoke(
  19035. Expression.Call(
  19036. null,
  19037. m,
  19038. Expression.Constant(provider, typeof(IQbservableProvider)),
  19039. function
  19040. ),
  19041. Expression.Constant(t1, typeof(TArg1)),
  19042. Expression.Constant(t2, typeof(TArg2)),
  19043. Expression.Constant(t3, typeof(TArg3)),
  19044. Expression.Constant(t4, typeof(TArg4)),
  19045. Expression.Constant(t5, typeof(TArg5)),
  19046. Expression.Constant(t6, typeof(TArg6)),
  19047. Expression.Constant(t7, typeof(TArg7))
  19048. )
  19049. );
  19050. }
  19051. /// <summary>
  19052. /// 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.
  19053. /// </summary>
  19054. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19055. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19056. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19057. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19058. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19059. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19060. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19061. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19062. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19063. /// <param name="function">Function to convert to an asynchronous function.</param>
  19064. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19065. /// <returns>Asynchronous function.</returns>
  19066. /// <exception cref="T:System.ArgumentNullException">
  19067. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19068. 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)
  19069. {
  19070. if (provider == null)
  19071. throw new ArgumentNullException("provider");
  19072. if (function == null)
  19073. throw new ArgumentNullException("function");
  19074. if (scheduler == null)
  19075. throw new ArgumentNullException("scheduler");
  19076. #if CRIPPLED_REFLECTION
  19077. 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)));
  19078. #else
  19079. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TResult));
  19080. #endif
  19081. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<TResult>(
  19082. Expression.Invoke(
  19083. Expression.Call(
  19084. null,
  19085. m,
  19086. Expression.Constant(provider, typeof(IQbservableProvider)),
  19087. function,
  19088. Expression.Constant(scheduler, typeof(IScheduler))
  19089. ),
  19090. Expression.Constant(t1, typeof(TArg1)),
  19091. Expression.Constant(t2, typeof(TArg2)),
  19092. Expression.Constant(t3, typeof(TArg3)),
  19093. Expression.Constant(t4, typeof(TArg4)),
  19094. Expression.Constant(t5, typeof(TArg5)),
  19095. Expression.Constant(t6, typeof(TArg6)),
  19096. Expression.Constant(t7, typeof(TArg7))
  19097. )
  19098. );
  19099. }
  19100. /// <summary>
  19101. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19102. /// </summary>
  19103. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19104. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19105. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19106. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19107. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19108. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19109. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19110. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19111. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19112. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19113. /// <param name="function">Function to convert to an asynchronous function.</param>
  19114. /// <returns>Asynchronous function.</returns>
  19115. /// <exception cref="T:System.ArgumentNullException">
  19116. /// <paramref name="function" /> is null.</exception>
  19117. 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)
  19118. {
  19119. if (provider == null)
  19120. throw new ArgumentNullException("provider");
  19121. if (function == null)
  19122. throw new ArgumentNullException("function");
  19123. #if CRIPPLED_REFLECTION
  19124. 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>>)));
  19125. #else
  19126. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TResult));
  19127. #endif
  19128. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<TResult>(
  19129. Expression.Invoke(
  19130. Expression.Call(
  19131. null,
  19132. m,
  19133. Expression.Constant(provider, typeof(IQbservableProvider)),
  19134. function
  19135. ),
  19136. Expression.Constant(t1, typeof(TArg1)),
  19137. Expression.Constant(t2, typeof(TArg2)),
  19138. Expression.Constant(t3, typeof(TArg3)),
  19139. Expression.Constant(t4, typeof(TArg4)),
  19140. Expression.Constant(t5, typeof(TArg5)),
  19141. Expression.Constant(t6, typeof(TArg6)),
  19142. Expression.Constant(t7, typeof(TArg7)),
  19143. Expression.Constant(t8, typeof(TArg8))
  19144. )
  19145. );
  19146. }
  19147. /// <summary>
  19148. /// 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.
  19149. /// </summary>
  19150. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19151. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19152. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19153. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19154. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19155. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19156. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19157. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19158. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19159. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19160. /// <param name="function">Function to convert to an asynchronous function.</param>
  19161. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19162. /// <returns>Asynchronous function.</returns>
  19163. /// <exception cref="T:System.ArgumentNullException">
  19164. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19165. 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)
  19166. {
  19167. if (provider == null)
  19168. throw new ArgumentNullException("provider");
  19169. if (function == null)
  19170. throw new ArgumentNullException("function");
  19171. if (scheduler == null)
  19172. throw new ArgumentNullException("scheduler");
  19173. #if CRIPPLED_REFLECTION
  19174. 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)));
  19175. #else
  19176. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TResult));
  19177. #endif
  19178. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<TResult>(
  19179. Expression.Invoke(
  19180. Expression.Call(
  19181. null,
  19182. m,
  19183. Expression.Constant(provider, typeof(IQbservableProvider)),
  19184. function,
  19185. Expression.Constant(scheduler, typeof(IScheduler))
  19186. ),
  19187. Expression.Constant(t1, typeof(TArg1)),
  19188. Expression.Constant(t2, typeof(TArg2)),
  19189. Expression.Constant(t3, typeof(TArg3)),
  19190. Expression.Constant(t4, typeof(TArg4)),
  19191. Expression.Constant(t5, typeof(TArg5)),
  19192. Expression.Constant(t6, typeof(TArg6)),
  19193. Expression.Constant(t7, typeof(TArg7)),
  19194. Expression.Constant(t8, typeof(TArg8))
  19195. )
  19196. );
  19197. }
  19198. /// <summary>
  19199. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19200. /// </summary>
  19201. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19202. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19203. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19204. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19205. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19206. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19207. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19208. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19209. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19210. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  19211. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19212. /// <param name="function">Function to convert to an asynchronous function.</param>
  19213. /// <returns>Asynchronous function.</returns>
  19214. /// <exception cref="T:System.ArgumentNullException">
  19215. /// <paramref name="function" /> is null.</exception>
  19216. 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)
  19217. {
  19218. if (provider == null)
  19219. throw new ArgumentNullException("provider");
  19220. if (function == null)
  19221. throw new ArgumentNullException("function");
  19222. #if CRIPPLED_REFLECTION
  19223. 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>>)));
  19224. #else
  19225. 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));
  19226. #endif
  19227. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<TResult>(
  19228. Expression.Invoke(
  19229. Expression.Call(
  19230. null,
  19231. m,
  19232. Expression.Constant(provider, typeof(IQbservableProvider)),
  19233. function
  19234. ),
  19235. Expression.Constant(t1, typeof(TArg1)),
  19236. Expression.Constant(t2, typeof(TArg2)),
  19237. Expression.Constant(t3, typeof(TArg3)),
  19238. Expression.Constant(t4, typeof(TArg4)),
  19239. Expression.Constant(t5, typeof(TArg5)),
  19240. Expression.Constant(t6, typeof(TArg6)),
  19241. Expression.Constant(t7, typeof(TArg7)),
  19242. Expression.Constant(t8, typeof(TArg8)),
  19243. Expression.Constant(t9, typeof(TArg9))
  19244. )
  19245. );
  19246. }
  19247. /// <summary>
  19248. /// 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.
  19249. /// </summary>
  19250. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19251. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19252. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19253. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19254. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19255. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19256. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19257. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19258. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19259. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  19260. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19261. /// <param name="function">Function to convert to an asynchronous function.</param>
  19262. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19263. /// <returns>Asynchronous function.</returns>
  19264. /// <exception cref="T:System.ArgumentNullException">
  19265. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19266. 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)
  19267. {
  19268. if (provider == null)
  19269. throw new ArgumentNullException("provider");
  19270. if (function == null)
  19271. throw new ArgumentNullException("function");
  19272. if (scheduler == null)
  19273. throw new ArgumentNullException("scheduler");
  19274. #if CRIPPLED_REFLECTION
  19275. 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)));
  19276. #else
  19277. 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));
  19278. #endif
  19279. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<TResult>(
  19280. Expression.Invoke(
  19281. Expression.Call(
  19282. null,
  19283. m,
  19284. Expression.Constant(provider, typeof(IQbservableProvider)),
  19285. function,
  19286. Expression.Constant(scheduler, typeof(IScheduler))
  19287. ),
  19288. Expression.Constant(t1, typeof(TArg1)),
  19289. Expression.Constant(t2, typeof(TArg2)),
  19290. Expression.Constant(t3, typeof(TArg3)),
  19291. Expression.Constant(t4, typeof(TArg4)),
  19292. Expression.Constant(t5, typeof(TArg5)),
  19293. Expression.Constant(t6, typeof(TArg6)),
  19294. Expression.Constant(t7, typeof(TArg7)),
  19295. Expression.Constant(t8, typeof(TArg8)),
  19296. Expression.Constant(t9, typeof(TArg9))
  19297. )
  19298. );
  19299. }
  19300. /// <summary>
  19301. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19302. /// </summary>
  19303. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19304. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19305. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19306. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19307. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19308. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19309. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19310. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19311. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19312. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  19313. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  19314. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19315. /// <param name="function">Function to convert to an asynchronous function.</param>
  19316. /// <returns>Asynchronous function.</returns>
  19317. /// <exception cref="T:System.ArgumentNullException">
  19318. /// <paramref name="function" /> is null.</exception>
  19319. 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)
  19320. {
  19321. if (provider == null)
  19322. throw new ArgumentNullException("provider");
  19323. if (function == null)
  19324. throw new ArgumentNullException("function");
  19325. #if CRIPPLED_REFLECTION
  19326. 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>>)));
  19327. #else
  19328. 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));
  19329. #endif
  19330. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<TResult>(
  19331. Expression.Invoke(
  19332. Expression.Call(
  19333. null,
  19334. m,
  19335. Expression.Constant(provider, typeof(IQbservableProvider)),
  19336. function
  19337. ),
  19338. Expression.Constant(t1, typeof(TArg1)),
  19339. Expression.Constant(t2, typeof(TArg2)),
  19340. Expression.Constant(t3, typeof(TArg3)),
  19341. Expression.Constant(t4, typeof(TArg4)),
  19342. Expression.Constant(t5, typeof(TArg5)),
  19343. Expression.Constant(t6, typeof(TArg6)),
  19344. Expression.Constant(t7, typeof(TArg7)),
  19345. Expression.Constant(t8, typeof(TArg8)),
  19346. Expression.Constant(t9, typeof(TArg9)),
  19347. Expression.Constant(t10, typeof(TArg10))
  19348. )
  19349. );
  19350. }
  19351. /// <summary>
  19352. /// 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.
  19353. /// </summary>
  19354. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19355. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19356. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19357. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19358. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19359. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19360. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19361. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19362. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19363. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  19364. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  19365. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19366. /// <param name="function">Function to convert to an asynchronous function.</param>
  19367. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19368. /// <returns>Asynchronous function.</returns>
  19369. /// <exception cref="T:System.ArgumentNullException">
  19370. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19371. 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)
  19372. {
  19373. if (provider == null)
  19374. throw new ArgumentNullException("provider");
  19375. if (function == null)
  19376. throw new ArgumentNullException("function");
  19377. if (scheduler == null)
  19378. throw new ArgumentNullException("scheduler");
  19379. #if CRIPPLED_REFLECTION
  19380. 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)));
  19381. #else
  19382. 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));
  19383. #endif
  19384. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<TResult>(
  19385. Expression.Invoke(
  19386. Expression.Call(
  19387. null,
  19388. m,
  19389. Expression.Constant(provider, typeof(IQbservableProvider)),
  19390. function,
  19391. Expression.Constant(scheduler, typeof(IScheduler))
  19392. ),
  19393. Expression.Constant(t1, typeof(TArg1)),
  19394. Expression.Constant(t2, typeof(TArg2)),
  19395. Expression.Constant(t3, typeof(TArg3)),
  19396. Expression.Constant(t4, typeof(TArg4)),
  19397. Expression.Constant(t5, typeof(TArg5)),
  19398. Expression.Constant(t6, typeof(TArg6)),
  19399. Expression.Constant(t7, typeof(TArg7)),
  19400. Expression.Constant(t8, typeof(TArg8)),
  19401. Expression.Constant(t9, typeof(TArg9)),
  19402. Expression.Constant(t10, typeof(TArg10))
  19403. )
  19404. );
  19405. }
  19406. /// <summary>
  19407. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19408. /// </summary>
  19409. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19410. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19411. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19412. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19413. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19414. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19415. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19416. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19417. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19418. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  19419. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  19420. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  19421. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19422. /// <param name="function">Function to convert to an asynchronous function.</param>
  19423. /// <returns>Asynchronous function.</returns>
  19424. /// <exception cref="T:System.ArgumentNullException">
  19425. /// <paramref name="function" /> is null.</exception>
  19426. 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)
  19427. {
  19428. if (provider == null)
  19429. throw new ArgumentNullException("provider");
  19430. if (function == null)
  19431. throw new ArgumentNullException("function");
  19432. #if CRIPPLED_REFLECTION
  19433. 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>>)));
  19434. #else
  19435. 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));
  19436. #endif
  19437. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<TResult>(
  19438. Expression.Invoke(
  19439. Expression.Call(
  19440. null,
  19441. m,
  19442. Expression.Constant(provider, typeof(IQbservableProvider)),
  19443. function
  19444. ),
  19445. Expression.Constant(t1, typeof(TArg1)),
  19446. Expression.Constant(t2, typeof(TArg2)),
  19447. Expression.Constant(t3, typeof(TArg3)),
  19448. Expression.Constant(t4, typeof(TArg4)),
  19449. Expression.Constant(t5, typeof(TArg5)),
  19450. Expression.Constant(t6, typeof(TArg6)),
  19451. Expression.Constant(t7, typeof(TArg7)),
  19452. Expression.Constant(t8, typeof(TArg8)),
  19453. Expression.Constant(t9, typeof(TArg9)),
  19454. Expression.Constant(t10, typeof(TArg10)),
  19455. Expression.Constant(t11, typeof(TArg11))
  19456. )
  19457. );
  19458. }
  19459. /// <summary>
  19460. /// 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.
  19461. /// </summary>
  19462. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19463. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19464. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19465. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19466. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19467. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19468. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19469. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19470. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19471. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  19472. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  19473. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  19474. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19475. /// <param name="function">Function to convert to an asynchronous function.</param>
  19476. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19477. /// <returns>Asynchronous function.</returns>
  19478. /// <exception cref="T:System.ArgumentNullException">
  19479. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19480. 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)
  19481. {
  19482. if (provider == null)
  19483. throw new ArgumentNullException("provider");
  19484. if (function == null)
  19485. throw new ArgumentNullException("function");
  19486. if (scheduler == null)
  19487. throw new ArgumentNullException("scheduler");
  19488. #if CRIPPLED_REFLECTION
  19489. 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)));
  19490. #else
  19491. 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));
  19492. #endif
  19493. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<TResult>(
  19494. Expression.Invoke(
  19495. Expression.Call(
  19496. null,
  19497. m,
  19498. Expression.Constant(provider, typeof(IQbservableProvider)),
  19499. function,
  19500. Expression.Constant(scheduler, typeof(IScheduler))
  19501. ),
  19502. Expression.Constant(t1, typeof(TArg1)),
  19503. Expression.Constant(t2, typeof(TArg2)),
  19504. Expression.Constant(t3, typeof(TArg3)),
  19505. Expression.Constant(t4, typeof(TArg4)),
  19506. Expression.Constant(t5, typeof(TArg5)),
  19507. Expression.Constant(t6, typeof(TArg6)),
  19508. Expression.Constant(t7, typeof(TArg7)),
  19509. Expression.Constant(t8, typeof(TArg8)),
  19510. Expression.Constant(t9, typeof(TArg9)),
  19511. Expression.Constant(t10, typeof(TArg10)),
  19512. Expression.Constant(t11, typeof(TArg11))
  19513. )
  19514. );
  19515. }
  19516. /// <summary>
  19517. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19518. /// </summary>
  19519. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19520. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19521. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19522. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19523. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19524. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19525. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19526. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19527. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19528. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  19529. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  19530. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  19531. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  19532. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19533. /// <param name="function">Function to convert to an asynchronous function.</param>
  19534. /// <returns>Asynchronous function.</returns>
  19535. /// <exception cref="T:System.ArgumentNullException">
  19536. /// <paramref name="function" /> is null.</exception>
  19537. 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)
  19538. {
  19539. if (provider == null)
  19540. throw new ArgumentNullException("provider");
  19541. if (function == null)
  19542. throw new ArgumentNullException("function");
  19543. #if CRIPPLED_REFLECTION
  19544. 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>>)));
  19545. #else
  19546. 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));
  19547. #endif
  19548. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<TResult>(
  19549. Expression.Invoke(
  19550. Expression.Call(
  19551. null,
  19552. m,
  19553. Expression.Constant(provider, typeof(IQbservableProvider)),
  19554. function
  19555. ),
  19556. Expression.Constant(t1, typeof(TArg1)),
  19557. Expression.Constant(t2, typeof(TArg2)),
  19558. Expression.Constant(t3, typeof(TArg3)),
  19559. Expression.Constant(t4, typeof(TArg4)),
  19560. Expression.Constant(t5, typeof(TArg5)),
  19561. Expression.Constant(t6, typeof(TArg6)),
  19562. Expression.Constant(t7, typeof(TArg7)),
  19563. Expression.Constant(t8, typeof(TArg8)),
  19564. Expression.Constant(t9, typeof(TArg9)),
  19565. Expression.Constant(t10, typeof(TArg10)),
  19566. Expression.Constant(t11, typeof(TArg11)),
  19567. Expression.Constant(t12, typeof(TArg12))
  19568. )
  19569. );
  19570. }
  19571. /// <summary>
  19572. /// 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.
  19573. /// </summary>
  19574. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19575. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19576. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19577. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19578. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19579. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19580. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19581. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19582. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19583. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  19584. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  19585. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  19586. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  19587. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19588. /// <param name="function">Function to convert to an asynchronous function.</param>
  19589. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19590. /// <returns>Asynchronous function.</returns>
  19591. /// <exception cref="T:System.ArgumentNullException">
  19592. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19593. 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)
  19594. {
  19595. if (provider == null)
  19596. throw new ArgumentNullException("provider");
  19597. if (function == null)
  19598. throw new ArgumentNullException("function");
  19599. if (scheduler == null)
  19600. throw new ArgumentNullException("scheduler");
  19601. #if CRIPPLED_REFLECTION
  19602. 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)));
  19603. #else
  19604. 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));
  19605. #endif
  19606. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<TResult>(
  19607. Expression.Invoke(
  19608. Expression.Call(
  19609. null,
  19610. m,
  19611. Expression.Constant(provider, typeof(IQbservableProvider)),
  19612. function,
  19613. Expression.Constant(scheduler, typeof(IScheduler))
  19614. ),
  19615. Expression.Constant(t1, typeof(TArg1)),
  19616. Expression.Constant(t2, typeof(TArg2)),
  19617. Expression.Constant(t3, typeof(TArg3)),
  19618. Expression.Constant(t4, typeof(TArg4)),
  19619. Expression.Constant(t5, typeof(TArg5)),
  19620. Expression.Constant(t6, typeof(TArg6)),
  19621. Expression.Constant(t7, typeof(TArg7)),
  19622. Expression.Constant(t8, typeof(TArg8)),
  19623. Expression.Constant(t9, typeof(TArg9)),
  19624. Expression.Constant(t10, typeof(TArg10)),
  19625. Expression.Constant(t11, typeof(TArg11)),
  19626. Expression.Constant(t12, typeof(TArg12))
  19627. )
  19628. );
  19629. }
  19630. /// <summary>
  19631. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19632. /// </summary>
  19633. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19634. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19635. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19636. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19637. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19638. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19639. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19640. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19641. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19642. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  19643. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  19644. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  19645. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  19646. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  19647. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19648. /// <param name="function">Function to convert to an asynchronous function.</param>
  19649. /// <returns>Asynchronous function.</returns>
  19650. /// <exception cref="T:System.ArgumentNullException">
  19651. /// <paramref name="function" /> is null.</exception>
  19652. 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)
  19653. {
  19654. if (provider == null)
  19655. throw new ArgumentNullException("provider");
  19656. if (function == null)
  19657. throw new ArgumentNullException("function");
  19658. #if CRIPPLED_REFLECTION
  19659. 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>>)));
  19660. #else
  19661. 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));
  19662. #endif
  19663. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<TResult>(
  19664. Expression.Invoke(
  19665. Expression.Call(
  19666. null,
  19667. m,
  19668. Expression.Constant(provider, typeof(IQbservableProvider)),
  19669. function
  19670. ),
  19671. Expression.Constant(t1, typeof(TArg1)),
  19672. Expression.Constant(t2, typeof(TArg2)),
  19673. Expression.Constant(t3, typeof(TArg3)),
  19674. Expression.Constant(t4, typeof(TArg4)),
  19675. Expression.Constant(t5, typeof(TArg5)),
  19676. Expression.Constant(t6, typeof(TArg6)),
  19677. Expression.Constant(t7, typeof(TArg7)),
  19678. Expression.Constant(t8, typeof(TArg8)),
  19679. Expression.Constant(t9, typeof(TArg9)),
  19680. Expression.Constant(t10, typeof(TArg10)),
  19681. Expression.Constant(t11, typeof(TArg11)),
  19682. Expression.Constant(t12, typeof(TArg12)),
  19683. Expression.Constant(t13, typeof(TArg13))
  19684. )
  19685. );
  19686. }
  19687. /// <summary>
  19688. /// 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.
  19689. /// </summary>
  19690. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19691. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19692. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19693. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19694. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19695. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19696. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19697. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19698. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19699. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  19700. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  19701. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  19702. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  19703. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  19704. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19705. /// <param name="function">Function to convert to an asynchronous function.</param>
  19706. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19707. /// <returns>Asynchronous function.</returns>
  19708. /// <exception cref="T:System.ArgumentNullException">
  19709. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19710. 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)
  19711. {
  19712. if (provider == null)
  19713. throw new ArgumentNullException("provider");
  19714. if (function == null)
  19715. throw new ArgumentNullException("function");
  19716. if (scheduler == null)
  19717. throw new ArgumentNullException("scheduler");
  19718. #if CRIPPLED_REFLECTION
  19719. 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)));
  19720. #else
  19721. 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));
  19722. #endif
  19723. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<TResult>(
  19724. Expression.Invoke(
  19725. Expression.Call(
  19726. null,
  19727. m,
  19728. Expression.Constant(provider, typeof(IQbservableProvider)),
  19729. function,
  19730. Expression.Constant(scheduler, typeof(IScheduler))
  19731. ),
  19732. Expression.Constant(t1, typeof(TArg1)),
  19733. Expression.Constant(t2, typeof(TArg2)),
  19734. Expression.Constant(t3, typeof(TArg3)),
  19735. Expression.Constant(t4, typeof(TArg4)),
  19736. Expression.Constant(t5, typeof(TArg5)),
  19737. Expression.Constant(t6, typeof(TArg6)),
  19738. Expression.Constant(t7, typeof(TArg7)),
  19739. Expression.Constant(t8, typeof(TArg8)),
  19740. Expression.Constant(t9, typeof(TArg9)),
  19741. Expression.Constant(t10, typeof(TArg10)),
  19742. Expression.Constant(t11, typeof(TArg11)),
  19743. Expression.Constant(t12, typeof(TArg12)),
  19744. Expression.Constant(t13, typeof(TArg13))
  19745. )
  19746. );
  19747. }
  19748. /// <summary>
  19749. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19750. /// </summary>
  19751. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19752. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19753. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19754. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19755. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19756. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19757. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19758. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19759. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19760. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  19761. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  19762. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  19763. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  19764. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  19765. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  19766. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19767. /// <param name="function">Function to convert to an asynchronous function.</param>
  19768. /// <returns>Asynchronous function.</returns>
  19769. /// <exception cref="T:System.ArgumentNullException">
  19770. /// <paramref name="function" /> is null.</exception>
  19771. 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)
  19772. {
  19773. if (provider == null)
  19774. throw new ArgumentNullException("provider");
  19775. if (function == null)
  19776. throw new ArgumentNullException("function");
  19777. #if CRIPPLED_REFLECTION
  19778. 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>>)));
  19779. #else
  19780. 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));
  19781. #endif
  19782. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<TResult>(
  19783. Expression.Invoke(
  19784. Expression.Call(
  19785. null,
  19786. m,
  19787. Expression.Constant(provider, typeof(IQbservableProvider)),
  19788. function
  19789. ),
  19790. Expression.Constant(t1, typeof(TArg1)),
  19791. Expression.Constant(t2, typeof(TArg2)),
  19792. Expression.Constant(t3, typeof(TArg3)),
  19793. Expression.Constant(t4, typeof(TArg4)),
  19794. Expression.Constant(t5, typeof(TArg5)),
  19795. Expression.Constant(t6, typeof(TArg6)),
  19796. Expression.Constant(t7, typeof(TArg7)),
  19797. Expression.Constant(t8, typeof(TArg8)),
  19798. Expression.Constant(t9, typeof(TArg9)),
  19799. Expression.Constant(t10, typeof(TArg10)),
  19800. Expression.Constant(t11, typeof(TArg11)),
  19801. Expression.Constant(t12, typeof(TArg12)),
  19802. Expression.Constant(t13, typeof(TArg13)),
  19803. Expression.Constant(t14, typeof(TArg14))
  19804. )
  19805. );
  19806. }
  19807. /// <summary>
  19808. /// 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.
  19809. /// </summary>
  19810. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19811. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19812. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19813. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19814. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19815. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19816. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19817. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19818. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19819. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  19820. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  19821. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  19822. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  19823. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  19824. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  19825. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19826. /// <param name="function">Function to convert to an asynchronous function.</param>
  19827. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19828. /// <returns>Asynchronous function.</returns>
  19829. /// <exception cref="T:System.ArgumentNullException">
  19830. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19831. 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)
  19832. {
  19833. if (provider == null)
  19834. throw new ArgumentNullException("provider");
  19835. if (function == null)
  19836. throw new ArgumentNullException("function");
  19837. if (scheduler == null)
  19838. throw new ArgumentNullException("scheduler");
  19839. #if CRIPPLED_REFLECTION
  19840. 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)));
  19841. #else
  19842. 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));
  19843. #endif
  19844. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<TResult>(
  19845. Expression.Invoke(
  19846. Expression.Call(
  19847. null,
  19848. m,
  19849. Expression.Constant(provider, typeof(IQbservableProvider)),
  19850. function,
  19851. Expression.Constant(scheduler, typeof(IScheduler))
  19852. ),
  19853. Expression.Constant(t1, typeof(TArg1)),
  19854. Expression.Constant(t2, typeof(TArg2)),
  19855. Expression.Constant(t3, typeof(TArg3)),
  19856. Expression.Constant(t4, typeof(TArg4)),
  19857. Expression.Constant(t5, typeof(TArg5)),
  19858. Expression.Constant(t6, typeof(TArg6)),
  19859. Expression.Constant(t7, typeof(TArg7)),
  19860. Expression.Constant(t8, typeof(TArg8)),
  19861. Expression.Constant(t9, typeof(TArg9)),
  19862. Expression.Constant(t10, typeof(TArg10)),
  19863. Expression.Constant(t11, typeof(TArg11)),
  19864. Expression.Constant(t12, typeof(TArg12)),
  19865. Expression.Constant(t13, typeof(TArg13)),
  19866. Expression.Constant(t14, typeof(TArg14))
  19867. )
  19868. );
  19869. }
  19870. /// <summary>
  19871. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19872. /// </summary>
  19873. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19874. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19875. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19876. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19877. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19878. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19879. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19880. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19881. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19882. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  19883. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  19884. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  19885. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  19886. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  19887. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  19888. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the function.</typeparam>
  19889. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19890. /// <param name="function">Function to convert to an asynchronous function.</param>
  19891. /// <returns>Asynchronous function.</returns>
  19892. /// <exception cref="T:System.ArgumentNullException">
  19893. /// <paramref name="function" /> is null.</exception>
  19894. 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)
  19895. {
  19896. if (provider == null)
  19897. throw new ArgumentNullException("provider");
  19898. if (function == null)
  19899. throw new ArgumentNullException("function");
  19900. #if CRIPPLED_REFLECTION
  19901. 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>>)));
  19902. #else
  19903. 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));
  19904. #endif
  19905. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) => provider.CreateQuery<TResult>(
  19906. Expression.Invoke(
  19907. Expression.Call(
  19908. null,
  19909. m,
  19910. Expression.Constant(provider, typeof(IQbservableProvider)),
  19911. function
  19912. ),
  19913. Expression.Constant(t1, typeof(TArg1)),
  19914. Expression.Constant(t2, typeof(TArg2)),
  19915. Expression.Constant(t3, typeof(TArg3)),
  19916. Expression.Constant(t4, typeof(TArg4)),
  19917. Expression.Constant(t5, typeof(TArg5)),
  19918. Expression.Constant(t6, typeof(TArg6)),
  19919. Expression.Constant(t7, typeof(TArg7)),
  19920. Expression.Constant(t8, typeof(TArg8)),
  19921. Expression.Constant(t9, typeof(TArg9)),
  19922. Expression.Constant(t10, typeof(TArg10)),
  19923. Expression.Constant(t11, typeof(TArg11)),
  19924. Expression.Constant(t12, typeof(TArg12)),
  19925. Expression.Constant(t13, typeof(TArg13)),
  19926. Expression.Constant(t14, typeof(TArg14)),
  19927. Expression.Constant(t15, typeof(TArg15))
  19928. )
  19929. );
  19930. }
  19931. /// <summary>
  19932. /// 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.
  19933. /// </summary>
  19934. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19935. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19936. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19937. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19938. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19939. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19940. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19941. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19942. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19943. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  19944. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  19945. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  19946. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  19947. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  19948. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  19949. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the function.</typeparam>
  19950. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19951. /// <param name="function">Function to convert to an asynchronous function.</param>
  19952. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19953. /// <returns>Asynchronous function.</returns>
  19954. /// <exception cref="T:System.ArgumentNullException">
  19955. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19956. 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)
  19957. {
  19958. if (provider == null)
  19959. throw new ArgumentNullException("provider");
  19960. if (function == null)
  19961. throw new ArgumentNullException("function");
  19962. if (scheduler == null)
  19963. throw new ArgumentNullException("scheduler");
  19964. #if CRIPPLED_REFLECTION
  19965. 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)));
  19966. #else
  19967. 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));
  19968. #endif
  19969. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) => provider.CreateQuery<TResult>(
  19970. Expression.Invoke(
  19971. Expression.Call(
  19972. null,
  19973. m,
  19974. Expression.Constant(provider, typeof(IQbservableProvider)),
  19975. function,
  19976. Expression.Constant(scheduler, typeof(IScheduler))
  19977. ),
  19978. Expression.Constant(t1, typeof(TArg1)),
  19979. Expression.Constant(t2, typeof(TArg2)),
  19980. Expression.Constant(t3, typeof(TArg3)),
  19981. Expression.Constant(t4, typeof(TArg4)),
  19982. Expression.Constant(t5, typeof(TArg5)),
  19983. Expression.Constant(t6, typeof(TArg6)),
  19984. Expression.Constant(t7, typeof(TArg7)),
  19985. Expression.Constant(t8, typeof(TArg8)),
  19986. Expression.Constant(t9, typeof(TArg9)),
  19987. Expression.Constant(t10, typeof(TArg10)),
  19988. Expression.Constant(t11, typeof(TArg11)),
  19989. Expression.Constant(t12, typeof(TArg12)),
  19990. Expression.Constant(t13, typeof(TArg13)),
  19991. Expression.Constant(t14, typeof(TArg14)),
  19992. Expression.Constant(t15, typeof(TArg15))
  19993. )
  19994. );
  19995. }
  19996. /// <summary>
  19997. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19998. /// </summary>
  19999. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20000. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20001. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20002. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20003. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20004. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20005. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20006. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20007. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20008. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20009. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20010. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20011. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20012. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20013. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20014. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the function.</typeparam>
  20015. /// <typeparam name="TArg16">The type of the sixteenth argument passed to the function.</typeparam>
  20016. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20017. /// <param name="function">Function to convert to an asynchronous function.</param>
  20018. /// <returns>Asynchronous function.</returns>
  20019. /// <exception cref="T:System.ArgumentNullException">
  20020. /// <paramref name="function" /> is null.</exception>
  20021. 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)
  20022. {
  20023. if (provider == null)
  20024. throw new ArgumentNullException("provider");
  20025. if (function == null)
  20026. throw new ArgumentNullException("function");
  20027. #if CRIPPLED_REFLECTION
  20028. 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>>)));
  20029. #else
  20030. 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));
  20031. #endif
  20032. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) => provider.CreateQuery<TResult>(
  20033. Expression.Invoke(
  20034. Expression.Call(
  20035. null,
  20036. m,
  20037. Expression.Constant(provider, typeof(IQbservableProvider)),
  20038. function
  20039. ),
  20040. Expression.Constant(t1, typeof(TArg1)),
  20041. Expression.Constant(t2, typeof(TArg2)),
  20042. Expression.Constant(t3, typeof(TArg3)),
  20043. Expression.Constant(t4, typeof(TArg4)),
  20044. Expression.Constant(t5, typeof(TArg5)),
  20045. Expression.Constant(t6, typeof(TArg6)),
  20046. Expression.Constant(t7, typeof(TArg7)),
  20047. Expression.Constant(t8, typeof(TArg8)),
  20048. Expression.Constant(t9, typeof(TArg9)),
  20049. Expression.Constant(t10, typeof(TArg10)),
  20050. Expression.Constant(t11, typeof(TArg11)),
  20051. Expression.Constant(t12, typeof(TArg12)),
  20052. Expression.Constant(t13, typeof(TArg13)),
  20053. Expression.Constant(t14, typeof(TArg14)),
  20054. Expression.Constant(t15, typeof(TArg15)),
  20055. Expression.Constant(t16, typeof(TArg16))
  20056. )
  20057. );
  20058. }
  20059. /// <summary>
  20060. /// 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.
  20061. /// </summary>
  20062. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20063. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20064. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20065. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20066. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20067. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20068. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20069. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20070. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20071. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20072. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20073. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20074. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20075. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20076. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20077. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the function.</typeparam>
  20078. /// <typeparam name="TArg16">The type of the sixteenth argument passed to the function.</typeparam>
  20079. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20080. /// <param name="function">Function to convert to an asynchronous function.</param>
  20081. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20082. /// <returns>Asynchronous function.</returns>
  20083. /// <exception cref="T:System.ArgumentNullException">
  20084. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20085. 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)
  20086. {
  20087. if (provider == null)
  20088. throw new ArgumentNullException("provider");
  20089. if (function == null)
  20090. throw new ArgumentNullException("function");
  20091. if (scheduler == null)
  20092. throw new ArgumentNullException("scheduler");
  20093. #if CRIPPLED_REFLECTION
  20094. 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)));
  20095. #else
  20096. 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));
  20097. #endif
  20098. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) => provider.CreateQuery<TResult>(
  20099. Expression.Invoke(
  20100. Expression.Call(
  20101. null,
  20102. m,
  20103. Expression.Constant(provider, typeof(IQbservableProvider)),
  20104. function,
  20105. Expression.Constant(scheduler, typeof(IScheduler))
  20106. ),
  20107. Expression.Constant(t1, typeof(TArg1)),
  20108. Expression.Constant(t2, typeof(TArg2)),
  20109. Expression.Constant(t3, typeof(TArg3)),
  20110. Expression.Constant(t4, typeof(TArg4)),
  20111. Expression.Constant(t5, typeof(TArg5)),
  20112. Expression.Constant(t6, typeof(TArg6)),
  20113. Expression.Constant(t7, typeof(TArg7)),
  20114. Expression.Constant(t8, typeof(TArg8)),
  20115. Expression.Constant(t9, typeof(TArg9)),
  20116. Expression.Constant(t10, typeof(TArg10)),
  20117. Expression.Constant(t11, typeof(TArg11)),
  20118. Expression.Constant(t12, typeof(TArg12)),
  20119. Expression.Constant(t13, typeof(TArg13)),
  20120. Expression.Constant(t14, typeof(TArg14)),
  20121. Expression.Constant(t15, typeof(TArg15)),
  20122. Expression.Constant(t16, typeof(TArg16))
  20123. )
  20124. );
  20125. }
  20126. #endif
  20127. /// <summary>
  20128. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20129. /// </summary>
  20130. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20131. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20132. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20133. /// <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>
  20134. /// <exception cref="T:System.ArgumentNullException">
  20135. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20136. /// <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>
  20137. #if PREFERASYNC
  20138. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20139. #endif
  20140. public static Func<IQbservable<Unit>> FromAsyncPattern(this IQbservableProvider provider, Expression<Func<AsyncCallback, object, IAsyncResult>> begin, Expression<Action<IAsyncResult>>end)
  20141. {
  20142. if (provider == null)
  20143. throw new ArgumentNullException("provider");
  20144. if (begin == null)
  20145. throw new ArgumentNullException("begin");
  20146. if (end == null)
  20147. throw new ArgumentNullException("end");
  20148. #if CRIPPLED_REFLECTION
  20149. var m = InfoOf(() => Qbservable.FromAsyncPattern(default(IQbservableProvider), default(Expression<Func<AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  20150. #else
  20151. var m = (MethodInfo)MethodInfo.GetCurrentMethod();
  20152. #endif
  20153. return () => provider.CreateQuery<Unit>(
  20154. Expression.Invoke(
  20155. Expression.Call(
  20156. null,
  20157. m,
  20158. Expression.Constant(provider, typeof(IQbservableProvider)),
  20159. begin,
  20160. end
  20161. )
  20162. )
  20163. );
  20164. }
  20165. /// <summary>
  20166. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20167. /// </summary>
  20168. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20169. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20170. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20171. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20172. /// <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>
  20173. /// <exception cref="T:System.ArgumentNullException">
  20174. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20175. /// <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>
  20176. #if PREFERASYNC
  20177. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20178. #endif
  20179. public static Func<TArg1, IQbservable<Unit>> FromAsyncPattern<TArg1>(this IQbservableProvider provider, Expression<Func<TArg1, AsyncCallback, object, IAsyncResult>> begin, Expression<Action<IAsyncResult>>end)
  20180. {
  20181. if (provider == null)
  20182. throw new ArgumentNullException("provider");
  20183. if (begin == null)
  20184. throw new ArgumentNullException("begin");
  20185. if (end == null)
  20186. throw new ArgumentNullException("end");
  20187. #if CRIPPLED_REFLECTION
  20188. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1>(default(IQbservableProvider), default(Expression<Func<TArg1, AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  20189. #else
  20190. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1));
  20191. #endif
  20192. return (t1) => provider.CreateQuery<Unit>(
  20193. Expression.Invoke(
  20194. Expression.Call(
  20195. null,
  20196. m,
  20197. Expression.Constant(provider, typeof(IQbservableProvider)),
  20198. begin,
  20199. end
  20200. ),
  20201. Expression.Constant(t1, typeof(TArg1))
  20202. )
  20203. );
  20204. }
  20205. /// <summary>
  20206. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20207. /// </summary>
  20208. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20209. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20210. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20211. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20212. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20213. /// <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>
  20214. /// <exception cref="T:System.ArgumentNullException">
  20215. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20216. /// <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>
  20217. #if PREFERASYNC
  20218. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20219. #endif
  20220. 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)
  20221. {
  20222. if (provider == null)
  20223. throw new ArgumentNullException("provider");
  20224. if (begin == null)
  20225. throw new ArgumentNullException("begin");
  20226. if (end == null)
  20227. throw new ArgumentNullException("end");
  20228. #if CRIPPLED_REFLECTION
  20229. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  20230. #else
  20231. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2));
  20232. #endif
  20233. return (t1, t2) => provider.CreateQuery<Unit>(
  20234. Expression.Invoke(
  20235. Expression.Call(
  20236. null,
  20237. m,
  20238. Expression.Constant(provider, typeof(IQbservableProvider)),
  20239. begin,
  20240. end
  20241. ),
  20242. Expression.Constant(t1, typeof(TArg1)),
  20243. Expression.Constant(t2, typeof(TArg2))
  20244. )
  20245. );
  20246. }
  20247. #if !NO_LARGEARITY
  20248. /// <summary>
  20249. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20250. /// </summary>
  20251. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20252. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20253. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20254. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  20255. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20256. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20257. /// <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>
  20258. /// <exception cref="T:System.ArgumentNullException">
  20259. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20260. /// <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>
  20261. #if PREFERASYNC
  20262. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20263. #endif
  20264. 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)
  20265. {
  20266. if (provider == null)
  20267. throw new ArgumentNullException("provider");
  20268. if (begin == null)
  20269. throw new ArgumentNullException("begin");
  20270. if (end == null)
  20271. throw new ArgumentNullException("end");
  20272. #if CRIPPLED_REFLECTION
  20273. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TArg3>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  20274. #else
  20275. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3));
  20276. #endif
  20277. return (t1, t2, t3) => provider.CreateQuery<Unit>(
  20278. Expression.Invoke(
  20279. Expression.Call(
  20280. null,
  20281. m,
  20282. Expression.Constant(provider, typeof(IQbservableProvider)),
  20283. begin,
  20284. end
  20285. ),
  20286. Expression.Constant(t1, typeof(TArg1)),
  20287. Expression.Constant(t2, typeof(TArg2)),
  20288. Expression.Constant(t3, typeof(TArg3))
  20289. )
  20290. );
  20291. }
  20292. /// <summary>
  20293. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20294. /// </summary>
  20295. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20296. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20297. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20298. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  20299. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  20300. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20301. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20302. /// <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>
  20303. /// <exception cref="T:System.ArgumentNullException">
  20304. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20305. /// <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>
  20306. #if PREFERASYNC
  20307. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20308. #endif
  20309. 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)
  20310. {
  20311. if (provider == null)
  20312. throw new ArgumentNullException("provider");
  20313. if (begin == null)
  20314. throw new ArgumentNullException("begin");
  20315. if (end == null)
  20316. throw new ArgumentNullException("end");
  20317. #if CRIPPLED_REFLECTION
  20318. 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>>)));
  20319. #else
  20320. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4));
  20321. #endif
  20322. return (t1, t2, t3, t4) => provider.CreateQuery<Unit>(
  20323. Expression.Invoke(
  20324. Expression.Call(
  20325. null,
  20326. m,
  20327. Expression.Constant(provider, typeof(IQbservableProvider)),
  20328. begin,
  20329. end
  20330. ),
  20331. Expression.Constant(t1, typeof(TArg1)),
  20332. Expression.Constant(t2, typeof(TArg2)),
  20333. Expression.Constant(t3, typeof(TArg3)),
  20334. Expression.Constant(t4, typeof(TArg4))
  20335. )
  20336. );
  20337. }
  20338. /// <summary>
  20339. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20340. /// </summary>
  20341. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20342. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20343. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20344. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  20345. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  20346. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  20347. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20348. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20349. /// <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>
  20350. /// <exception cref="T:System.ArgumentNullException">
  20351. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20352. /// <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>
  20353. #if PREFERASYNC
  20354. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20355. #endif
  20356. 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)
  20357. {
  20358. if (provider == null)
  20359. throw new ArgumentNullException("provider");
  20360. if (begin == null)
  20361. throw new ArgumentNullException("begin");
  20362. if (end == null)
  20363. throw new ArgumentNullException("end");
  20364. #if CRIPPLED_REFLECTION
  20365. 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>>)));
  20366. #else
  20367. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5));
  20368. #endif
  20369. return (t1, t2, t3, t4, t5) => provider.CreateQuery<Unit>(
  20370. Expression.Invoke(
  20371. Expression.Call(
  20372. null,
  20373. m,
  20374. Expression.Constant(provider, typeof(IQbservableProvider)),
  20375. begin,
  20376. end
  20377. ),
  20378. Expression.Constant(t1, typeof(TArg1)),
  20379. Expression.Constant(t2, typeof(TArg2)),
  20380. Expression.Constant(t3, typeof(TArg3)),
  20381. Expression.Constant(t4, typeof(TArg4)),
  20382. Expression.Constant(t5, typeof(TArg5))
  20383. )
  20384. );
  20385. }
  20386. /// <summary>
  20387. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20388. /// </summary>
  20389. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20390. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20391. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20392. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  20393. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  20394. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  20395. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  20396. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20397. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20398. /// <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>
  20399. /// <exception cref="T:System.ArgumentNullException">
  20400. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20401. /// <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>
  20402. #if PREFERASYNC
  20403. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20404. #endif
  20405. 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)
  20406. {
  20407. if (provider == null)
  20408. throw new ArgumentNullException("provider");
  20409. if (begin == null)
  20410. throw new ArgumentNullException("begin");
  20411. if (end == null)
  20412. throw new ArgumentNullException("end");
  20413. #if CRIPPLED_REFLECTION
  20414. 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>>)));
  20415. #else
  20416. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6));
  20417. #endif
  20418. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<Unit>(
  20419. Expression.Invoke(
  20420. Expression.Call(
  20421. null,
  20422. m,
  20423. Expression.Constant(provider, typeof(IQbservableProvider)),
  20424. begin,
  20425. end
  20426. ),
  20427. Expression.Constant(t1, typeof(TArg1)),
  20428. Expression.Constant(t2, typeof(TArg2)),
  20429. Expression.Constant(t3, typeof(TArg3)),
  20430. Expression.Constant(t4, typeof(TArg4)),
  20431. Expression.Constant(t5, typeof(TArg5)),
  20432. Expression.Constant(t6, typeof(TArg6))
  20433. )
  20434. );
  20435. }
  20436. /// <summary>
  20437. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20438. /// </summary>
  20439. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20440. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20441. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20442. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  20443. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  20444. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  20445. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  20446. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  20447. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20448. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20449. /// <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>
  20450. /// <exception cref="T:System.ArgumentNullException">
  20451. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20452. /// <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>
  20453. #if PREFERASYNC
  20454. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20455. #endif
  20456. 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)
  20457. {
  20458. if (provider == null)
  20459. throw new ArgumentNullException("provider");
  20460. if (begin == null)
  20461. throw new ArgumentNullException("begin");
  20462. if (end == null)
  20463. throw new ArgumentNullException("end");
  20464. #if CRIPPLED_REFLECTION
  20465. 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>>)));
  20466. #else
  20467. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7));
  20468. #endif
  20469. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<Unit>(
  20470. Expression.Invoke(
  20471. Expression.Call(
  20472. null,
  20473. m,
  20474. Expression.Constant(provider, typeof(IQbservableProvider)),
  20475. begin,
  20476. end
  20477. ),
  20478. Expression.Constant(t1, typeof(TArg1)),
  20479. Expression.Constant(t2, typeof(TArg2)),
  20480. Expression.Constant(t3, typeof(TArg3)),
  20481. Expression.Constant(t4, typeof(TArg4)),
  20482. Expression.Constant(t5, typeof(TArg5)),
  20483. Expression.Constant(t6, typeof(TArg6)),
  20484. Expression.Constant(t7, typeof(TArg7))
  20485. )
  20486. );
  20487. }
  20488. /// <summary>
  20489. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20490. /// </summary>
  20491. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20492. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20493. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20494. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  20495. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  20496. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  20497. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  20498. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  20499. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  20500. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20501. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20502. /// <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>
  20503. /// <exception cref="T:System.ArgumentNullException">
  20504. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20505. /// <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>
  20506. #if PREFERASYNC
  20507. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20508. #endif
  20509. 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)
  20510. {
  20511. if (provider == null)
  20512. throw new ArgumentNullException("provider");
  20513. if (begin == null)
  20514. throw new ArgumentNullException("begin");
  20515. if (end == null)
  20516. throw new ArgumentNullException("end");
  20517. #if CRIPPLED_REFLECTION
  20518. 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>>)));
  20519. #else
  20520. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8));
  20521. #endif
  20522. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<Unit>(
  20523. Expression.Invoke(
  20524. Expression.Call(
  20525. null,
  20526. m,
  20527. Expression.Constant(provider, typeof(IQbservableProvider)),
  20528. begin,
  20529. end
  20530. ),
  20531. Expression.Constant(t1, typeof(TArg1)),
  20532. Expression.Constant(t2, typeof(TArg2)),
  20533. Expression.Constant(t3, typeof(TArg3)),
  20534. Expression.Constant(t4, typeof(TArg4)),
  20535. Expression.Constant(t5, typeof(TArg5)),
  20536. Expression.Constant(t6, typeof(TArg6)),
  20537. Expression.Constant(t7, typeof(TArg7)),
  20538. Expression.Constant(t8, typeof(TArg8))
  20539. )
  20540. );
  20541. }
  20542. /// <summary>
  20543. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20544. /// </summary>
  20545. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20546. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20547. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20548. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  20549. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  20550. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  20551. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  20552. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  20553. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  20554. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  20555. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20556. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20557. /// <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>
  20558. /// <exception cref="T:System.ArgumentNullException">
  20559. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20560. /// <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>
  20561. #if PREFERASYNC
  20562. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20563. #endif
  20564. 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)
  20565. {
  20566. if (provider == null)
  20567. throw new ArgumentNullException("provider");
  20568. if (begin == null)
  20569. throw new ArgumentNullException("begin");
  20570. if (end == null)
  20571. throw new ArgumentNullException("end");
  20572. #if CRIPPLED_REFLECTION
  20573. 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>>)));
  20574. #else
  20575. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9));
  20576. #endif
  20577. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<Unit>(
  20578. Expression.Invoke(
  20579. Expression.Call(
  20580. null,
  20581. m,
  20582. Expression.Constant(provider, typeof(IQbservableProvider)),
  20583. begin,
  20584. end
  20585. ),
  20586. Expression.Constant(t1, typeof(TArg1)),
  20587. Expression.Constant(t2, typeof(TArg2)),
  20588. Expression.Constant(t3, typeof(TArg3)),
  20589. Expression.Constant(t4, typeof(TArg4)),
  20590. Expression.Constant(t5, typeof(TArg5)),
  20591. Expression.Constant(t6, typeof(TArg6)),
  20592. Expression.Constant(t7, typeof(TArg7)),
  20593. Expression.Constant(t8, typeof(TArg8)),
  20594. Expression.Constant(t9, typeof(TArg9))
  20595. )
  20596. );
  20597. }
  20598. /// <summary>
  20599. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20600. /// </summary>
  20601. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20602. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20603. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20604. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  20605. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  20606. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  20607. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  20608. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  20609. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  20610. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  20611. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  20612. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20613. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20614. /// <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>
  20615. /// <exception cref="T:System.ArgumentNullException">
  20616. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20617. /// <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>
  20618. #if PREFERASYNC
  20619. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20620. #endif
  20621. 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)
  20622. {
  20623. if (provider == null)
  20624. throw new ArgumentNullException("provider");
  20625. if (begin == null)
  20626. throw new ArgumentNullException("begin");
  20627. if (end == null)
  20628. throw new ArgumentNullException("end");
  20629. #if CRIPPLED_REFLECTION
  20630. 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>>)));
  20631. #else
  20632. 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));
  20633. #endif
  20634. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<Unit>(
  20635. Expression.Invoke(
  20636. Expression.Call(
  20637. null,
  20638. m,
  20639. Expression.Constant(provider, typeof(IQbservableProvider)),
  20640. begin,
  20641. end
  20642. ),
  20643. Expression.Constant(t1, typeof(TArg1)),
  20644. Expression.Constant(t2, typeof(TArg2)),
  20645. Expression.Constant(t3, typeof(TArg3)),
  20646. Expression.Constant(t4, typeof(TArg4)),
  20647. Expression.Constant(t5, typeof(TArg5)),
  20648. Expression.Constant(t6, typeof(TArg6)),
  20649. Expression.Constant(t7, typeof(TArg7)),
  20650. Expression.Constant(t8, typeof(TArg8)),
  20651. Expression.Constant(t9, typeof(TArg9)),
  20652. Expression.Constant(t10, typeof(TArg10))
  20653. )
  20654. );
  20655. }
  20656. /// <summary>
  20657. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20658. /// </summary>
  20659. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20660. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20661. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20662. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  20663. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  20664. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  20665. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  20666. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  20667. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  20668. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  20669. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  20670. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  20671. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20672. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20673. /// <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>
  20674. /// <exception cref="T:System.ArgumentNullException">
  20675. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20676. /// <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>
  20677. #if PREFERASYNC
  20678. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20679. #endif
  20680. 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)
  20681. {
  20682. if (provider == null)
  20683. throw new ArgumentNullException("provider");
  20684. if (begin == null)
  20685. throw new ArgumentNullException("begin");
  20686. if (end == null)
  20687. throw new ArgumentNullException("end");
  20688. #if CRIPPLED_REFLECTION
  20689. 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>>)));
  20690. #else
  20691. 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));
  20692. #endif
  20693. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<Unit>(
  20694. Expression.Invoke(
  20695. Expression.Call(
  20696. null,
  20697. m,
  20698. Expression.Constant(provider, typeof(IQbservableProvider)),
  20699. begin,
  20700. end
  20701. ),
  20702. Expression.Constant(t1, typeof(TArg1)),
  20703. Expression.Constant(t2, typeof(TArg2)),
  20704. Expression.Constant(t3, typeof(TArg3)),
  20705. Expression.Constant(t4, typeof(TArg4)),
  20706. Expression.Constant(t5, typeof(TArg5)),
  20707. Expression.Constant(t6, typeof(TArg6)),
  20708. Expression.Constant(t7, typeof(TArg7)),
  20709. Expression.Constant(t8, typeof(TArg8)),
  20710. Expression.Constant(t9, typeof(TArg9)),
  20711. Expression.Constant(t10, typeof(TArg10)),
  20712. Expression.Constant(t11, typeof(TArg11))
  20713. )
  20714. );
  20715. }
  20716. /// <summary>
  20717. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20718. /// </summary>
  20719. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20720. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20721. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20722. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  20723. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  20724. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  20725. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  20726. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  20727. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  20728. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  20729. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  20730. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  20731. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  20732. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20733. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20734. /// <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>
  20735. /// <exception cref="T:System.ArgumentNullException">
  20736. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20737. /// <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>
  20738. #if PREFERASYNC
  20739. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20740. #endif
  20741. 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)
  20742. {
  20743. if (provider == null)
  20744. throw new ArgumentNullException("provider");
  20745. if (begin == null)
  20746. throw new ArgumentNullException("begin");
  20747. if (end == null)
  20748. throw new ArgumentNullException("end");
  20749. #if CRIPPLED_REFLECTION
  20750. 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>>)));
  20751. #else
  20752. 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));
  20753. #endif
  20754. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<Unit>(
  20755. Expression.Invoke(
  20756. Expression.Call(
  20757. null,
  20758. m,
  20759. Expression.Constant(provider, typeof(IQbservableProvider)),
  20760. begin,
  20761. end
  20762. ),
  20763. Expression.Constant(t1, typeof(TArg1)),
  20764. Expression.Constant(t2, typeof(TArg2)),
  20765. Expression.Constant(t3, typeof(TArg3)),
  20766. Expression.Constant(t4, typeof(TArg4)),
  20767. Expression.Constant(t5, typeof(TArg5)),
  20768. Expression.Constant(t6, typeof(TArg6)),
  20769. Expression.Constant(t7, typeof(TArg7)),
  20770. Expression.Constant(t8, typeof(TArg8)),
  20771. Expression.Constant(t9, typeof(TArg9)),
  20772. Expression.Constant(t10, typeof(TArg10)),
  20773. Expression.Constant(t11, typeof(TArg11)),
  20774. Expression.Constant(t12, typeof(TArg12))
  20775. )
  20776. );
  20777. }
  20778. /// <summary>
  20779. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20780. /// </summary>
  20781. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20782. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20783. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20784. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  20785. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  20786. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  20787. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  20788. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  20789. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  20790. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  20791. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  20792. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  20793. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  20794. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the begin delegate.</typeparam>
  20795. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20796. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20797. /// <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>
  20798. /// <exception cref="T:System.ArgumentNullException">
  20799. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20800. /// <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>
  20801. #if PREFERASYNC
  20802. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20803. #endif
  20804. 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)
  20805. {
  20806. if (provider == null)
  20807. throw new ArgumentNullException("provider");
  20808. if (begin == null)
  20809. throw new ArgumentNullException("begin");
  20810. if (end == null)
  20811. throw new ArgumentNullException("end");
  20812. #if CRIPPLED_REFLECTION
  20813. 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>>)));
  20814. #else
  20815. 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));
  20816. #endif
  20817. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<Unit>(
  20818. Expression.Invoke(
  20819. Expression.Call(
  20820. null,
  20821. m,
  20822. Expression.Constant(provider, typeof(IQbservableProvider)),
  20823. begin,
  20824. end
  20825. ),
  20826. Expression.Constant(t1, typeof(TArg1)),
  20827. Expression.Constant(t2, typeof(TArg2)),
  20828. Expression.Constant(t3, typeof(TArg3)),
  20829. Expression.Constant(t4, typeof(TArg4)),
  20830. Expression.Constant(t5, typeof(TArg5)),
  20831. Expression.Constant(t6, typeof(TArg6)),
  20832. Expression.Constant(t7, typeof(TArg7)),
  20833. Expression.Constant(t8, typeof(TArg8)),
  20834. Expression.Constant(t9, typeof(TArg9)),
  20835. Expression.Constant(t10, typeof(TArg10)),
  20836. Expression.Constant(t11, typeof(TArg11)),
  20837. Expression.Constant(t12, typeof(TArg12)),
  20838. Expression.Constant(t13, typeof(TArg13))
  20839. )
  20840. );
  20841. }
  20842. /// <summary>
  20843. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20844. /// </summary>
  20845. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20846. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20847. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20848. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  20849. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  20850. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  20851. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  20852. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  20853. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  20854. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  20855. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  20856. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  20857. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  20858. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the begin delegate.</typeparam>
  20859. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the begin delegate.</typeparam>
  20860. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20861. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20862. /// <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>
  20863. /// <exception cref="T:System.ArgumentNullException">
  20864. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20865. /// <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>
  20866. #if PREFERASYNC
  20867. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20868. #endif
  20869. 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)
  20870. {
  20871. if (provider == null)
  20872. throw new ArgumentNullException("provider");
  20873. if (begin == null)
  20874. throw new ArgumentNullException("begin");
  20875. if (end == null)
  20876. throw new ArgumentNullException("end");
  20877. #if CRIPPLED_REFLECTION
  20878. 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>>)));
  20879. #else
  20880. 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));
  20881. #endif
  20882. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<Unit>(
  20883. Expression.Invoke(
  20884. Expression.Call(
  20885. null,
  20886. m,
  20887. Expression.Constant(provider, typeof(IQbservableProvider)),
  20888. begin,
  20889. end
  20890. ),
  20891. Expression.Constant(t1, typeof(TArg1)),
  20892. Expression.Constant(t2, typeof(TArg2)),
  20893. Expression.Constant(t3, typeof(TArg3)),
  20894. Expression.Constant(t4, typeof(TArg4)),
  20895. Expression.Constant(t5, typeof(TArg5)),
  20896. Expression.Constant(t6, typeof(TArg6)),
  20897. Expression.Constant(t7, typeof(TArg7)),
  20898. Expression.Constant(t8, typeof(TArg8)),
  20899. Expression.Constant(t9, typeof(TArg9)),
  20900. Expression.Constant(t10, typeof(TArg10)),
  20901. Expression.Constant(t11, typeof(TArg11)),
  20902. Expression.Constant(t12, typeof(TArg12)),
  20903. Expression.Constant(t13, typeof(TArg13)),
  20904. Expression.Constant(t14, typeof(TArg14))
  20905. )
  20906. );
  20907. }
  20908. #endif
  20909. /// <summary>
  20910. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20911. /// </summary>
  20912. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20913. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  20914. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20915. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20916. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  20917. /// <exception cref="T:System.ArgumentNullException">
  20918. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20919. /// <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>
  20920. #if PREFERASYNC
  20921. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20922. #endif
  20923. public static Func<IQbservable<TResult>> FromAsyncPattern<TResult>(this IQbservableProvider provider, Expression<Func<AsyncCallback, object, IAsyncResult>> begin, Expression<Func<IAsyncResult, TResult>>end)
  20924. {
  20925. if (provider == null)
  20926. throw new ArgumentNullException("provider");
  20927. if (begin == null)
  20928. throw new ArgumentNullException("begin");
  20929. if (end == null)
  20930. throw new ArgumentNullException("end");
  20931. #if CRIPPLED_REFLECTION
  20932. var m = InfoOf(() => Qbservable.FromAsyncPattern<TResult>(default(IQbservableProvider), default(Expression<Func<AsyncCallback, object, IAsyncResult>>), default(Expression<Func<IAsyncResult, TResult>>)));
  20933. #else
  20934. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult));
  20935. #endif
  20936. return () => provider.CreateQuery<TResult>(
  20937. Expression.Invoke(
  20938. Expression.Call(
  20939. null,
  20940. m,
  20941. Expression.Constant(provider, typeof(IQbservableProvider)),
  20942. begin,
  20943. end
  20944. )
  20945. )
  20946. );
  20947. }
  20948. /// <summary>
  20949. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20950. /// </summary>
  20951. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20952. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20953. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  20954. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20955. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20956. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  20957. /// <exception cref="T:System.ArgumentNullException">
  20958. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20959. /// <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>
  20960. #if PREFERASYNC
  20961. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20962. #endif
  20963. public static Func<TArg1, IQbservable<TResult>> FromAsyncPattern<TArg1, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, AsyncCallback, object, IAsyncResult>> begin, Expression<Func<IAsyncResult, TResult>>end)
  20964. {
  20965. if (provider == null)
  20966. throw new ArgumentNullException("provider");
  20967. if (begin == null)
  20968. throw new ArgumentNullException("begin");
  20969. if (end == null)
  20970. throw new ArgumentNullException("end");
  20971. #if CRIPPLED_REFLECTION
  20972. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, AsyncCallback, object, IAsyncResult>>), default(Expression<Func<IAsyncResult, TResult>>)));
  20973. #else
  20974. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TResult));
  20975. #endif
  20976. return (t1) => provider.CreateQuery<TResult>(
  20977. Expression.Invoke(
  20978. Expression.Call(
  20979. null,
  20980. m,
  20981. Expression.Constant(provider, typeof(IQbservableProvider)),
  20982. begin,
  20983. end
  20984. ),
  20985. Expression.Constant(t1, typeof(TArg1))
  20986. )
  20987. );
  20988. }
  20989. /// <summary>
  20990. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20991. /// </summary>
  20992. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20993. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20994. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20995. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  20996. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20997. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20998. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  20999. /// <exception cref="T:System.ArgumentNullException">
  21000. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21001. /// <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>
  21002. #if PREFERASYNC
  21003. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21004. #endif
  21005. 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)
  21006. {
  21007. if (provider == null)
  21008. throw new ArgumentNullException("provider");
  21009. if (begin == null)
  21010. throw new ArgumentNullException("begin");
  21011. if (end == null)
  21012. throw new ArgumentNullException("end");
  21013. #if CRIPPLED_REFLECTION
  21014. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, AsyncCallback, object, IAsyncResult>>), default(Expression<Func<IAsyncResult, TResult>>)));
  21015. #else
  21016. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TResult));
  21017. #endif
  21018. return (t1, t2) => provider.CreateQuery<TResult>(
  21019. Expression.Invoke(
  21020. Expression.Call(
  21021. null,
  21022. m,
  21023. Expression.Constant(provider, typeof(IQbservableProvider)),
  21024. begin,
  21025. end
  21026. ),
  21027. Expression.Constant(t1, typeof(TArg1)),
  21028. Expression.Constant(t2, typeof(TArg2))
  21029. )
  21030. );
  21031. }
  21032. #if !NO_LARGEARITY
  21033. /// <summary>
  21034. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21035. /// </summary>
  21036. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21037. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21038. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21039. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21040. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21041. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21042. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21043. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21044. /// <exception cref="T:System.ArgumentNullException">
  21045. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21046. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  21047. #if PREFERASYNC
  21048. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21049. #endif
  21050. public static Func<TArg1, TArg2, TArg3, IQbservable<TResult>> FromAsyncPattern<TArg1, TArg2, TArg3, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, AsyncCallback, object, IAsyncResult>> begin, Expression<Func<IAsyncResult, TResult>>end)
  21051. {
  21052. if (provider == null)
  21053. throw new ArgumentNullException("provider");
  21054. if (begin == null)
  21055. throw new ArgumentNullException("begin");
  21056. if (end == null)
  21057. throw new ArgumentNullException("end");
  21058. #if CRIPPLED_REFLECTION
  21059. 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>>)));
  21060. #else
  21061. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TResult));
  21062. #endif
  21063. return (t1, t2, t3) => provider.CreateQuery<TResult>(
  21064. Expression.Invoke(
  21065. Expression.Call(
  21066. null,
  21067. m,
  21068. Expression.Constant(provider, typeof(IQbservableProvider)),
  21069. begin,
  21070. end
  21071. ),
  21072. Expression.Constant(t1, typeof(TArg1)),
  21073. Expression.Constant(t2, typeof(TArg2)),
  21074. Expression.Constant(t3, typeof(TArg3))
  21075. )
  21076. );
  21077. }
  21078. /// <summary>
  21079. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21080. /// </summary>
  21081. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21082. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21083. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21084. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21085. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21086. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21087. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21088. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21089. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21090. /// <exception cref="T:System.ArgumentNullException">
  21091. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21092. /// <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>
  21093. #if PREFERASYNC
  21094. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21095. #endif
  21096. 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)
  21097. {
  21098. if (provider == null)
  21099. throw new ArgumentNullException("provider");
  21100. if (begin == null)
  21101. throw new ArgumentNullException("begin");
  21102. if (end == null)
  21103. throw new ArgumentNullException("end");
  21104. #if CRIPPLED_REFLECTION
  21105. 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>>)));
  21106. #else
  21107. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TResult));
  21108. #endif
  21109. return (t1, t2, t3, t4) => provider.CreateQuery<TResult>(
  21110. Expression.Invoke(
  21111. Expression.Call(
  21112. null,
  21113. m,
  21114. Expression.Constant(provider, typeof(IQbservableProvider)),
  21115. begin,
  21116. end
  21117. ),
  21118. Expression.Constant(t1, typeof(TArg1)),
  21119. Expression.Constant(t2, typeof(TArg2)),
  21120. Expression.Constant(t3, typeof(TArg3)),
  21121. Expression.Constant(t4, typeof(TArg4))
  21122. )
  21123. );
  21124. }
  21125. /// <summary>
  21126. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21127. /// </summary>
  21128. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21129. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21130. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21131. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21132. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21133. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21134. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21135. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21136. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21137. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21138. /// <exception cref="T:System.ArgumentNullException">
  21139. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21140. /// <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>
  21141. #if PREFERASYNC
  21142. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21143. #endif
  21144. 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)
  21145. {
  21146. if (provider == null)
  21147. throw new ArgumentNullException("provider");
  21148. if (begin == null)
  21149. throw new ArgumentNullException("begin");
  21150. if (end == null)
  21151. throw new ArgumentNullException("end");
  21152. #if CRIPPLED_REFLECTION
  21153. 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>>)));
  21154. #else
  21155. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TResult));
  21156. #endif
  21157. return (t1, t2, t3, t4, t5) => provider.CreateQuery<TResult>(
  21158. Expression.Invoke(
  21159. Expression.Call(
  21160. null,
  21161. m,
  21162. Expression.Constant(provider, typeof(IQbservableProvider)),
  21163. begin,
  21164. end
  21165. ),
  21166. Expression.Constant(t1, typeof(TArg1)),
  21167. Expression.Constant(t2, typeof(TArg2)),
  21168. Expression.Constant(t3, typeof(TArg3)),
  21169. Expression.Constant(t4, typeof(TArg4)),
  21170. Expression.Constant(t5, typeof(TArg5))
  21171. )
  21172. );
  21173. }
  21174. /// <summary>
  21175. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21176. /// </summary>
  21177. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21178. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21179. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21180. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21181. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21182. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21183. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21184. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21185. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21186. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21187. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21188. /// <exception cref="T:System.ArgumentNullException">
  21189. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21190. /// <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>
  21191. #if PREFERASYNC
  21192. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21193. #endif
  21194. 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)
  21195. {
  21196. if (provider == null)
  21197. throw new ArgumentNullException("provider");
  21198. if (begin == null)
  21199. throw new ArgumentNullException("begin");
  21200. if (end == null)
  21201. throw new ArgumentNullException("end");
  21202. #if CRIPPLED_REFLECTION
  21203. 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>>)));
  21204. #else
  21205. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TResult));
  21206. #endif
  21207. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<TResult>(
  21208. Expression.Invoke(
  21209. Expression.Call(
  21210. null,
  21211. m,
  21212. Expression.Constant(provider, typeof(IQbservableProvider)),
  21213. begin,
  21214. end
  21215. ),
  21216. Expression.Constant(t1, typeof(TArg1)),
  21217. Expression.Constant(t2, typeof(TArg2)),
  21218. Expression.Constant(t3, typeof(TArg3)),
  21219. Expression.Constant(t4, typeof(TArg4)),
  21220. Expression.Constant(t5, typeof(TArg5)),
  21221. Expression.Constant(t6, typeof(TArg6))
  21222. )
  21223. );
  21224. }
  21225. /// <summary>
  21226. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21227. /// </summary>
  21228. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21229. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21230. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21231. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21232. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21233. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21234. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21235. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21236. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21237. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21238. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21239. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21240. /// <exception cref="T:System.ArgumentNullException">
  21241. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21242. /// <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>
  21243. #if PREFERASYNC
  21244. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21245. #endif
  21246. 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)
  21247. {
  21248. if (provider == null)
  21249. throw new ArgumentNullException("provider");
  21250. if (begin == null)
  21251. throw new ArgumentNullException("begin");
  21252. if (end == null)
  21253. throw new ArgumentNullException("end");
  21254. #if CRIPPLED_REFLECTION
  21255. 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>>)));
  21256. #else
  21257. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TResult));
  21258. #endif
  21259. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<TResult>(
  21260. Expression.Invoke(
  21261. Expression.Call(
  21262. null,
  21263. m,
  21264. Expression.Constant(provider, typeof(IQbservableProvider)),
  21265. begin,
  21266. end
  21267. ),
  21268. Expression.Constant(t1, typeof(TArg1)),
  21269. Expression.Constant(t2, typeof(TArg2)),
  21270. Expression.Constant(t3, typeof(TArg3)),
  21271. Expression.Constant(t4, typeof(TArg4)),
  21272. Expression.Constant(t5, typeof(TArg5)),
  21273. Expression.Constant(t6, typeof(TArg6)),
  21274. Expression.Constant(t7, typeof(TArg7))
  21275. )
  21276. );
  21277. }
  21278. /// <summary>
  21279. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21280. /// </summary>
  21281. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21282. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21283. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21284. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21285. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21286. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21287. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21288. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21289. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21290. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21291. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21292. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21293. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21294. /// <exception cref="T:System.ArgumentNullException">
  21295. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21296. /// <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>
  21297. #if PREFERASYNC
  21298. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21299. #endif
  21300. 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)
  21301. {
  21302. if (provider == null)
  21303. throw new ArgumentNullException("provider");
  21304. if (begin == null)
  21305. throw new ArgumentNullException("begin");
  21306. if (end == null)
  21307. throw new ArgumentNullException("end");
  21308. #if CRIPPLED_REFLECTION
  21309. 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>>)));
  21310. #else
  21311. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TResult));
  21312. #endif
  21313. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<TResult>(
  21314. Expression.Invoke(
  21315. Expression.Call(
  21316. null,
  21317. m,
  21318. Expression.Constant(provider, typeof(IQbservableProvider)),
  21319. begin,
  21320. end
  21321. ),
  21322. Expression.Constant(t1, typeof(TArg1)),
  21323. Expression.Constant(t2, typeof(TArg2)),
  21324. Expression.Constant(t3, typeof(TArg3)),
  21325. Expression.Constant(t4, typeof(TArg4)),
  21326. Expression.Constant(t5, typeof(TArg5)),
  21327. Expression.Constant(t6, typeof(TArg6)),
  21328. Expression.Constant(t7, typeof(TArg7)),
  21329. Expression.Constant(t8, typeof(TArg8))
  21330. )
  21331. );
  21332. }
  21333. /// <summary>
  21334. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21335. /// </summary>
  21336. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21337. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21338. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21339. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21340. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21341. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21342. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21343. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21344. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21345. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21346. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21347. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21348. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21349. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21350. /// <exception cref="T:System.ArgumentNullException">
  21351. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21352. /// <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>
  21353. #if PREFERASYNC
  21354. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21355. #endif
  21356. 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)
  21357. {
  21358. if (provider == null)
  21359. throw new ArgumentNullException("provider");
  21360. if (begin == null)
  21361. throw new ArgumentNullException("begin");
  21362. if (end == null)
  21363. throw new ArgumentNullException("end");
  21364. #if CRIPPLED_REFLECTION
  21365. 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>>)));
  21366. #else
  21367. 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));
  21368. #endif
  21369. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<TResult>(
  21370. Expression.Invoke(
  21371. Expression.Call(
  21372. null,
  21373. m,
  21374. Expression.Constant(provider, typeof(IQbservableProvider)),
  21375. begin,
  21376. end
  21377. ),
  21378. Expression.Constant(t1, typeof(TArg1)),
  21379. Expression.Constant(t2, typeof(TArg2)),
  21380. Expression.Constant(t3, typeof(TArg3)),
  21381. Expression.Constant(t4, typeof(TArg4)),
  21382. Expression.Constant(t5, typeof(TArg5)),
  21383. Expression.Constant(t6, typeof(TArg6)),
  21384. Expression.Constant(t7, typeof(TArg7)),
  21385. Expression.Constant(t8, typeof(TArg8)),
  21386. Expression.Constant(t9, typeof(TArg9))
  21387. )
  21388. );
  21389. }
  21390. /// <summary>
  21391. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21392. /// </summary>
  21393. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21394. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21395. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21396. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21397. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21398. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21399. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21400. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21401. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21402. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21403. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21404. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21405. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21406. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21407. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21408. /// <exception cref="T:System.ArgumentNullException">
  21409. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21410. /// <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>
  21411. #if PREFERASYNC
  21412. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21413. #endif
  21414. 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)
  21415. {
  21416. if (provider == null)
  21417. throw new ArgumentNullException("provider");
  21418. if (begin == null)
  21419. throw new ArgumentNullException("begin");
  21420. if (end == null)
  21421. throw new ArgumentNullException("end");
  21422. #if CRIPPLED_REFLECTION
  21423. 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>>)));
  21424. #else
  21425. 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));
  21426. #endif
  21427. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<TResult>(
  21428. Expression.Invoke(
  21429. Expression.Call(
  21430. null,
  21431. m,
  21432. Expression.Constant(provider, typeof(IQbservableProvider)),
  21433. begin,
  21434. end
  21435. ),
  21436. Expression.Constant(t1, typeof(TArg1)),
  21437. Expression.Constant(t2, typeof(TArg2)),
  21438. Expression.Constant(t3, typeof(TArg3)),
  21439. Expression.Constant(t4, typeof(TArg4)),
  21440. Expression.Constant(t5, typeof(TArg5)),
  21441. Expression.Constant(t6, typeof(TArg6)),
  21442. Expression.Constant(t7, typeof(TArg7)),
  21443. Expression.Constant(t8, typeof(TArg8)),
  21444. Expression.Constant(t9, typeof(TArg9)),
  21445. Expression.Constant(t10, typeof(TArg10))
  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 IQbservable&lt;T&gt; 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="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21459. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21460. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21461. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21462. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21463. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  21464. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21465. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21466. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21467. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21468. /// <exception cref="T:System.ArgumentNullException">
  21469. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21470. /// <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>
  21471. #if PREFERASYNC
  21472. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21473. #endif
  21474. 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)
  21475. {
  21476. if (provider == null)
  21477. throw new ArgumentNullException("provider");
  21478. if (begin == null)
  21479. throw new ArgumentNullException("begin");
  21480. if (end == null)
  21481. throw new ArgumentNullException("end");
  21482. #if CRIPPLED_REFLECTION
  21483. 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>>)));
  21484. #else
  21485. 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));
  21486. #endif
  21487. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<TResult>(
  21488. Expression.Invoke(
  21489. Expression.Call(
  21490. null,
  21491. m,
  21492. Expression.Constant(provider, typeof(IQbservableProvider)),
  21493. begin,
  21494. end
  21495. ),
  21496. Expression.Constant(t1, typeof(TArg1)),
  21497. Expression.Constant(t2, typeof(TArg2)),
  21498. Expression.Constant(t3, typeof(TArg3)),
  21499. Expression.Constant(t4, typeof(TArg4)),
  21500. Expression.Constant(t5, typeof(TArg5)),
  21501. Expression.Constant(t6, typeof(TArg6)),
  21502. Expression.Constant(t7, typeof(TArg7)),
  21503. Expression.Constant(t8, typeof(TArg8)),
  21504. Expression.Constant(t9, typeof(TArg9)),
  21505. Expression.Constant(t10, typeof(TArg10)),
  21506. Expression.Constant(t11, typeof(TArg11))
  21507. )
  21508. );
  21509. }
  21510. /// <summary>
  21511. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21512. /// </summary>
  21513. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21514. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21515. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21516. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21517. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21518. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21519. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21520. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21521. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21522. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21523. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21524. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  21525. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  21526. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21527. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21528. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21529. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21530. /// <exception cref="T:System.ArgumentNullException">
  21531. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21532. /// <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>
  21533. #if PREFERASYNC
  21534. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21535. #endif
  21536. 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)
  21537. {
  21538. if (provider == null)
  21539. throw new ArgumentNullException("provider");
  21540. if (begin == null)
  21541. throw new ArgumentNullException("begin");
  21542. if (end == null)
  21543. throw new ArgumentNullException("end");
  21544. #if CRIPPLED_REFLECTION
  21545. 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>>)));
  21546. #else
  21547. 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));
  21548. #endif
  21549. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<TResult>(
  21550. Expression.Invoke(
  21551. Expression.Call(
  21552. null,
  21553. m,
  21554. Expression.Constant(provider, typeof(IQbservableProvider)),
  21555. begin,
  21556. end
  21557. ),
  21558. Expression.Constant(t1, typeof(TArg1)),
  21559. Expression.Constant(t2, typeof(TArg2)),
  21560. Expression.Constant(t3, typeof(TArg3)),
  21561. Expression.Constant(t4, typeof(TArg4)),
  21562. Expression.Constant(t5, typeof(TArg5)),
  21563. Expression.Constant(t6, typeof(TArg6)),
  21564. Expression.Constant(t7, typeof(TArg7)),
  21565. Expression.Constant(t8, typeof(TArg8)),
  21566. Expression.Constant(t9, typeof(TArg9)),
  21567. Expression.Constant(t10, typeof(TArg10)),
  21568. Expression.Constant(t11, typeof(TArg11)),
  21569. Expression.Constant(t12, typeof(TArg12))
  21570. )
  21571. );
  21572. }
  21573. /// <summary>
  21574. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21575. /// </summary>
  21576. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21577. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21578. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21579. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21580. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21581. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21582. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21583. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21584. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21585. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21586. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21587. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  21588. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  21589. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the begin delegate.</typeparam>
  21590. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21591. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21592. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21593. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21594. /// <exception cref="T:System.ArgumentNullException">
  21595. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21596. /// <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>
  21597. #if PREFERASYNC
  21598. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21599. #endif
  21600. 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)
  21601. {
  21602. if (provider == null)
  21603. throw new ArgumentNullException("provider");
  21604. if (begin == null)
  21605. throw new ArgumentNullException("begin");
  21606. if (end == null)
  21607. throw new ArgumentNullException("end");
  21608. #if CRIPPLED_REFLECTION
  21609. 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>>)));
  21610. #else
  21611. 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));
  21612. #endif
  21613. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<TResult>(
  21614. Expression.Invoke(
  21615. Expression.Call(
  21616. null,
  21617. m,
  21618. Expression.Constant(provider, typeof(IQbservableProvider)),
  21619. begin,
  21620. end
  21621. ),
  21622. Expression.Constant(t1, typeof(TArg1)),
  21623. Expression.Constant(t2, typeof(TArg2)),
  21624. Expression.Constant(t3, typeof(TArg3)),
  21625. Expression.Constant(t4, typeof(TArg4)),
  21626. Expression.Constant(t5, typeof(TArg5)),
  21627. Expression.Constant(t6, typeof(TArg6)),
  21628. Expression.Constant(t7, typeof(TArg7)),
  21629. Expression.Constant(t8, typeof(TArg8)),
  21630. Expression.Constant(t9, typeof(TArg9)),
  21631. Expression.Constant(t10, typeof(TArg10)),
  21632. Expression.Constant(t11, typeof(TArg11)),
  21633. Expression.Constant(t12, typeof(TArg12)),
  21634. Expression.Constant(t13, typeof(TArg13))
  21635. )
  21636. );
  21637. }
  21638. /// <summary>
  21639. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21640. /// </summary>
  21641. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21642. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21643. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21644. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21645. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21646. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21647. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21648. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21649. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21650. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21651. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21652. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  21653. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  21654. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the begin delegate.</typeparam>
  21655. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the begin delegate.</typeparam>
  21656. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21657. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21658. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21659. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21660. /// <exception cref="T:System.ArgumentNullException">
  21661. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21662. /// <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>
  21663. #if PREFERASYNC
  21664. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21665. #endif
  21666. 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)
  21667. {
  21668. if (provider == null)
  21669. throw new ArgumentNullException("provider");
  21670. if (begin == null)
  21671. throw new ArgumentNullException("begin");
  21672. if (end == null)
  21673. throw new ArgumentNullException("end");
  21674. #if CRIPPLED_REFLECTION
  21675. 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>>)));
  21676. #else
  21677. 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));
  21678. #endif
  21679. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<TResult>(
  21680. Expression.Invoke(
  21681. Expression.Call(
  21682. null,
  21683. m,
  21684. Expression.Constant(provider, typeof(IQbservableProvider)),
  21685. begin,
  21686. end
  21687. ),
  21688. Expression.Constant(t1, typeof(TArg1)),
  21689. Expression.Constant(t2, typeof(TArg2)),
  21690. Expression.Constant(t3, typeof(TArg3)),
  21691. Expression.Constant(t4, typeof(TArg4)),
  21692. Expression.Constant(t5, typeof(TArg5)),
  21693. Expression.Constant(t6, typeof(TArg6)),
  21694. Expression.Constant(t7, typeof(TArg7)),
  21695. Expression.Constant(t8, typeof(TArg8)),
  21696. Expression.Constant(t9, typeof(TArg9)),
  21697. Expression.Constant(t10, typeof(TArg10)),
  21698. Expression.Constant(t11, typeof(TArg11)),
  21699. Expression.Constant(t12, typeof(TArg12)),
  21700. Expression.Constant(t13, typeof(TArg13)),
  21701. Expression.Constant(t14, typeof(TArg14))
  21702. )
  21703. );
  21704. }
  21705. #endif
  21706. }
  21707. }
  21708. #endif
  21709. #pragma warning restore 1591