Qbservable.Generated.cs 1.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886
  1. /*
  2. * WARNING: Auto-generated file (11/4/2013 11:19:06 AM)
  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 with the specified initial capacity according to a specified key selector function.
  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="capacity">The initial number of elements that the underlying dictionary can contain.</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" /> is null.</exception>
  7006. /// <exception cref="T:System.ArgumentOutOfRangeException">
  7007. /// <paramref name="capacity" /> is less than 0.</exception>
  7008. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, int capacity)
  7009. {
  7010. if (source == null)
  7011. throw new ArgumentNullException("source");
  7012. if (keySelector == null)
  7013. throw new ArgumentNullException("keySelector");
  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(int))),
  7019. #else
  7020. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  7021. #endif
  7022. source.Expression,
  7023. keySelector,
  7024. Expression.Constant(capacity, typeof(int))
  7025. )
  7026. );
  7027. }
  7028. /// <summary>
  7029. /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function and comparer.
  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. /// <param name="source">An observable sequence whose elements to group.</param>
  7034. /// <param name="keySelector">A function to extract the key for each element.</param>
  7035. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7036. /// <param name="comparer">An equality comparer to compare keys with.</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="comparer" /> is null.</exception>
  7040. /// <exception cref="T:System.ArgumentOutOfRangeException">
  7041. /// <paramref name="capacity" /> is less than 0.</exception>
  7042. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, int capacity, IEqualityComparer<TKey> comparer)
  7043. {
  7044. if (source == null)
  7045. throw new ArgumentNullException("source");
  7046. if (keySelector == null)
  7047. throw new ArgumentNullException("keySelector");
  7048. if (comparer == null)
  7049. throw new ArgumentNullException("comparer");
  7050. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7051. Expression.Call(
  7052. null,
  7053. #if CRIPPLED_REFLECTION
  7054. InfoOf(() => Qbservable.GroupBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(int), default(IEqualityComparer<TKey>))),
  7055. #else
  7056. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  7057. #endif
  7058. source.Expression,
  7059. keySelector,
  7060. Expression.Constant(capacity, typeof(int)),
  7061. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7062. )
  7063. );
  7064. }
  7065. /// <summary>
  7066. /// Groups the elements of an observable sequence according to a specified key selector function and comparer.
  7067. /// </summary>
  7068. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7069. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7070. /// <param name="source">An observable sequence whose elements to group.</param>
  7071. /// <param name="keySelector">A function to extract the key for each element.</param>
  7072. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7073. /// <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>
  7074. /// <exception cref="T:System.ArgumentNullException">
  7075. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  7076. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  7077. {
  7078. if (source == null)
  7079. throw new ArgumentNullException("source");
  7080. if (keySelector == null)
  7081. throw new ArgumentNullException("keySelector");
  7082. if (comparer == null)
  7083. throw new ArgumentNullException("comparer");
  7084. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7085. Expression.Call(
  7086. null,
  7087. #if CRIPPLED_REFLECTION
  7088. InfoOf(() => Qbservable.GroupBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IEqualityComparer<TKey>))),
  7089. #else
  7090. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  7091. #endif
  7092. source.Expression,
  7093. keySelector,
  7094. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7095. )
  7096. );
  7097. }
  7098. /// <summary>
  7099. /// Groups the elements of an observable sequence and selects the resulting elements by using a specified function.
  7100. /// </summary>
  7101. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7102. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7103. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7104. /// <param name="source">An observable sequence whose elements to group.</param>
  7105. /// <param name="keySelector">A function to extract the key for each element.</param>
  7106. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7107. /// <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>
  7108. /// <exception cref="T:System.ArgumentNullException">
  7109. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> is null.</exception>
  7110. public static IQbservable<IGroupedObservable<TKey, TElement>> GroupBy<TSource, TKey, TElement>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector)
  7111. {
  7112. if (source == null)
  7113. throw new ArgumentNullException("source");
  7114. if (keySelector == null)
  7115. throw new ArgumentNullException("keySelector");
  7116. if (elementSelector == null)
  7117. throw new ArgumentNullException("elementSelector");
  7118. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7119. Expression.Call(
  7120. null,
  7121. #if CRIPPLED_REFLECTION
  7122. InfoOf(() => Qbservable.GroupBy<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>))),
  7123. #else
  7124. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  7125. #endif
  7126. source.Expression,
  7127. keySelector,
  7128. elementSelector
  7129. )
  7130. );
  7131. }
  7132. /// <summary>
  7133. /// Groups the elements of an observable sequence with the specified initial capacity and selects the resulting elements by using a specified function.
  7134. /// </summary>
  7135. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7136. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7137. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7138. /// <param name="source">An observable sequence whose elements to group.</param>
  7139. /// <param name="keySelector">A function to extract the key for each element.</param>
  7140. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7141. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7142. /// <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>
  7143. /// <exception cref="T:System.ArgumentNullException">
  7144. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> is null.</exception>
  7145. /// <exception cref="T:System.ArgumentOutOfRangeException">
  7146. /// <paramref name="capacity" /> is less than 0.</exception>
  7147. public static IQbservable<IGroupedObservable<TKey, TElement>> GroupBy<TSource, TKey, TElement>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector, int capacity)
  7148. {
  7149. if (source == null)
  7150. throw new ArgumentNullException("source");
  7151. if (keySelector == null)
  7152. throw new ArgumentNullException("keySelector");
  7153. if (elementSelector == null)
  7154. throw new ArgumentNullException("elementSelector");
  7155. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7156. Expression.Call(
  7157. null,
  7158. #if CRIPPLED_REFLECTION
  7159. InfoOf(() => Qbservable.GroupBy<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(int))),
  7160. #else
  7161. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  7162. #endif
  7163. source.Expression,
  7164. keySelector,
  7165. elementSelector,
  7166. Expression.Constant(capacity, typeof(int))
  7167. )
  7168. );
  7169. }
  7170. /// <summary>
  7171. /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function and comparer and selects the resulting elements by using a specified function.
  7172. /// </summary>
  7173. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7174. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7175. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7176. /// <param name="source">An observable sequence whose elements to group.</param>
  7177. /// <param name="keySelector">A function to extract the key for each element.</param>
  7178. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7179. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7180. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7181. /// <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>
  7182. /// <exception cref="T:System.ArgumentNullException">
  7183. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="comparer" /> is null.</exception>
  7184. /// <exception cref="T:System.ArgumentOutOfRangeException">
  7185. /// <paramref name="capacity" /> is less than 0.</exception>
  7186. public static IQbservable<IGroupedObservable<TKey, TElement>> GroupBy<TSource, TKey, TElement>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector, int capacity, IEqualityComparer<TKey> comparer)
  7187. {
  7188. if (source == null)
  7189. throw new ArgumentNullException("source");
  7190. if (keySelector == null)
  7191. throw new ArgumentNullException("keySelector");
  7192. if (elementSelector == null)
  7193. throw new ArgumentNullException("elementSelector");
  7194. if (comparer == null)
  7195. throw new ArgumentNullException("comparer");
  7196. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7197. Expression.Call(
  7198. null,
  7199. #if CRIPPLED_REFLECTION
  7200. InfoOf(() => Qbservable.GroupBy<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(int), default(IEqualityComparer<TKey>))),
  7201. #else
  7202. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  7203. #endif
  7204. source.Expression,
  7205. keySelector,
  7206. elementSelector,
  7207. Expression.Constant(capacity, typeof(int)),
  7208. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7209. )
  7210. );
  7211. }
  7212. /// <summary>
  7213. /// 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.
  7214. /// </summary>
  7215. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7216. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7217. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7218. /// <param name="source">An observable sequence whose elements to group.</param>
  7219. /// <param name="keySelector">A function to extract the key for each element.</param>
  7220. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7221. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7222. /// <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>
  7223. /// <exception cref="T:System.ArgumentNullException">
  7224. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="comparer" /> is null.</exception>
  7225. 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)
  7226. {
  7227. if (source == null)
  7228. throw new ArgumentNullException("source");
  7229. if (keySelector == null)
  7230. throw new ArgumentNullException("keySelector");
  7231. if (elementSelector == null)
  7232. throw new ArgumentNullException("elementSelector");
  7233. if (comparer == null)
  7234. throw new ArgumentNullException("comparer");
  7235. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7236. Expression.Call(
  7237. null,
  7238. #if CRIPPLED_REFLECTION
  7239. InfoOf(() => Qbservable.GroupBy<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(IEqualityComparer<TKey>))),
  7240. #else
  7241. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  7242. #endif
  7243. source.Expression,
  7244. keySelector,
  7245. elementSelector,
  7246. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7247. )
  7248. );
  7249. }
  7250. /// <summary>
  7251. /// Groups the elements of an observable sequence according to a specified key selector function.
  7252. /// 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
  7253. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7254. /// </summary>
  7255. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7256. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7257. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7258. /// <param name="source">An observable sequence whose elements to group.</param>
  7259. /// <param name="keySelector">A function to extract the key for each element.</param>
  7260. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7261. /// <returns>
  7262. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7263. /// 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.
  7264. /// </returns>
  7265. /// <exception cref="T:System.ArgumentNullException">
  7266. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="durationSelector" /> is null.</exception>
  7267. 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)
  7268. {
  7269. if (source == null)
  7270. throw new ArgumentNullException("source");
  7271. if (keySelector == null)
  7272. throw new ArgumentNullException("keySelector");
  7273. if (durationSelector == null)
  7274. throw new ArgumentNullException("durationSelector");
  7275. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7276. Expression.Call(
  7277. null,
  7278. #if CRIPPLED_REFLECTION
  7279. InfoOf(() => Qbservable.GroupByUntil<TSource, TKey, TDuration>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<IGroupedObservable<TKey, TSource>, IObservable<TDuration>>>))),
  7280. #else
  7281. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TDuration)),
  7282. #endif
  7283. source.Expression,
  7284. keySelector,
  7285. durationSelector
  7286. )
  7287. );
  7288. }
  7289. /// <summary>
  7290. /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function.
  7291. /// 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
  7292. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7293. /// </summary>
  7294. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7295. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7296. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7297. /// <param name="source">An observable sequence whose elements to group.</param>
  7298. /// <param name="keySelector">A function to extract the key for each element.</param>
  7299. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7300. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7301. /// <returns>
  7302. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7303. /// If a group's lifetime expires, a new group with the same key value can be created once an element with such a key value is encoutered.
  7304. /// </returns>
  7305. /// <exception cref="T:System.ArgumentNullException">
  7306. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="durationSelector" /> is null.</exception>
  7307. /// <exception cref="T:System.ArgumentOutOfRangeException">
  7308. /// <paramref name="capacity" /> is less than 0.</exception>
  7309. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupByUntil<TSource, TKey, TDuration>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<IGroupedObservable<TKey, TSource>, IObservable<TDuration>>> durationSelector, int capacity)
  7310. {
  7311. if (source == null)
  7312. throw new ArgumentNullException("source");
  7313. if (keySelector == null)
  7314. throw new ArgumentNullException("keySelector");
  7315. if (durationSelector == null)
  7316. throw new ArgumentNullException("durationSelector");
  7317. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7318. Expression.Call(
  7319. null,
  7320. #if CRIPPLED_REFLECTION
  7321. InfoOf(() => Qbservable.GroupByUntil<TSource, TKey, TDuration>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<IGroupedObservable<TKey, TSource>, IObservable<TDuration>>>), default(int))),
  7322. #else
  7323. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TDuration)),
  7324. #endif
  7325. source.Expression,
  7326. keySelector,
  7327. durationSelector,
  7328. Expression.Constant(capacity, typeof(int))
  7329. )
  7330. );
  7331. }
  7332. /// <summary>
  7333. /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function and comparer.
  7334. /// 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
  7335. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7336. /// </summary>
  7337. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7338. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7339. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7340. /// <param name="source">An observable sequence whose elements to group.</param>
  7341. /// <param name="keySelector">A function to extract the key for each element.</param>
  7342. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7343. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7344. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7345. /// <returns>
  7346. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7347. /// 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.
  7348. /// </returns>
  7349. /// <exception cref="T:System.ArgumentNullException">
  7350. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="durationSelector" /> or <paramref name="comparer" /> is null.</exception>
  7351. /// <exception cref="T:System.ArgumentOutOfRangeException">
  7352. /// <paramref name="capacity" /> is less than 0.</exception>
  7353. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupByUntil<TSource, TKey, TDuration>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<IGroupedObservable<TKey, TSource>, IObservable<TDuration>>> durationSelector, int capacity, IEqualityComparer<TKey> comparer)
  7354. {
  7355. if (source == null)
  7356. throw new ArgumentNullException("source");
  7357. if (keySelector == null)
  7358. throw new ArgumentNullException("keySelector");
  7359. if (durationSelector == null)
  7360. throw new ArgumentNullException("durationSelector");
  7361. if (comparer == null)
  7362. throw new ArgumentNullException("comparer");
  7363. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7364. Expression.Call(
  7365. null,
  7366. #if CRIPPLED_REFLECTION
  7367. InfoOf(() => Qbservable.GroupByUntil<TSource, TKey, TDuration>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<IGroupedObservable<TKey, TSource>, IObservable<TDuration>>>), default(int), default(IEqualityComparer<TKey>))),
  7368. #else
  7369. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TDuration)),
  7370. #endif
  7371. source.Expression,
  7372. keySelector,
  7373. durationSelector,
  7374. Expression.Constant(capacity, typeof(int)),
  7375. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7376. )
  7377. );
  7378. }
  7379. /// <summary>
  7380. /// Groups the elements of an observable sequence according to a specified key selector function and comparer.
  7381. /// 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
  7382. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7383. /// </summary>
  7384. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7385. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7386. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7387. /// <param name="source">An observable sequence whose elements to group.</param>
  7388. /// <param name="keySelector">A function to extract the key for each element.</param>
  7389. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7390. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7391. /// <returns>
  7392. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7393. /// 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.
  7394. /// </returns>
  7395. /// <exception cref="T:System.ArgumentNullException">
  7396. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="durationSelector" /> or <paramref name="comparer" /> is null.</exception>
  7397. 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)
  7398. {
  7399. if (source == null)
  7400. throw new ArgumentNullException("source");
  7401. if (keySelector == null)
  7402. throw new ArgumentNullException("keySelector");
  7403. if (durationSelector == null)
  7404. throw new ArgumentNullException("durationSelector");
  7405. if (comparer == null)
  7406. throw new ArgumentNullException("comparer");
  7407. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7408. Expression.Call(
  7409. null,
  7410. #if CRIPPLED_REFLECTION
  7411. 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>))),
  7412. #else
  7413. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TDuration)),
  7414. #endif
  7415. source.Expression,
  7416. keySelector,
  7417. durationSelector,
  7418. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7419. )
  7420. );
  7421. }
  7422. /// <summary>
  7423. /// Groups the elements of an observable sequence according to a specified key selector function and selects the resulting elements by using a specified function.
  7424. /// 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
  7425. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7426. /// </summary>
  7427. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7428. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7429. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7430. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7431. /// <param name="source">An observable sequence whose elements to group.</param>
  7432. /// <param name="keySelector">A function to extract the key for each element.</param>
  7433. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7434. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7435. /// <returns>
  7436. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7437. /// 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.
  7438. /// </returns>
  7439. /// <exception cref="T:System.ArgumentNullException">
  7440. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="durationSelector" /> is null.</exception>
  7441. 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)
  7442. {
  7443. if (source == null)
  7444. throw new ArgumentNullException("source");
  7445. if (keySelector == null)
  7446. throw new ArgumentNullException("keySelector");
  7447. if (elementSelector == null)
  7448. throw new ArgumentNullException("elementSelector");
  7449. if (durationSelector == null)
  7450. throw new ArgumentNullException("durationSelector");
  7451. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7452. Expression.Call(
  7453. null,
  7454. #if CRIPPLED_REFLECTION
  7455. 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>>>))),
  7456. #else
  7457. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TDuration)),
  7458. #endif
  7459. source.Expression,
  7460. keySelector,
  7461. elementSelector,
  7462. durationSelector
  7463. )
  7464. );
  7465. }
  7466. /// <summary>
  7467. /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function and selects the resulting elements by using a specified function.
  7468. /// 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
  7469. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7470. /// </summary>
  7471. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7472. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7473. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7474. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7475. /// <param name="source">An observable sequence whose elements to group.</param>
  7476. /// <param name="keySelector">A function to extract the key for each element.</param>
  7477. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7478. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7479. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7480. /// <returns>
  7481. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7482. /// 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.
  7483. /// </returns>
  7484. /// <exception cref="T:System.ArgumentNullException">
  7485. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="durationSelector" /> is null.</exception>
  7486. /// <exception cref="T:System.ArgumentOutOfRangeException">
  7487. /// <paramref name="capacity" /> is less than 0.</exception>
  7488. public static IQbservable<IGroupedObservable<TKey, TElement>> GroupByUntil<TSource, TKey, TElement, TDuration>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector, Expression<Func<IGroupedObservable<TKey, TElement>, IObservable<TDuration>>> durationSelector, int capacity)
  7489. {
  7490. if (source == null)
  7491. throw new ArgumentNullException("source");
  7492. if (keySelector == null)
  7493. throw new ArgumentNullException("keySelector");
  7494. if (elementSelector == null)
  7495. throw new ArgumentNullException("elementSelector");
  7496. if (durationSelector == null)
  7497. throw new ArgumentNullException("durationSelector");
  7498. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7499. Expression.Call(
  7500. null,
  7501. #if CRIPPLED_REFLECTION
  7502. InfoOf(() => Qbservable.GroupByUntil<TSource, TKey, TElement, TDuration>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(Expression<Func<IGroupedObservable<TKey, TElement>, IObservable<TDuration>>>), default(int))),
  7503. #else
  7504. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TDuration)),
  7505. #endif
  7506. source.Expression,
  7507. keySelector,
  7508. elementSelector,
  7509. durationSelector,
  7510. Expression.Constant(capacity, typeof(int))
  7511. )
  7512. );
  7513. }
  7514. /// <summary>
  7515. /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function and comparer and selects the resulting elements by using a specified function.
  7516. /// 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
  7517. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7518. /// </summary>
  7519. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7520. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7521. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7522. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7523. /// <param name="source">An observable sequence whose elements to group.</param>
  7524. /// <param name="keySelector">A function to extract the key for each element.</param>
  7525. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7526. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7527. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7528. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7529. /// <returns>
  7530. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7531. /// 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.
  7532. /// </returns>
  7533. /// <exception cref="T:System.ArgumentNullException">
  7534. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="durationSelector" /> or <paramref name="comparer" /> is null.</exception>
  7535. /// <exception cref="T:System.ArgumentOutOfRangeException">
  7536. /// <paramref name="capacity" /> is less than 0.</exception>
  7537. public static IQbservable<IGroupedObservable<TKey, TElement>> GroupByUntil<TSource, TKey, TElement, TDuration>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector, Expression<Func<IGroupedObservable<TKey, TElement>, IObservable<TDuration>>> durationSelector, int capacity, IEqualityComparer<TKey> comparer)
  7538. {
  7539. if (source == null)
  7540. throw new ArgumentNullException("source");
  7541. if (keySelector == null)
  7542. throw new ArgumentNullException("keySelector");
  7543. if (elementSelector == null)
  7544. throw new ArgumentNullException("elementSelector");
  7545. if (durationSelector == null)
  7546. throw new ArgumentNullException("durationSelector");
  7547. if (comparer == null)
  7548. throw new ArgumentNullException("comparer");
  7549. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7550. Expression.Call(
  7551. null,
  7552. #if CRIPPLED_REFLECTION
  7553. InfoOf(() => Qbservable.GroupByUntil<TSource, TKey, TElement, TDuration>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(Expression<Func<IGroupedObservable<TKey, TElement>, IObservable<TDuration>>>), default(int), default(IEqualityComparer<TKey>))),
  7554. #else
  7555. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TDuration)),
  7556. #endif
  7557. source.Expression,
  7558. keySelector,
  7559. elementSelector,
  7560. durationSelector,
  7561. Expression.Constant(capacity, typeof(int)),
  7562. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7563. )
  7564. );
  7565. }
  7566. /// <summary>
  7567. /// 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.
  7568. /// 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
  7569. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7570. /// </summary>
  7571. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7572. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7573. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7574. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7575. /// <param name="source">An observable sequence whose elements to group.</param>
  7576. /// <param name="keySelector">A function to extract the key for each element.</param>
  7577. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7578. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7579. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7580. /// <returns>
  7581. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7582. /// 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.
  7583. /// </returns>
  7584. /// <exception cref="T:System.ArgumentNullException">
  7585. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="durationSelector" /> or <paramref name="comparer" /> is null.</exception>
  7586. 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)
  7587. {
  7588. if (source == null)
  7589. throw new ArgumentNullException("source");
  7590. if (keySelector == null)
  7591. throw new ArgumentNullException("keySelector");
  7592. if (elementSelector == null)
  7593. throw new ArgumentNullException("elementSelector");
  7594. if (durationSelector == null)
  7595. throw new ArgumentNullException("durationSelector");
  7596. if (comparer == null)
  7597. throw new ArgumentNullException("comparer");
  7598. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7599. Expression.Call(
  7600. null,
  7601. #if CRIPPLED_REFLECTION
  7602. 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>))),
  7603. #else
  7604. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TDuration)),
  7605. #endif
  7606. source.Expression,
  7607. keySelector,
  7608. elementSelector,
  7609. durationSelector,
  7610. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7611. )
  7612. );
  7613. }
  7614. /// <summary>
  7615. /// Correlates the elements of two sequences based on overlapping durations, and groups the results.
  7616. /// </summary>
  7617. /// <typeparam name="TLeft">The type of the elements in the left source sequence.</typeparam>
  7618. /// <typeparam name="TRight">The type of the elements in the right source sequence.</typeparam>
  7619. /// <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>
  7620. /// <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>
  7621. /// <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>
  7622. /// <param name="left">The left observable sequence to join elements for.</param>
  7623. /// <param name="right">The right observable sequence to join elements for.</param>
  7624. /// <param name="leftDurationSelector">A function to select the duration of each element of the left observable sequence, used to determine overlap.</param>
  7625. /// <param name="rightDurationSelector">A function to select the duration of each element of the right observable sequence, used to determine overlap.</param>
  7626. /// <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>
  7627. /// <returns>An observable sequence that contains result elements computed from source elements that have an overlapping duration.</returns>
  7628. /// <exception cref="T:System.ArgumentNullException">
  7629. /// <paramref name="left" /> or <paramref name="right" /> or <paramref name="leftDurationSelector" /> or <paramref name="rightDurationSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  7630. 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)
  7631. {
  7632. if (left == null)
  7633. throw new ArgumentNullException("left");
  7634. if (right == null)
  7635. throw new ArgumentNullException("right");
  7636. if (leftDurationSelector == null)
  7637. throw new ArgumentNullException("leftDurationSelector");
  7638. if (rightDurationSelector == null)
  7639. throw new ArgumentNullException("rightDurationSelector");
  7640. if (resultSelector == null)
  7641. throw new ArgumentNullException("resultSelector");
  7642. return left.Provider.CreateQuery<TResult>(
  7643. Expression.Call(
  7644. null,
  7645. #if CRIPPLED_REFLECTION
  7646. 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>>))),
  7647. #else
  7648. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TLeft), typeof(TRight), typeof(TLeftDuration), typeof(TRightDuration), typeof(TResult)),
  7649. #endif
  7650. left.Expression,
  7651. GetSourceExpression(right),
  7652. leftDurationSelector,
  7653. rightDurationSelector,
  7654. resultSelector
  7655. )
  7656. );
  7657. }
  7658. /// <summary>
  7659. /// If the specified <paramref name="condition" /> evaluates true, select the <paramref name="thenSource" /> sequence. Otherwise, return an empty sequence.
  7660. /// </summary>
  7661. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  7662. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  7663. /// <param name="condition">Condition evaluated to decide which sequence to return.</param>
  7664. /// <param name="thenSource">Sequence returned in case <paramref name="condition" /> evaluates true.</param>
  7665. /// <returns>
  7666. /// <paramref name="thenSource" /> if <paramref name="condition" /> evaluates true; an empty sequence otherwise.</returns>
  7667. /// <exception cref="T:System.ArgumentNullException">
  7668. /// <paramref name="condition" /> or <paramref name="thenSource" /> is null.</exception>
  7669. public static IQbservable<TResult> If<TResult>(this IQbservableProvider provider, Expression<Func<bool>> condition, IObservable<TResult> thenSource)
  7670. {
  7671. if (provider == null)
  7672. throw new ArgumentNullException("provider");
  7673. if (condition == null)
  7674. throw new ArgumentNullException("condition");
  7675. if (thenSource == null)
  7676. throw new ArgumentNullException("thenSource");
  7677. return provider.CreateQuery<TResult>(
  7678. Expression.Call(
  7679. null,
  7680. #if CRIPPLED_REFLECTION
  7681. InfoOf(() => Qbservable.If<TResult>(default(IQbservableProvider), default(Expression<Func<bool>>), default(IObservable<TResult>))),
  7682. #else
  7683. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  7684. #endif
  7685. Expression.Constant(provider, typeof(IQbservableProvider)),
  7686. condition,
  7687. GetSourceExpression(thenSource)
  7688. )
  7689. );
  7690. }
  7691. /// <summary>
  7692. /// If the specified <paramref name="condition" /> evaluates true, select the <paramref name="thenSource" /> sequence. Otherwise, select the <paramref name="elseSource" /> sequence.
  7693. /// </summary>
  7694. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  7695. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  7696. /// <param name="condition">Condition evaluated to decide which sequence to return.</param>
  7697. /// <param name="thenSource">Sequence returned in case <paramref name="condition" /> evaluates true.</param>
  7698. /// <param name="elseSource">Sequence returned in case <paramref name="condition" /> evaluates false.</param>
  7699. /// <returns>
  7700. /// <paramref name="thenSource" /> if <paramref name="condition" /> evaluates true; <paramref name="elseSource" /> otherwise.</returns>
  7701. /// <exception cref="T:System.ArgumentNullException">
  7702. /// <paramref name="condition" /> or <paramref name="thenSource" /> or <paramref name="elseSource" /> is null.</exception>
  7703. public static IQbservable<TResult> If<TResult>(this IQbservableProvider provider, Expression<Func<bool>> condition, IObservable<TResult> thenSource, IObservable<TResult> elseSource)
  7704. {
  7705. if (provider == null)
  7706. throw new ArgumentNullException("provider");
  7707. if (condition == null)
  7708. throw new ArgumentNullException("condition");
  7709. if (thenSource == null)
  7710. throw new ArgumentNullException("thenSource");
  7711. if (elseSource == null)
  7712. throw new ArgumentNullException("elseSource");
  7713. return provider.CreateQuery<TResult>(
  7714. Expression.Call(
  7715. null,
  7716. #if CRIPPLED_REFLECTION
  7717. InfoOf(() => Qbservable.If<TResult>(default(IQbservableProvider), default(Expression<Func<bool>>), default(IObservable<TResult>), default(IObservable<TResult>))),
  7718. #else
  7719. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  7720. #endif
  7721. Expression.Constant(provider, typeof(IQbservableProvider)),
  7722. condition,
  7723. GetSourceExpression(thenSource),
  7724. GetSourceExpression(elseSource)
  7725. )
  7726. );
  7727. }
  7728. /// <summary>
  7729. /// If the specified <paramref name="condition" /> evaluates true, select the <paramref name="thenSource" /> sequence. Otherwise, return an empty sequence generated on the specified scheduler.
  7730. /// </summary>
  7731. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  7732. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  7733. /// <param name="condition">Condition evaluated to decide which sequence to return.</param>
  7734. /// <param name="thenSource">Sequence returned in case <paramref name="condition" /> evaluates true.</param>
  7735. /// <param name="scheduler">Scheduler to generate an empty sequence on in case <paramref name="condition" /> evaluates false.</param>
  7736. /// <returns>
  7737. /// <paramref name="thenSource" /> if <paramref name="condition" /> evaluates true; an empty sequence otherwise.</returns>
  7738. /// <exception cref="T:System.ArgumentNullException">
  7739. /// <paramref name="condition" /> or <paramref name="thenSource" /> or <paramref name="scheduler" /> is null.</exception>
  7740. public static IQbservable<TResult> If<TResult>(this IQbservableProvider provider, Expression<Func<bool>> condition, IObservable<TResult> thenSource, IScheduler scheduler)
  7741. {
  7742. if (provider == null)
  7743. throw new ArgumentNullException("provider");
  7744. if (condition == null)
  7745. throw new ArgumentNullException("condition");
  7746. if (thenSource == null)
  7747. throw new ArgumentNullException("thenSource");
  7748. if (scheduler == null)
  7749. throw new ArgumentNullException("scheduler");
  7750. return provider.CreateQuery<TResult>(
  7751. Expression.Call(
  7752. null,
  7753. #if CRIPPLED_REFLECTION
  7754. InfoOf(() => Qbservable.If<TResult>(default(IQbservableProvider), default(Expression<Func<bool>>), default(IObservable<TResult>), default(IScheduler))),
  7755. #else
  7756. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  7757. #endif
  7758. Expression.Constant(provider, typeof(IQbservableProvider)),
  7759. condition,
  7760. GetSourceExpression(thenSource),
  7761. Expression.Constant(scheduler, typeof(IScheduler))
  7762. )
  7763. );
  7764. }
  7765. /// <summary>
  7766. /// Ignores all elements in an observable sequence leaving only the termination messages.
  7767. /// </summary>
  7768. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7769. /// <param name="source">Source sequence.</param>
  7770. /// <returns>An empty observable sequence that signals termination, successful or exceptional, of the source sequence.</returns>
  7771. /// <exception cref="T:System.ArgumentNullException">
  7772. /// <paramref name="source" /> is null.</exception>
  7773. public static IQbservable<TSource> IgnoreElements<TSource>(this IQbservable<TSource> source)
  7774. {
  7775. if (source == null)
  7776. throw new ArgumentNullException("source");
  7777. return source.Provider.CreateQuery<TSource>(
  7778. Expression.Call(
  7779. null,
  7780. #if CRIPPLED_REFLECTION
  7781. InfoOf(() => Qbservable.IgnoreElements<TSource>(default(IQbservable<TSource>))),
  7782. #else
  7783. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7784. #endif
  7785. source.Expression
  7786. )
  7787. );
  7788. }
  7789. /// <summary>
  7790. /// Returns an observable sequence that produces a value after each period.
  7791. /// </summary>
  7792. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  7793. /// <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>
  7794. /// <returns>An observable sequence that produces a value after each period.</returns>
  7795. /// <exception cref="T:System.ArgumentOutOfRangeException">
  7796. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  7797. /// <remarks>
  7798. /// Intervals are measured between the start of subsequent notifications, not between the end of the previous and the start of the next notification.
  7799. /// If the observer takes longer than the interval period to handle the message, the subsequent notification will be delivered immediately after the
  7800. /// 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
  7801. /// <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})" />
  7802. /// operator instead.
  7803. /// </remarks>
  7804. public static IQbservable<long> Interval(this IQbservableProvider provider, TimeSpan period)
  7805. {
  7806. if (provider == null)
  7807. throw new ArgumentNullException("provider");
  7808. return provider.CreateQuery<long>(
  7809. Expression.Call(
  7810. null,
  7811. #if CRIPPLED_REFLECTION
  7812. InfoOf(() => Qbservable.Interval(default(IQbservableProvider), default(TimeSpan))),
  7813. #else
  7814. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7815. #endif
  7816. Expression.Constant(provider, typeof(IQbservableProvider)),
  7817. Expression.Constant(period, typeof(TimeSpan))
  7818. )
  7819. );
  7820. }
  7821. /// <summary>
  7822. /// Returns an observable sequence that produces a value after each period, using the specified scheduler to run timers and to send out observer messages.
  7823. /// </summary>
  7824. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  7825. /// <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>
  7826. /// <param name="scheduler">Scheduler to run the timer on.</param>
  7827. /// <returns>An observable sequence that produces a value after each period.</returns>
  7828. /// <exception cref="T:System.ArgumentOutOfRangeException">
  7829. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  7830. /// <exception cref="T:System.ArgumentNullException">
  7831. /// <paramref name="scheduler" /> is null.</exception>
  7832. /// <remarks>
  7833. /// Intervals are measured between the start of subsequent notifications, not between the end of the previous and the start of the next notification.
  7834. /// If the observer takes longer than the interval period to handle the message, the subsequent notification will be delivered immediately after the
  7835. /// 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
  7836. /// <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)" />
  7837. /// operator instead.
  7838. /// </remarks>
  7839. public static IQbservable<long> Interval(this IQbservableProvider provider, TimeSpan period, IScheduler scheduler)
  7840. {
  7841. if (provider == null)
  7842. throw new ArgumentNullException("provider");
  7843. if (scheduler == null)
  7844. throw new ArgumentNullException("scheduler");
  7845. return provider.CreateQuery<long>(
  7846. Expression.Call(
  7847. null,
  7848. #if CRIPPLED_REFLECTION
  7849. InfoOf(() => Qbservable.Interval(default(IQbservableProvider), default(TimeSpan), default(IScheduler))),
  7850. #else
  7851. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7852. #endif
  7853. Expression.Constant(provider, typeof(IQbservableProvider)),
  7854. Expression.Constant(period, typeof(TimeSpan)),
  7855. Expression.Constant(scheduler, typeof(IScheduler))
  7856. )
  7857. );
  7858. }
  7859. /// <summary>
  7860. /// Determines whether an observable sequence is empty.
  7861. /// </summary>
  7862. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7863. /// <param name="source">An observable sequence to check for emptiness.</param>
  7864. /// <returns>An observable sequence containing a single element determining whether the source sequence is empty.</returns>
  7865. /// <exception cref="T:System.ArgumentNullException">
  7866. /// <paramref name="source" /> is null.</exception>
  7867. public static IQbservable<bool> IsEmpty<TSource>(this IQbservable<TSource> source)
  7868. {
  7869. if (source == null)
  7870. throw new ArgumentNullException("source");
  7871. return source.Provider.CreateQuery<bool>(
  7872. Expression.Call(
  7873. null,
  7874. #if CRIPPLED_REFLECTION
  7875. InfoOf(() => Qbservable.IsEmpty<TSource>(default(IQbservable<TSource>))),
  7876. #else
  7877. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7878. #endif
  7879. source.Expression
  7880. )
  7881. );
  7882. }
  7883. /// <summary>
  7884. /// Correlates the elements of two sequences based on overlapping durations.
  7885. /// </summary>
  7886. /// <typeparam name="TLeft">The type of the elements in the left source sequence.</typeparam>
  7887. /// <typeparam name="TRight">The type of the elements in the right source sequence.</typeparam>
  7888. /// <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>
  7889. /// <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>
  7890. /// <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>
  7891. /// <param name="left">The left observable sequence to join elements for.</param>
  7892. /// <param name="right">The right observable sequence to join elements for.</param>
  7893. /// <param name="leftDurationSelector">A function to select the duration of each element of the left observable sequence, used to determine overlap.</param>
  7894. /// <param name="rightDurationSelector">A function to select the duration of each element of the right observable sequence, used to determine overlap.</param>
  7895. /// <param name="resultSelector">A function invoked to compute a result element for any two overlapping elements of the left and right observable sequences.</param>
  7896. /// <returns>An observable sequence that contains result elements computed from source elements that have an overlapping duration.</returns>
  7897. /// <exception cref="T:System.ArgumentNullException">
  7898. /// <paramref name="left" /> or <paramref name="right" /> or <paramref name="leftDurationSelector" /> or <paramref name="rightDurationSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  7899. 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)
  7900. {
  7901. if (left == null)
  7902. throw new ArgumentNullException("left");
  7903. if (right == null)
  7904. throw new ArgumentNullException("right");
  7905. if (leftDurationSelector == null)
  7906. throw new ArgumentNullException("leftDurationSelector");
  7907. if (rightDurationSelector == null)
  7908. throw new ArgumentNullException("rightDurationSelector");
  7909. if (resultSelector == null)
  7910. throw new ArgumentNullException("resultSelector");
  7911. return left.Provider.CreateQuery<TResult>(
  7912. Expression.Call(
  7913. null,
  7914. #if CRIPPLED_REFLECTION
  7915. 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>>))),
  7916. #else
  7917. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TLeft), typeof(TRight), typeof(TLeftDuration), typeof(TRightDuration), typeof(TResult)),
  7918. #endif
  7919. left.Expression,
  7920. GetSourceExpression(right),
  7921. leftDurationSelector,
  7922. rightDurationSelector,
  7923. resultSelector
  7924. )
  7925. );
  7926. }
  7927. /// <summary>
  7928. /// Returns the last element of an observable sequence.
  7929. /// </summary>
  7930. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7931. /// <param name="source">Source observable sequence.</param>
  7932. /// <returns>Sequence containing the last element in the observable sequence.</returns>
  7933. /// <exception cref="T:System.ArgumentNullException">
  7934. /// <paramref name="source" /> is null.</exception>
  7935. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  7936. public static IQbservable<TSource> LastAsync<TSource>(this IQbservable<TSource> source)
  7937. {
  7938. if (source == null)
  7939. throw new ArgumentNullException("source");
  7940. return source.Provider.CreateQuery<TSource>(
  7941. Expression.Call(
  7942. null,
  7943. #if CRIPPLED_REFLECTION
  7944. InfoOf(() => Qbservable.LastAsync<TSource>(default(IQbservable<TSource>))),
  7945. #else
  7946. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7947. #endif
  7948. source.Expression
  7949. )
  7950. );
  7951. }
  7952. /// <summary>
  7953. /// Returns the last element of an observable sequence that satisfies the condition in the predicate.
  7954. /// </summary>
  7955. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7956. /// <param name="source">Source observable sequence.</param>
  7957. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  7958. /// <returns>Sequence containing the last element in the observable sequence that satisfies the condition in the predicate.</returns>
  7959. /// <exception cref="T:System.ArgumentNullException">
  7960. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  7961. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) No element satisfies the condition in the predicate. -or- The source sequence is empty.</exception>
  7962. public static IQbservable<TSource> LastAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  7963. {
  7964. if (source == null)
  7965. throw new ArgumentNullException("source");
  7966. if (predicate == null)
  7967. throw new ArgumentNullException("predicate");
  7968. return source.Provider.CreateQuery<TSource>(
  7969. Expression.Call(
  7970. null,
  7971. #if CRIPPLED_REFLECTION
  7972. InfoOf(() => Qbservable.LastAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  7973. #else
  7974. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7975. #endif
  7976. source.Expression,
  7977. predicate
  7978. )
  7979. );
  7980. }
  7981. /// <summary>
  7982. /// Returns the last element of an observable sequence, or a default value if no such element exists.
  7983. /// </summary>
  7984. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7985. /// <param name="source">Source observable sequence.</param>
  7986. /// <returns>Sequence containing the last element in the observable sequence, or a default value if no such element exists.</returns>
  7987. /// <exception cref="T:System.ArgumentNullException">
  7988. /// <paramref name="source" /> is null.</exception>
  7989. public static IQbservable<TSource> LastOrDefaultAsync<TSource>(this IQbservable<TSource> source)
  7990. {
  7991. if (source == null)
  7992. throw new ArgumentNullException("source");
  7993. return source.Provider.CreateQuery<TSource>(
  7994. Expression.Call(
  7995. null,
  7996. #if CRIPPLED_REFLECTION
  7997. InfoOf(() => Qbservable.LastOrDefaultAsync<TSource>(default(IQbservable<TSource>))),
  7998. #else
  7999. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8000. #endif
  8001. source.Expression
  8002. )
  8003. );
  8004. }
  8005. /// <summary>
  8006. /// Returns the last element of an observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.
  8007. /// </summary>
  8008. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8009. /// <param name="source">Source observable sequence.</param>
  8010. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  8011. /// <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>
  8012. /// <exception cref="T:System.ArgumentNullException">
  8013. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  8014. public static IQbservable<TSource> LastOrDefaultAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  8015. {
  8016. if (source == null)
  8017. throw new ArgumentNullException("source");
  8018. if (predicate == null)
  8019. throw new ArgumentNullException("predicate");
  8020. return source.Provider.CreateQuery<TSource>(
  8021. Expression.Call(
  8022. null,
  8023. #if CRIPPLED_REFLECTION
  8024. InfoOf(() => Qbservable.LastOrDefaultAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  8025. #else
  8026. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8027. #endif
  8028. source.Expression,
  8029. predicate
  8030. )
  8031. );
  8032. }
  8033. /// <summary>
  8034. /// Returns an enumerable sequence whose enumeration returns the latest observed element in the source observable sequence.
  8035. /// Enumerators on the resulting sequence will never produce the same element repeatedly, and will block until the next element becomes available.
  8036. /// </summary>
  8037. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8038. /// <param name="source">Source observable sequence.</param>
  8039. /// <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>
  8040. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  8041. public static IQueryable<TSource> Latest<TSource>(this IQbservable<TSource> source)
  8042. {
  8043. if (source == null)
  8044. throw new ArgumentNullException("source");
  8045. return ((IQueryProvider)source.Provider).CreateQuery<TSource>(
  8046. Expression.Call(
  8047. null,
  8048. #if CRIPPLED_REFLECTION
  8049. InfoOf(() => Qbservable.Latest<TSource>(default(IQbservable<TSource>))),
  8050. #else
  8051. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8052. #endif
  8053. source.Expression
  8054. )
  8055. );
  8056. }
  8057. /// <summary>
  8058. /// Returns an observable sequence containing an <see cref="T:System.Int64" /> that represents the total number of elements in an observable sequence.
  8059. /// </summary>
  8060. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8061. /// <param name="source">An observable sequence that contains elements to be counted.</param>
  8062. /// <returns>An observable sequence containing a single element with the number of elements in the input sequence.</returns>
  8063. /// <exception cref="T:System.ArgumentNullException">
  8064. /// <paramref name="source" /> is null.</exception>
  8065. /// <exception cref="T:System.OverflowException">(Asynchronous) The number of elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue" />.</exception>
  8066. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8067. public static IQbservable<long> LongCount<TSource>(this IQbservable<TSource> source)
  8068. {
  8069. if (source == null)
  8070. throw new ArgumentNullException("source");
  8071. return source.Provider.CreateQuery<long>(
  8072. Expression.Call(
  8073. null,
  8074. #if CRIPPLED_REFLECTION
  8075. InfoOf(() => Qbservable.LongCount<TSource>(default(IQbservable<TSource>))),
  8076. #else
  8077. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8078. #endif
  8079. source.Expression
  8080. )
  8081. );
  8082. }
  8083. /// <summary>
  8084. /// Returns an observable sequence containing an <see cref="T:System.Int64" /> that represents how many elements in the specified observable sequence satisfy a condition.
  8085. /// </summary>
  8086. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8087. /// <param name="source">An observable sequence that contains elements to be counted.</param>
  8088. /// <param name="predicate">A function to test each element for a condition.</param>
  8089. /// <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>
  8090. /// <exception cref="T:System.ArgumentNullException">
  8091. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  8092. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8093. public static IQbservable<long> LongCount<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  8094. {
  8095. if (source == null)
  8096. throw new ArgumentNullException("source");
  8097. if (predicate == null)
  8098. throw new ArgumentNullException("predicate");
  8099. return source.Provider.CreateQuery<long>(
  8100. Expression.Call(
  8101. null,
  8102. #if CRIPPLED_REFLECTION
  8103. InfoOf(() => Qbservable.LongCount<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  8104. #else
  8105. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8106. #endif
  8107. source.Expression,
  8108. predicate
  8109. )
  8110. );
  8111. }
  8112. /// <summary>
  8113. /// Materializes the implicit notifications of an observable sequence as explicit notification values.
  8114. /// </summary>
  8115. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8116. /// <param name="source">An observable sequence to get notification values for.</param>
  8117. /// <returns>An observable sequence containing the materialized notification values from the source sequence.</returns>
  8118. /// <exception cref="T:System.ArgumentNullException">
  8119. /// <paramref name="source" /> is null.</exception>
  8120. public static IQbservable<Notification<TSource>> Materialize<TSource>(this IQbservable<TSource> source)
  8121. {
  8122. if (source == null)
  8123. throw new ArgumentNullException("source");
  8124. return source.Provider.CreateQuery<Notification<TSource>>(
  8125. Expression.Call(
  8126. null,
  8127. #if CRIPPLED_REFLECTION
  8128. InfoOf(() => Qbservable.Materialize<TSource>(default(IQbservable<TSource>))),
  8129. #else
  8130. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8131. #endif
  8132. source.Expression
  8133. )
  8134. );
  8135. }
  8136. /// <summary>
  8137. /// Returns the maximum value in an observable sequence of <see cref="T:System.Decimal" /> values.
  8138. /// </summary>
  8139. /// <param name="source">A sequence of <see cref="T:System.Decimal" /> values to determine the maximum value of.</param>
  8140. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8141. /// <exception cref="T:System.ArgumentNullException">
  8142. /// <paramref name="source" /> is null.</exception>
  8143. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8144. public static IQbservable<decimal> Max(this IQbservable<decimal> source)
  8145. {
  8146. if (source == null)
  8147. throw new ArgumentNullException("source");
  8148. return source.Provider.CreateQuery<decimal>(
  8149. Expression.Call(
  8150. null,
  8151. #if CRIPPLED_REFLECTION
  8152. InfoOf(() => Qbservable.Max(default(IQbservable<decimal>))),
  8153. #else
  8154. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8155. #endif
  8156. source.Expression
  8157. )
  8158. );
  8159. }
  8160. /// <summary>
  8161. /// Returns the maximum value in an observable sequence of <see cref="T:System.Double" /> values.
  8162. /// </summary>
  8163. /// <param name="source">A sequence of <see cref="T:System.Double" /> values to determine the maximum value of.</param>
  8164. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8165. /// <exception cref="T:System.ArgumentNullException">
  8166. /// <paramref name="source" /> is null.</exception>
  8167. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8168. public static IQbservable<double> Max(this IQbservable<double> source)
  8169. {
  8170. if (source == null)
  8171. throw new ArgumentNullException("source");
  8172. return source.Provider.CreateQuery<double>(
  8173. Expression.Call(
  8174. null,
  8175. #if CRIPPLED_REFLECTION
  8176. InfoOf(() => Qbservable.Max(default(IQbservable<double>))),
  8177. #else
  8178. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8179. #endif
  8180. source.Expression
  8181. )
  8182. );
  8183. }
  8184. /// <summary>
  8185. /// Returns the maximum value in an observable sequence of <see cref="T:System.Int32" /> values.
  8186. /// </summary>
  8187. /// <param name="source">A sequence of <see cref="T:System.Int32" /> values to determine the maximum value of.</param>
  8188. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8189. /// <exception cref="T:System.ArgumentNullException">
  8190. /// <paramref name="source" /> is null.</exception>
  8191. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8192. public static IQbservable<int> Max(this IQbservable<int> source)
  8193. {
  8194. if (source == null)
  8195. throw new ArgumentNullException("source");
  8196. return source.Provider.CreateQuery<int>(
  8197. Expression.Call(
  8198. null,
  8199. #if CRIPPLED_REFLECTION
  8200. InfoOf(() => Qbservable.Max(default(IQbservable<int>))),
  8201. #else
  8202. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8203. #endif
  8204. source.Expression
  8205. )
  8206. );
  8207. }
  8208. /// <summary>
  8209. /// Returns the maximum value in an observable sequence of <see cref="T:System.Int64" /> values.
  8210. /// </summary>
  8211. /// <param name="source">A sequence of <see cref="T:System.Int64" /> values to determine the maximum value of.</param>
  8212. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8213. /// <exception cref="T:System.ArgumentNullException">
  8214. /// <paramref name="source" /> 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<long> Max(this IQbservable<long> source)
  8217. {
  8218. if (source == null)
  8219. throw new ArgumentNullException("source");
  8220. return source.Provider.CreateQuery<long>(
  8221. Expression.Call(
  8222. null,
  8223. #if CRIPPLED_REFLECTION
  8224. InfoOf(() => Qbservable.Max(default(IQbservable<long>))),
  8225. #else
  8226. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8227. #endif
  8228. source.Expression
  8229. )
  8230. );
  8231. }
  8232. /// <summary>
  8233. /// Returns the maximum value in an observable sequence of nullable <see cref="T:System.Decimal" /> values.
  8234. /// </summary>
  8235. /// <param name="source">A sequence of nullable <see cref="T:System.Decimal" /> values to determine the maximum value of.</param>
  8236. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8237. /// <exception cref="T:System.ArgumentNullException">
  8238. /// <paramref name="source" /> is null.</exception>
  8239. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8240. public static IQbservable<decimal?> Max(this IQbservable<decimal?> source)
  8241. {
  8242. if (source == null)
  8243. throw new ArgumentNullException("source");
  8244. return source.Provider.CreateQuery<decimal?>(
  8245. Expression.Call(
  8246. null,
  8247. #if CRIPPLED_REFLECTION
  8248. InfoOf(() => Qbservable.Max(default(IQbservable<decimal?>))),
  8249. #else
  8250. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8251. #endif
  8252. source.Expression
  8253. )
  8254. );
  8255. }
  8256. /// <summary>
  8257. /// Returns the maximum value in an observable sequence of nullable <see cref="T:System.Double" /> values.
  8258. /// </summary>
  8259. /// <param name="source">A sequence of nullable <see cref="T:System.Double" /> values to determine the maximum value of.</param>
  8260. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8261. /// <exception cref="T:System.ArgumentNullException">
  8262. /// <paramref name="source" /> is null.</exception>
  8263. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8264. public static IQbservable<double?> Max(this IQbservable<double?> source)
  8265. {
  8266. if (source == null)
  8267. throw new ArgumentNullException("source");
  8268. return source.Provider.CreateQuery<double?>(
  8269. Expression.Call(
  8270. null,
  8271. #if CRIPPLED_REFLECTION
  8272. InfoOf(() => Qbservable.Max(default(IQbservable<double?>))),
  8273. #else
  8274. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8275. #endif
  8276. source.Expression
  8277. )
  8278. );
  8279. }
  8280. /// <summary>
  8281. /// Returns the maximum value in an observable sequence of nullable <see cref="T:System.Int32" /> values.
  8282. /// </summary>
  8283. /// <param name="source">A sequence of nullable <see cref="T:System.Int32" /> values to determine the maximum value of.</param>
  8284. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8285. /// <exception cref="T:System.ArgumentNullException">
  8286. /// <paramref name="source" /> is null.</exception>
  8287. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8288. public static IQbservable<int?> Max(this IQbservable<int?> source)
  8289. {
  8290. if (source == null)
  8291. throw new ArgumentNullException("source");
  8292. return source.Provider.CreateQuery<int?>(
  8293. Expression.Call(
  8294. null,
  8295. #if CRIPPLED_REFLECTION
  8296. InfoOf(() => Qbservable.Max(default(IQbservable<int?>))),
  8297. #else
  8298. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8299. #endif
  8300. source.Expression
  8301. )
  8302. );
  8303. }
  8304. /// <summary>
  8305. /// Returns the maximum value in an observable sequence of nullable <see cref="T:System.Int64" /> values.
  8306. /// </summary>
  8307. /// <param name="source">A sequence of nullable <see cref="T:System.Int64" /> values to determine the maximum value of.</param>
  8308. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8309. /// <exception cref="T:System.ArgumentNullException">
  8310. /// <paramref name="source" /> is null.</exception>
  8311. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8312. public static IQbservable<long?> Max(this IQbservable<long?> source)
  8313. {
  8314. if (source == null)
  8315. throw new ArgumentNullException("source");
  8316. return source.Provider.CreateQuery<long?>(
  8317. Expression.Call(
  8318. null,
  8319. #if CRIPPLED_REFLECTION
  8320. InfoOf(() => Qbservable.Max(default(IQbservable<long?>))),
  8321. #else
  8322. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8323. #endif
  8324. source.Expression
  8325. )
  8326. );
  8327. }
  8328. /// <summary>
  8329. /// Returns the maximum value in an observable sequence of nullable <see cref="T:System.Single" /> values.
  8330. /// </summary>
  8331. /// <param name="source">A sequence of nullable <see cref="T:System.Single" /> values to determine the maximum value of.</param>
  8332. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8333. /// <exception cref="T:System.ArgumentNullException">
  8334. /// <paramref name="source" /> is null.</exception>
  8335. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8336. public static IQbservable<float?> Max(this IQbservable<float?> source)
  8337. {
  8338. if (source == null)
  8339. throw new ArgumentNullException("source");
  8340. return source.Provider.CreateQuery<float?>(
  8341. Expression.Call(
  8342. null,
  8343. #if CRIPPLED_REFLECTION
  8344. InfoOf(() => Qbservable.Max(default(IQbservable<float?>))),
  8345. #else
  8346. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8347. #endif
  8348. source.Expression
  8349. )
  8350. );
  8351. }
  8352. /// <summary>
  8353. /// Returns the maximum value in an observable sequence of <see cref="T:System.Single" /> values.
  8354. /// </summary>
  8355. /// <param name="source">A sequence of <see cref="T:System.Single" /> values to determine the maximum value of.</param>
  8356. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8357. /// <exception cref="T:System.ArgumentNullException">
  8358. /// <paramref name="source" /> is null.</exception>
  8359. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8360. public static IQbservable<float> Max(this IQbservable<float> source)
  8361. {
  8362. if (source == null)
  8363. throw new ArgumentNullException("source");
  8364. return source.Provider.CreateQuery<float>(
  8365. Expression.Call(
  8366. null,
  8367. #if CRIPPLED_REFLECTION
  8368. InfoOf(() => Qbservable.Max(default(IQbservable<float>))),
  8369. #else
  8370. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8371. #endif
  8372. source.Expression
  8373. )
  8374. );
  8375. }
  8376. /// <summary>
  8377. /// Returns the maximum element in an observable sequence.
  8378. /// </summary>
  8379. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8380. /// <param name="source">An observable sequence to determine the maximum element of.</param>
  8381. /// <returns>An observable sequence containing a single element with the maximum element in the source sequence.</returns>
  8382. /// <exception cref="T:System.ArgumentNullException">
  8383. /// <paramref name="source" /> is null.</exception>
  8384. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8385. public static IQbservable<TSource> Max<TSource>(this IQbservable<TSource> source)
  8386. {
  8387. if (source == null)
  8388. throw new ArgumentNullException("source");
  8389. return source.Provider.CreateQuery<TSource>(
  8390. Expression.Call(
  8391. null,
  8392. #if CRIPPLED_REFLECTION
  8393. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>))),
  8394. #else
  8395. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8396. #endif
  8397. source.Expression
  8398. )
  8399. );
  8400. }
  8401. /// <summary>
  8402. /// Returns the maximum value in an observable sequence according to the specified comparer.
  8403. /// </summary>
  8404. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8405. /// <param name="source">An observable sequence to determine the maximum element of.</param>
  8406. /// <param name="comparer">Comparer used to compare elements.</param>
  8407. /// <returns>An observable sequence containing a single element with the maximum element in the source sequence.</returns>
  8408. /// <exception cref="T:System.ArgumentNullException">
  8409. /// <paramref name="source" /> or <paramref name="comparer" /> is null.</exception>
  8410. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8411. public static IQbservable<TSource> Max<TSource>(this IQbservable<TSource> source, IComparer<TSource> comparer)
  8412. {
  8413. if (source == null)
  8414. throw new ArgumentNullException("source");
  8415. if (comparer == null)
  8416. throw new ArgumentNullException("comparer");
  8417. return source.Provider.CreateQuery<TSource>(
  8418. Expression.Call(
  8419. null,
  8420. #if CRIPPLED_REFLECTION
  8421. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(IComparer<TSource>))),
  8422. #else
  8423. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8424. #endif
  8425. source.Expression,
  8426. Expression.Constant(comparer, typeof(IComparer<TSource>))
  8427. )
  8428. );
  8429. }
  8430. /// <summary>
  8431. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="T:System.Double" /> value.
  8432. /// </summary>
  8433. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8434. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8435. /// <param name="selector">A transform function to apply to each element.</param>
  8436. /// <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>
  8437. /// <exception cref="T:System.ArgumentNullException">
  8438. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8439. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8440. public static IQbservable<double> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double>> selector)
  8441. {
  8442. if (source == null)
  8443. throw new ArgumentNullException("source");
  8444. if (selector == null)
  8445. throw new ArgumentNullException("selector");
  8446. return source.Provider.CreateQuery<double>(
  8447. Expression.Call(
  8448. null,
  8449. #if CRIPPLED_REFLECTION
  8450. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double>>))),
  8451. #else
  8452. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8453. #endif
  8454. source.Expression,
  8455. selector
  8456. )
  8457. );
  8458. }
  8459. /// <summary>
  8460. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="T:System.Single" /> value.
  8461. /// </summary>
  8462. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8463. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8464. /// <param name="selector">A transform function to apply to each element.</param>
  8465. /// <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>
  8466. /// <exception cref="T:System.ArgumentNullException">
  8467. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8468. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8469. public static IQbservable<float> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float>> selector)
  8470. {
  8471. if (source == null)
  8472. throw new ArgumentNullException("source");
  8473. if (selector == null)
  8474. throw new ArgumentNullException("selector");
  8475. return source.Provider.CreateQuery<float>(
  8476. Expression.Call(
  8477. null,
  8478. #if CRIPPLED_REFLECTION
  8479. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float>>))),
  8480. #else
  8481. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8482. #endif
  8483. source.Expression,
  8484. selector
  8485. )
  8486. );
  8487. }
  8488. /// <summary>
  8489. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="T:System.Decimal" /> value.
  8490. /// </summary>
  8491. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8492. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8493. /// <param name="selector">A transform function to apply to each element.</param>
  8494. /// <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>
  8495. /// <exception cref="T:System.ArgumentNullException">
  8496. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8497. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8498. public static IQbservable<decimal> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal>> selector)
  8499. {
  8500. if (source == null)
  8501. throw new ArgumentNullException("source");
  8502. if (selector == null)
  8503. throw new ArgumentNullException("selector");
  8504. return source.Provider.CreateQuery<decimal>(
  8505. Expression.Call(
  8506. null,
  8507. #if CRIPPLED_REFLECTION
  8508. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal>>))),
  8509. #else
  8510. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8511. #endif
  8512. source.Expression,
  8513. selector
  8514. )
  8515. );
  8516. }
  8517. /// <summary>
  8518. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="T:System.Int32" /> value.
  8519. /// </summary>
  8520. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8521. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8522. /// <param name="selector">A transform function to apply to each element.</param>
  8523. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Int32" /> that corresponds to the maximum value in the source sequence.</returns>
  8524. /// <exception cref="T:System.ArgumentNullException">
  8525. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8526. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8527. public static IQbservable<int> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int>> selector)
  8528. {
  8529. if (source == null)
  8530. throw new ArgumentNullException("source");
  8531. if (selector == null)
  8532. throw new ArgumentNullException("selector");
  8533. return source.Provider.CreateQuery<int>(
  8534. Expression.Call(
  8535. null,
  8536. #if CRIPPLED_REFLECTION
  8537. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int>>))),
  8538. #else
  8539. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8540. #endif
  8541. source.Expression,
  8542. selector
  8543. )
  8544. );
  8545. }
  8546. /// <summary>
  8547. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="T:System.Int64" /> value.
  8548. /// </summary>
  8549. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8550. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8551. /// <param name="selector">A transform function to apply to each element.</param>
  8552. /// <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>
  8553. /// <exception cref="T:System.ArgumentNullException">
  8554. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8555. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8556. public static IQbservable<long> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long>> selector)
  8557. {
  8558. if (source == null)
  8559. throw new ArgumentNullException("source");
  8560. if (selector == null)
  8561. throw new ArgumentNullException("selector");
  8562. return source.Provider.CreateQuery<long>(
  8563. Expression.Call(
  8564. null,
  8565. #if CRIPPLED_REFLECTION
  8566. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long>>))),
  8567. #else
  8568. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8569. #endif
  8570. source.Expression,
  8571. selector
  8572. )
  8573. );
  8574. }
  8575. /// <summary>
  8576. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="T:System.Double" /> value.
  8577. /// </summary>
  8578. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8579. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8580. /// <param name="selector">A transform function to apply to each element.</param>
  8581. /// <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>
  8582. /// <exception cref="T:System.ArgumentNullException">
  8583. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8584. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8585. public static IQbservable<double?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double?>> selector)
  8586. {
  8587. if (source == null)
  8588. throw new ArgumentNullException("source");
  8589. if (selector == null)
  8590. throw new ArgumentNullException("selector");
  8591. return source.Provider.CreateQuery<double?>(
  8592. Expression.Call(
  8593. null,
  8594. #if CRIPPLED_REFLECTION
  8595. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double?>>))),
  8596. #else
  8597. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8598. #endif
  8599. source.Expression,
  8600. selector
  8601. )
  8602. );
  8603. }
  8604. /// <summary>
  8605. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="T:System.Single" /> value.
  8606. /// </summary>
  8607. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8608. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8609. /// <param name="selector">A transform function to apply to each element.</param>
  8610. /// <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>
  8611. /// <exception cref="T:System.ArgumentNullException">
  8612. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8613. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8614. public static IQbservable<float?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float?>> selector)
  8615. {
  8616. if (source == null)
  8617. throw new ArgumentNullException("source");
  8618. if (selector == null)
  8619. throw new ArgumentNullException("selector");
  8620. return source.Provider.CreateQuery<float?>(
  8621. Expression.Call(
  8622. null,
  8623. #if CRIPPLED_REFLECTION
  8624. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float?>>))),
  8625. #else
  8626. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8627. #endif
  8628. source.Expression,
  8629. selector
  8630. )
  8631. );
  8632. }
  8633. /// <summary>
  8634. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="T:System.Decimal" /> value.
  8635. /// </summary>
  8636. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8637. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8638. /// <param name="selector">A transform function to apply to each element.</param>
  8639. /// <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>
  8640. /// <exception cref="T:System.ArgumentNullException">
  8641. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8642. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8643. public static IQbservable<decimal?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal?>> selector)
  8644. {
  8645. if (source == null)
  8646. throw new ArgumentNullException("source");
  8647. if (selector == null)
  8648. throw new ArgumentNullException("selector");
  8649. return source.Provider.CreateQuery<decimal?>(
  8650. Expression.Call(
  8651. null,
  8652. #if CRIPPLED_REFLECTION
  8653. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal?>>))),
  8654. #else
  8655. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8656. #endif
  8657. source.Expression,
  8658. selector
  8659. )
  8660. );
  8661. }
  8662. /// <summary>
  8663. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="T:System.Int32" /> value.
  8664. /// </summary>
  8665. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8666. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8667. /// <param name="selector">A transform function to apply to each element.</param>
  8668. /// <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>
  8669. /// <exception cref="T:System.ArgumentNullException">
  8670. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8671. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8672. public static IQbservable<int?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int?>> selector)
  8673. {
  8674. if (source == null)
  8675. throw new ArgumentNullException("source");
  8676. if (selector == null)
  8677. throw new ArgumentNullException("selector");
  8678. return source.Provider.CreateQuery<int?>(
  8679. Expression.Call(
  8680. null,
  8681. #if CRIPPLED_REFLECTION
  8682. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int?>>))),
  8683. #else
  8684. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8685. #endif
  8686. source.Expression,
  8687. selector
  8688. )
  8689. );
  8690. }
  8691. /// <summary>
  8692. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="T:System.Int64" /> value.
  8693. /// </summary>
  8694. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8695. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8696. /// <param name="selector">A transform function to apply to each element.</param>
  8697. /// <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>
  8698. /// <exception cref="T:System.ArgumentNullException">
  8699. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8700. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8701. public static IQbservable<long?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long?>> selector)
  8702. {
  8703. if (source == null)
  8704. throw new ArgumentNullException("source");
  8705. if (selector == null)
  8706. throw new ArgumentNullException("selector");
  8707. return source.Provider.CreateQuery<long?>(
  8708. Expression.Call(
  8709. null,
  8710. #if CRIPPLED_REFLECTION
  8711. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long?>>))),
  8712. #else
  8713. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8714. #endif
  8715. source.Expression,
  8716. selector
  8717. )
  8718. );
  8719. }
  8720. /// <summary>
  8721. /// Invokes a transform function on each element of a sequence and returns the maximum value.
  8722. /// </summary>
  8723. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8724. /// <typeparam name="TResult">The type of the objects derived from the elements in the source sequence to determine the maximum of.</typeparam>
  8725. /// <param name="source">An observable sequence to determine the mimimum element of.</param>
  8726. /// <param name="selector">A transform function to apply to each element.</param>
  8727. /// <returns>An observable sequence containing a single element with the value that corresponds to the maximum element in the source sequence.</returns>
  8728. /// <exception cref="T:System.ArgumentNullException">
  8729. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8730. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8731. public static IQbservable<TResult> Max<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector)
  8732. {
  8733. if (source == null)
  8734. throw new ArgumentNullException("source");
  8735. if (selector == null)
  8736. throw new ArgumentNullException("selector");
  8737. return source.Provider.CreateQuery<TResult>(
  8738. Expression.Call(
  8739. null,
  8740. #if CRIPPLED_REFLECTION
  8741. InfoOf(() => Qbservable.Max<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>))),
  8742. #else
  8743. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  8744. #endif
  8745. source.Expression,
  8746. selector
  8747. )
  8748. );
  8749. }
  8750. /// <summary>
  8751. /// Invokes a transform function on each element of a sequence and returns the maximum value according to the specified comparer.
  8752. /// </summary>
  8753. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8754. /// <typeparam name="TResult">The type of the objects derived from the elements in the source sequence to determine the maximum of.</typeparam>
  8755. /// <param name="source">An observable sequence to determine the mimimum element of.</param>
  8756. /// <param name="selector">A transform function to apply to each element.</param>
  8757. /// <param name="comparer">Comparer used to compare elements.</param>
  8758. /// <returns>An observable sequence containing a single element with the value that corresponds to the maximum element in the source sequence.</returns>
  8759. /// <exception cref="T:System.ArgumentNullException">
  8760. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="comparer" /> is null.</exception>
  8761. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8762. public static IQbservable<TResult> Max<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector, IComparer<TResult> comparer)
  8763. {
  8764. if (source == null)
  8765. throw new ArgumentNullException("source");
  8766. if (selector == null)
  8767. throw new ArgumentNullException("selector");
  8768. if (comparer == null)
  8769. throw new ArgumentNullException("comparer");
  8770. return source.Provider.CreateQuery<TResult>(
  8771. Expression.Call(
  8772. null,
  8773. #if CRIPPLED_REFLECTION
  8774. InfoOf(() => Qbservable.Max<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>), default(IComparer<TResult>))),
  8775. #else
  8776. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  8777. #endif
  8778. source.Expression,
  8779. selector,
  8780. Expression.Constant(comparer, typeof(IComparer<TResult>))
  8781. )
  8782. );
  8783. }
  8784. /// <summary>
  8785. /// Returns the elements in an observable sequence with the maximum key value.
  8786. /// </summary>
  8787. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8788. /// <typeparam name="TKey">The type of the key computed for each element in the source sequence.</typeparam>
  8789. /// <param name="source">An observable sequence to get the maximum elements for.</param>
  8790. /// <param name="keySelector">Key selector function.</param>
  8791. /// <returns>An observable sequence containing a list of zero or more elements that have a maximum key value.</returns>
  8792. /// <exception cref="T:System.ArgumentNullException">
  8793. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  8794. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8795. public static IQbservable<IList<TSource>> MaxBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  8796. {
  8797. if (source == null)
  8798. throw new ArgumentNullException("source");
  8799. if (keySelector == null)
  8800. throw new ArgumentNullException("keySelector");
  8801. return source.Provider.CreateQuery<IList<TSource>>(
  8802. Expression.Call(
  8803. null,
  8804. #if CRIPPLED_REFLECTION
  8805. InfoOf(() => Qbservable.MaxBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  8806. #else
  8807. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  8808. #endif
  8809. source.Expression,
  8810. keySelector
  8811. )
  8812. );
  8813. }
  8814. /// <summary>
  8815. /// Returns the elements in an observable sequence with the maximum key value according to the specified comparer.
  8816. /// </summary>
  8817. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8818. /// <typeparam name="TKey">The type of the key computed for each element in the source sequence.</typeparam>
  8819. /// <param name="source">An observable sequence to get the maximum elements for.</param>
  8820. /// <param name="keySelector">Key selector function.</param>
  8821. /// <param name="comparer">Comparer used to compare key values.</param>
  8822. /// <returns>An observable sequence containing a list of zero or more elements that have a maximum key value.</returns>
  8823. /// <exception cref="T:System.ArgumentNullException">
  8824. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  8825. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8826. public static IQbservable<IList<TSource>> MaxBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer)
  8827. {
  8828. if (source == null)
  8829. throw new ArgumentNullException("source");
  8830. if (keySelector == null)
  8831. throw new ArgumentNullException("keySelector");
  8832. if (comparer == null)
  8833. throw new ArgumentNullException("comparer");
  8834. return source.Provider.CreateQuery<IList<TSource>>(
  8835. Expression.Call(
  8836. null,
  8837. #if CRIPPLED_REFLECTION
  8838. InfoOf(() => Qbservable.MaxBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IComparer<TKey>))),
  8839. #else
  8840. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  8841. #endif
  8842. source.Expression,
  8843. keySelector,
  8844. Expression.Constant(comparer, typeof(IComparer<TKey>))
  8845. )
  8846. );
  8847. }
  8848. /// <summary>
  8849. /// Merges elements from two observable sequences into a single observable sequence.
  8850. /// </summary>
  8851. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8852. /// <param name="first">First observable sequence.</param>
  8853. /// <param name="second">Second observable sequence.</param>
  8854. /// <returns>The observable sequence that merges the elements of the given sequences.</returns>
  8855. /// <exception cref="T:System.ArgumentNullException">
  8856. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  8857. public static IQbservable<TSource> Merge<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  8858. {
  8859. if (first == null)
  8860. throw new ArgumentNullException("first");
  8861. if (second == null)
  8862. throw new ArgumentNullException("second");
  8863. return first.Provider.CreateQuery<TSource>(
  8864. Expression.Call(
  8865. null,
  8866. #if CRIPPLED_REFLECTION
  8867. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  8868. #else
  8869. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8870. #endif
  8871. first.Expression,
  8872. GetSourceExpression(second)
  8873. )
  8874. );
  8875. }
  8876. /// <summary>
  8877. /// Merges elements from two observable sequences into a single observable sequence, using the specified scheduler for enumeration of and subscription to the sources.
  8878. /// </summary>
  8879. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8880. /// <param name="first">First observable sequence.</param>
  8881. /// <param name="second">Second observable sequence.</param>
  8882. /// <param name="scheduler">Scheduler used to introduce concurrency for making subscriptions to the given sequences.</param>
  8883. /// <returns>The observable sequence that merges the elements of the given sequences.</returns>
  8884. /// <exception cref="T:System.ArgumentNullException">
  8885. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="scheduler" /> is null.</exception>
  8886. public static IQbservable<TSource> Merge<TSource>(this IQbservable<TSource> first, IObservable<TSource> second, IScheduler scheduler)
  8887. {
  8888. if (first == null)
  8889. throw new ArgumentNullException("first");
  8890. if (second == null)
  8891. throw new ArgumentNullException("second");
  8892. if (scheduler == null)
  8893. throw new ArgumentNullException("scheduler");
  8894. return first.Provider.CreateQuery<TSource>(
  8895. Expression.Call(
  8896. null,
  8897. #if CRIPPLED_REFLECTION
  8898. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>), default(IScheduler))),
  8899. #else
  8900. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8901. #endif
  8902. first.Expression,
  8903. GetSourceExpression(second),
  8904. Expression.Constant(scheduler, typeof(IScheduler))
  8905. )
  8906. );
  8907. }
  8908. /// <summary>
  8909. /// 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.
  8910. /// </summary>
  8911. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  8912. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8913. /// <param name="sources">Observable sequences.</param>
  8914. /// <param name="scheduler">Scheduler to run the enumeration of the sequence of sources on.</param>
  8915. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  8916. /// <exception cref="T:System.ArgumentNullException">
  8917. /// <paramref name="scheduler" /> or <paramref name="sources" /> is null.</exception>
  8918. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IScheduler scheduler, params IObservable<TSource>[] sources)
  8919. {
  8920. if (provider == null)
  8921. throw new ArgumentNullException("provider");
  8922. if (scheduler == null)
  8923. throw new ArgumentNullException("scheduler");
  8924. if (sources == null)
  8925. throw new ArgumentNullException("sources");
  8926. return provider.CreateQuery<TSource>(
  8927. Expression.Call(
  8928. null,
  8929. #if CRIPPLED_REFLECTION
  8930. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IScheduler), default(IObservable<TSource>[]))),
  8931. #else
  8932. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8933. #endif
  8934. Expression.Constant(provider, typeof(IQbservableProvider)),
  8935. Expression.Constant(scheduler, typeof(IScheduler)),
  8936. GetSourceExpression(sources)
  8937. )
  8938. );
  8939. }
  8940. /// <summary>
  8941. /// Merges elements from all inner observable sequences into a single observable sequence.
  8942. /// </summary>
  8943. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8944. /// <param name="sources">Observable sequence of inner observable sequences.</param>
  8945. /// <returns>The observable sequence that merges the elements of the inner sequences.</returns>
  8946. /// <exception cref="T:System.ArgumentNullException">
  8947. /// <paramref name="sources" /> is null.</exception>
  8948. public static IQbservable<TSource> Merge<TSource>(this IQbservable<IObservable<TSource>> sources)
  8949. {
  8950. if (sources == null)
  8951. throw new ArgumentNullException("sources");
  8952. return sources.Provider.CreateQuery<TSource>(
  8953. Expression.Call(
  8954. null,
  8955. #if CRIPPLED_REFLECTION
  8956. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<IObservable<TSource>>))),
  8957. #else
  8958. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8959. #endif
  8960. sources.Expression
  8961. )
  8962. );
  8963. }
  8964. #if !NO_TPL
  8965. /// <summary>
  8966. /// Merges results from all source tasks into a single observable sequence.
  8967. /// </summary>
  8968. /// <typeparam name="TSource">The type of the results produced by the source tasks.</typeparam>
  8969. /// <param name="sources">Observable sequence of tasks.</param>
  8970. /// <returns>The observable sequence that merges the results of the source tasks.</returns>
  8971. /// <exception cref="T:System.ArgumentNullException">
  8972. /// <paramref name="sources" /> is null.</exception>
  8973. /// <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>
  8974. public static IQbservable<TSource> Merge<TSource>(this IQbservable<Task<TSource>> sources)
  8975. {
  8976. if (sources == null)
  8977. throw new ArgumentNullException("sources");
  8978. return sources.Provider.CreateQuery<TSource>(
  8979. Expression.Call(
  8980. null,
  8981. #if CRIPPLED_REFLECTION
  8982. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<Task<TSource>>))),
  8983. #else
  8984. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8985. #endif
  8986. sources.Expression
  8987. )
  8988. );
  8989. }
  8990. #endif
  8991. /// <summary>
  8992. /// Merges elements from all of the specified observable sequences into a single observable sequence.
  8993. /// </summary>
  8994. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  8995. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8996. /// <param name="sources">Observable sequences.</param>
  8997. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  8998. /// <exception cref="T:System.ArgumentNullException">
  8999. /// <paramref name="sources" /> is null.</exception>
  9000. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  9001. {
  9002. if (provider == null)
  9003. throw new ArgumentNullException("provider");
  9004. if (sources == null)
  9005. throw new ArgumentNullException("sources");
  9006. return provider.CreateQuery<TSource>(
  9007. Expression.Call(
  9008. null,
  9009. #if CRIPPLED_REFLECTION
  9010. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  9011. #else
  9012. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9013. #endif
  9014. Expression.Constant(provider, typeof(IQbservableProvider)),
  9015. GetSourceExpression(sources)
  9016. )
  9017. );
  9018. }
  9019. /// <summary>
  9020. /// Merges elements from all observable sequences in the given enumerable sequence into a single observable sequence.
  9021. /// </summary>
  9022. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  9023. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  9024. /// <param name="sources">Enumerable sequence of observable sequences.</param>
  9025. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  9026. /// <exception cref="T:System.ArgumentNullException">
  9027. /// <paramref name="sources" /> is null.</exception>
  9028. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  9029. {
  9030. if (provider == null)
  9031. throw new ArgumentNullException("provider");
  9032. if (sources == null)
  9033. throw new ArgumentNullException("sources");
  9034. return provider.CreateQuery<TSource>(
  9035. Expression.Call(
  9036. null,
  9037. #if CRIPPLED_REFLECTION
  9038. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  9039. #else
  9040. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9041. #endif
  9042. Expression.Constant(provider, typeof(IQbservableProvider)),
  9043. GetSourceExpression(sources)
  9044. )
  9045. );
  9046. }
  9047. /// <summary>
  9048. /// Merges elements from all inner observable sequences into a single observable sequence, limiting the number of concurrent subscriptions to inner sequences.
  9049. /// </summary>
  9050. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  9051. /// <param name="sources">Observable sequence of inner observable sequences.</param>
  9052. /// <param name="maxConcurrent">Maximum number of inner observable sequences being subscribed to concurrently.</param>
  9053. /// <returns>The observable sequence that merges the elements of the inner sequences.</returns>
  9054. /// <exception cref="T:System.ArgumentNullException">
  9055. /// <paramref name="sources" /> is null.</exception>
  9056. /// <exception cref="T:System.ArgumentOutOfRangeException">
  9057. /// <paramref name="maxConcurrent" /> is less than or equal to zero.</exception>
  9058. public static IQbservable<TSource> Merge<TSource>(this IQbservable<IObservable<TSource>> sources, int maxConcurrent)
  9059. {
  9060. if (sources == null)
  9061. throw new ArgumentNullException("sources");
  9062. return sources.Provider.CreateQuery<TSource>(
  9063. Expression.Call(
  9064. null,
  9065. #if CRIPPLED_REFLECTION
  9066. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<IObservable<TSource>>), default(int))),
  9067. #else
  9068. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9069. #endif
  9070. sources.Expression,
  9071. Expression.Constant(maxConcurrent, typeof(int))
  9072. )
  9073. );
  9074. }
  9075. /// <summary>
  9076. /// 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.
  9077. /// </summary>
  9078. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  9079. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  9080. /// <param name="sources">Enumerable sequence of observable sequences.</param>
  9081. /// <param name="maxConcurrent">Maximum number of observable sequences being subscribed to concurrently.</param>
  9082. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  9083. /// <exception cref="T:System.ArgumentNullException">
  9084. /// <paramref name="sources" /> is null.</exception>
  9085. /// <exception cref="T:System.ArgumentOutOfRangeException">
  9086. /// <paramref name="maxConcurrent" /> is less than or equal to zero.</exception>
  9087. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, int maxConcurrent)
  9088. {
  9089. if (provider == null)
  9090. throw new ArgumentNullException("provider");
  9091. if (sources == null)
  9092. throw new ArgumentNullException("sources");
  9093. return provider.CreateQuery<TSource>(
  9094. Expression.Call(
  9095. null,
  9096. #if CRIPPLED_REFLECTION
  9097. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(int))),
  9098. #else
  9099. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9100. #endif
  9101. Expression.Constant(provider, typeof(IQbservableProvider)),
  9102. GetSourceExpression(sources),
  9103. Expression.Constant(maxConcurrent, typeof(int))
  9104. )
  9105. );
  9106. }
  9107. /// <summary>
  9108. /// 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.
  9109. /// </summary>
  9110. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  9111. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  9112. /// <param name="sources">Enumerable sequence of observable sequences.</param>
  9113. /// <param name="maxConcurrent">Maximum number of observable sequences being subscribed to concurrently.</param>
  9114. /// <param name="scheduler">Scheduler to run the enumeration of the sequence of sources on.</param>
  9115. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  9116. /// <exception cref="T:System.ArgumentNullException">
  9117. /// <paramref name="sources" /> or <paramref name="scheduler" /> is null.</exception>
  9118. /// <exception cref="T:System.ArgumentOutOfRangeException">
  9119. /// <paramref name="maxConcurrent" /> is less than or equal to zero.</exception>
  9120. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, int maxConcurrent, IScheduler scheduler)
  9121. {
  9122. if (provider == null)
  9123. throw new ArgumentNullException("provider");
  9124. if (sources == null)
  9125. throw new ArgumentNullException("sources");
  9126. if (scheduler == null)
  9127. throw new ArgumentNullException("scheduler");
  9128. return provider.CreateQuery<TSource>(
  9129. Expression.Call(
  9130. null,
  9131. #if CRIPPLED_REFLECTION
  9132. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(int), default(IScheduler))),
  9133. #else
  9134. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9135. #endif
  9136. Expression.Constant(provider, typeof(IQbservableProvider)),
  9137. GetSourceExpression(sources),
  9138. Expression.Constant(maxConcurrent, typeof(int)),
  9139. Expression.Constant(scheduler, typeof(IScheduler))
  9140. )
  9141. );
  9142. }
  9143. /// <summary>
  9144. /// 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.
  9145. /// </summary>
  9146. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  9147. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  9148. /// <param name="sources">Enumerable sequence of observable sequences.</param>
  9149. /// <param name="scheduler">Scheduler to run the enumeration of the sequence of sources on.</param>
  9150. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  9151. /// <exception cref="T:System.ArgumentNullException">
  9152. /// <paramref name="sources" /> or <paramref name="scheduler" /> is null.</exception>
  9153. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, IScheduler scheduler)
  9154. {
  9155. if (provider == null)
  9156. throw new ArgumentNullException("provider");
  9157. if (sources == null)
  9158. throw new ArgumentNullException("sources");
  9159. if (scheduler == null)
  9160. throw new ArgumentNullException("scheduler");
  9161. return provider.CreateQuery<TSource>(
  9162. Expression.Call(
  9163. null,
  9164. #if CRIPPLED_REFLECTION
  9165. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(IScheduler))),
  9166. #else
  9167. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9168. #endif
  9169. Expression.Constant(provider, typeof(IQbservableProvider)),
  9170. GetSourceExpression(sources),
  9171. Expression.Constant(scheduler, typeof(IScheduler))
  9172. )
  9173. );
  9174. }
  9175. /// <summary>
  9176. /// Returns the minimum value in an observable sequence of <see cref="T:System.Decimal" /> values.
  9177. /// </summary>
  9178. /// <param name="source">A sequence of <see cref="T:System.Decimal" /> values to determine the minimum value of.</param>
  9179. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9180. /// <exception cref="T:System.ArgumentNullException">
  9181. /// <paramref name="source" /> is null.</exception>
  9182. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9183. public static IQbservable<decimal> Min(this IQbservable<decimal> source)
  9184. {
  9185. if (source == null)
  9186. throw new ArgumentNullException("source");
  9187. return source.Provider.CreateQuery<decimal>(
  9188. Expression.Call(
  9189. null,
  9190. #if CRIPPLED_REFLECTION
  9191. InfoOf(() => Qbservable.Min(default(IQbservable<decimal>))),
  9192. #else
  9193. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9194. #endif
  9195. source.Expression
  9196. )
  9197. );
  9198. }
  9199. /// <summary>
  9200. /// Returns the minimum value in an observable sequence of <see cref="T:System.Double" /> values.
  9201. /// </summary>
  9202. /// <param name="source">A sequence of <see cref="T:System.Double" /> values to determine the minimum value of.</param>
  9203. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9204. /// <exception cref="T:System.ArgumentNullException">
  9205. /// <paramref name="source" /> is null.</exception>
  9206. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9207. public static IQbservable<double> Min(this IQbservable<double> source)
  9208. {
  9209. if (source == null)
  9210. throw new ArgumentNullException("source");
  9211. return source.Provider.CreateQuery<double>(
  9212. Expression.Call(
  9213. null,
  9214. #if CRIPPLED_REFLECTION
  9215. InfoOf(() => Qbservable.Min(default(IQbservable<double>))),
  9216. #else
  9217. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9218. #endif
  9219. source.Expression
  9220. )
  9221. );
  9222. }
  9223. /// <summary>
  9224. /// Returns the minimum value in an observable sequence of <see cref="T:System.Int32" /> values.
  9225. /// </summary>
  9226. /// <param name="source">A sequence of <see cref="T:System.Int32" /> values to determine the minimum value of.</param>
  9227. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9228. /// <exception cref="T:System.ArgumentNullException">
  9229. /// <paramref name="source" /> is null.</exception>
  9230. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9231. public static IQbservable<int> Min(this IQbservable<int> source)
  9232. {
  9233. if (source == null)
  9234. throw new ArgumentNullException("source");
  9235. return source.Provider.CreateQuery<int>(
  9236. Expression.Call(
  9237. null,
  9238. #if CRIPPLED_REFLECTION
  9239. InfoOf(() => Qbservable.Min(default(IQbservable<int>))),
  9240. #else
  9241. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9242. #endif
  9243. source.Expression
  9244. )
  9245. );
  9246. }
  9247. /// <summary>
  9248. /// Returns the minimum value in an observable sequence of <see cref="T:System.Int64" /> values.
  9249. /// </summary>
  9250. /// <param name="source">A sequence of <see cref="T:System.Int64" /> values to determine the minimum value of.</param>
  9251. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9252. /// <exception cref="T:System.ArgumentNullException">
  9253. /// <paramref name="source" /> 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(this IQbservable<long> source)
  9256. {
  9257. if (source == null)
  9258. throw new ArgumentNullException("source");
  9259. return source.Provider.CreateQuery<long>(
  9260. Expression.Call(
  9261. null,
  9262. #if CRIPPLED_REFLECTION
  9263. InfoOf(() => Qbservable.Min(default(IQbservable<long>))),
  9264. #else
  9265. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9266. #endif
  9267. source.Expression
  9268. )
  9269. );
  9270. }
  9271. /// <summary>
  9272. /// Returns the minimum value in an observable sequence of nullable <see cref="T:System.Decimal" /> values.
  9273. /// </summary>
  9274. /// <param name="source">A sequence of nullable <see cref="T:System.Decimal" /> values to determine the minimum value of.</param>
  9275. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9276. /// <exception cref="T:System.ArgumentNullException">
  9277. /// <paramref name="source" /> is null.</exception>
  9278. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9279. public static IQbservable<decimal?> Min(this IQbservable<decimal?> source)
  9280. {
  9281. if (source == null)
  9282. throw new ArgumentNullException("source");
  9283. return source.Provider.CreateQuery<decimal?>(
  9284. Expression.Call(
  9285. null,
  9286. #if CRIPPLED_REFLECTION
  9287. InfoOf(() => Qbservable.Min(default(IQbservable<decimal?>))),
  9288. #else
  9289. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9290. #endif
  9291. source.Expression
  9292. )
  9293. );
  9294. }
  9295. /// <summary>
  9296. /// Returns the minimum value in an observable sequence of nullable <see cref="T:System.Double" /> values.
  9297. /// </summary>
  9298. /// <param name="source">A sequence of nullable <see cref="T:System.Double" /> values to determine the minimum value of.</param>
  9299. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9300. /// <exception cref="T:System.ArgumentNullException">
  9301. /// <paramref name="source" /> is null.</exception>
  9302. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9303. public static IQbservable<double?> Min(this IQbservable<double?> source)
  9304. {
  9305. if (source == null)
  9306. throw new ArgumentNullException("source");
  9307. return source.Provider.CreateQuery<double?>(
  9308. Expression.Call(
  9309. null,
  9310. #if CRIPPLED_REFLECTION
  9311. InfoOf(() => Qbservable.Min(default(IQbservable<double?>))),
  9312. #else
  9313. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9314. #endif
  9315. source.Expression
  9316. )
  9317. );
  9318. }
  9319. /// <summary>
  9320. /// Returns the minimum value in an observable sequence of nullable <see cref="T:System.Int32" /> values.
  9321. /// </summary>
  9322. /// <param name="source">A sequence of nullable <see cref="T:System.Int32" /> values to determine the minimum value of.</param>
  9323. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9324. /// <exception cref="T:System.ArgumentNullException">
  9325. /// <paramref name="source" /> is null.</exception>
  9326. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9327. public static IQbservable<int?> Min(this IQbservable<int?> source)
  9328. {
  9329. if (source == null)
  9330. throw new ArgumentNullException("source");
  9331. return source.Provider.CreateQuery<int?>(
  9332. Expression.Call(
  9333. null,
  9334. #if CRIPPLED_REFLECTION
  9335. InfoOf(() => Qbservable.Min(default(IQbservable<int?>))),
  9336. #else
  9337. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9338. #endif
  9339. source.Expression
  9340. )
  9341. );
  9342. }
  9343. /// <summary>
  9344. /// Returns the minimum value in an observable sequence of nullable <see cref="T:System.Int64" /> values.
  9345. /// </summary>
  9346. /// <param name="source">A sequence of nullable <see cref="T:System.Int64" /> values to determine the minimum value of.</param>
  9347. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9348. /// <exception cref="T:System.ArgumentNullException">
  9349. /// <paramref name="source" /> is null.</exception>
  9350. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9351. public static IQbservable<long?> Min(this IQbservable<long?> source)
  9352. {
  9353. if (source == null)
  9354. throw new ArgumentNullException("source");
  9355. return source.Provider.CreateQuery<long?>(
  9356. Expression.Call(
  9357. null,
  9358. #if CRIPPLED_REFLECTION
  9359. InfoOf(() => Qbservable.Min(default(IQbservable<long?>))),
  9360. #else
  9361. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9362. #endif
  9363. source.Expression
  9364. )
  9365. );
  9366. }
  9367. /// <summary>
  9368. /// Returns the minimum value in an observable sequence of nullable <see cref="T:System.Single" /> values.
  9369. /// </summary>
  9370. /// <param name="source">A sequence of nullable <see cref="T:System.Single" /> values to determine the minimum value of.</param>
  9371. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9372. /// <exception cref="T:System.ArgumentNullException">
  9373. /// <paramref name="source" /> is null.</exception>
  9374. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9375. public static IQbservable<float?> Min(this IQbservable<float?> source)
  9376. {
  9377. if (source == null)
  9378. throw new ArgumentNullException("source");
  9379. return source.Provider.CreateQuery<float?>(
  9380. Expression.Call(
  9381. null,
  9382. #if CRIPPLED_REFLECTION
  9383. InfoOf(() => Qbservable.Min(default(IQbservable<float?>))),
  9384. #else
  9385. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9386. #endif
  9387. source.Expression
  9388. )
  9389. );
  9390. }
  9391. /// <summary>
  9392. /// Returns the minimum value in an observable sequence of <see cref="T:System.Single" /> values.
  9393. /// </summary>
  9394. /// <param name="source">A sequence of <see cref="T:System.Single" /> values to determine the minimum value of.</param>
  9395. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9396. /// <exception cref="T:System.ArgumentNullException">
  9397. /// <paramref name="source" /> is null.</exception>
  9398. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9399. public static IQbservable<float> Min(this IQbservable<float> source)
  9400. {
  9401. if (source == null)
  9402. throw new ArgumentNullException("source");
  9403. return source.Provider.CreateQuery<float>(
  9404. Expression.Call(
  9405. null,
  9406. #if CRIPPLED_REFLECTION
  9407. InfoOf(() => Qbservable.Min(default(IQbservable<float>))),
  9408. #else
  9409. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9410. #endif
  9411. source.Expression
  9412. )
  9413. );
  9414. }
  9415. /// <summary>
  9416. /// Returns the minimum element in an observable sequence.
  9417. /// </summary>
  9418. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9419. /// <param name="source">An observable sequence to determine the mimimum element of.</param>
  9420. /// <returns>An observable sequence containing a single element with the minimum element in the source sequence.</returns>
  9421. /// <exception cref="T:System.ArgumentNullException">
  9422. /// <paramref name="source" /> is null.</exception>
  9423. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9424. public static IQbservable<TSource> Min<TSource>(this IQbservable<TSource> source)
  9425. {
  9426. if (source == null)
  9427. throw new ArgumentNullException("source");
  9428. return source.Provider.CreateQuery<TSource>(
  9429. Expression.Call(
  9430. null,
  9431. #if CRIPPLED_REFLECTION
  9432. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>))),
  9433. #else
  9434. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9435. #endif
  9436. source.Expression
  9437. )
  9438. );
  9439. }
  9440. /// <summary>
  9441. /// Returns the minimum element in an observable sequence according to the specified comparer.
  9442. /// </summary>
  9443. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9444. /// <param name="source">An observable sequence to determine the mimimum element of.</param>
  9445. /// <param name="comparer">Comparer used to compare elements.</param>
  9446. /// <returns>An observable sequence containing a single element with the minimum element in the source sequence.</returns>
  9447. /// <exception cref="T:System.ArgumentNullException">
  9448. /// <paramref name="source" /> or <paramref name="comparer" /> is null.</exception>
  9449. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9450. public static IQbservable<TSource> Min<TSource>(this IQbservable<TSource> source, IComparer<TSource> comparer)
  9451. {
  9452. if (source == null)
  9453. throw new ArgumentNullException("source");
  9454. if (comparer == null)
  9455. throw new ArgumentNullException("comparer");
  9456. return source.Provider.CreateQuery<TSource>(
  9457. Expression.Call(
  9458. null,
  9459. #if CRIPPLED_REFLECTION
  9460. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(IComparer<TSource>))),
  9461. #else
  9462. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9463. #endif
  9464. source.Expression,
  9465. Expression.Constant(comparer, typeof(IComparer<TSource>))
  9466. )
  9467. );
  9468. }
  9469. /// <summary>
  9470. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="T:System.Double" /> value.
  9471. /// </summary>
  9472. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9473. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9474. /// <param name="selector">A transform function to apply to each element.</param>
  9475. /// <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>
  9476. /// <exception cref="T:System.ArgumentNullException">
  9477. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9478. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9479. public static IQbservable<double> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double>> selector)
  9480. {
  9481. if (source == null)
  9482. throw new ArgumentNullException("source");
  9483. if (selector == null)
  9484. throw new ArgumentNullException("selector");
  9485. return source.Provider.CreateQuery<double>(
  9486. Expression.Call(
  9487. null,
  9488. #if CRIPPLED_REFLECTION
  9489. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double>>))),
  9490. #else
  9491. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9492. #endif
  9493. source.Expression,
  9494. selector
  9495. )
  9496. );
  9497. }
  9498. /// <summary>
  9499. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="T:System.Single" /> value.
  9500. /// </summary>
  9501. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9502. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9503. /// <param name="selector">A transform function to apply to each element.</param>
  9504. /// <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>
  9505. /// <exception cref="T:System.ArgumentNullException">
  9506. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9507. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9508. public static IQbservable<float> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float>> selector)
  9509. {
  9510. if (source == null)
  9511. throw new ArgumentNullException("source");
  9512. if (selector == null)
  9513. throw new ArgumentNullException("selector");
  9514. return source.Provider.CreateQuery<float>(
  9515. Expression.Call(
  9516. null,
  9517. #if CRIPPLED_REFLECTION
  9518. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float>>))),
  9519. #else
  9520. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9521. #endif
  9522. source.Expression,
  9523. selector
  9524. )
  9525. );
  9526. }
  9527. /// <summary>
  9528. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="T:System.Decimal" /> value.
  9529. /// </summary>
  9530. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9531. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9532. /// <param name="selector">A transform function to apply to each element.</param>
  9533. /// <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>
  9534. /// <exception cref="T:System.ArgumentNullException">
  9535. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9536. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9537. public static IQbservable<decimal> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal>> selector)
  9538. {
  9539. if (source == null)
  9540. throw new ArgumentNullException("source");
  9541. if (selector == null)
  9542. throw new ArgumentNullException("selector");
  9543. return source.Provider.CreateQuery<decimal>(
  9544. Expression.Call(
  9545. null,
  9546. #if CRIPPLED_REFLECTION
  9547. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal>>))),
  9548. #else
  9549. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9550. #endif
  9551. source.Expression,
  9552. selector
  9553. )
  9554. );
  9555. }
  9556. /// <summary>
  9557. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="T:System.Int32" /> value.
  9558. /// </summary>
  9559. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9560. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9561. /// <param name="selector">A transform function to apply to each element.</param>
  9562. /// <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>
  9563. /// <exception cref="T:System.ArgumentNullException">
  9564. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9565. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9566. public static IQbservable<int> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int>> selector)
  9567. {
  9568. if (source == null)
  9569. throw new ArgumentNullException("source");
  9570. if (selector == null)
  9571. throw new ArgumentNullException("selector");
  9572. return source.Provider.CreateQuery<int>(
  9573. Expression.Call(
  9574. null,
  9575. #if CRIPPLED_REFLECTION
  9576. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int>>))),
  9577. #else
  9578. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9579. #endif
  9580. source.Expression,
  9581. selector
  9582. )
  9583. );
  9584. }
  9585. /// <summary>
  9586. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="T:System.Int64" /> value.
  9587. /// </summary>
  9588. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9589. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9590. /// <param name="selector">A transform function to apply to each element.</param>
  9591. /// <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>
  9592. /// <exception cref="T:System.ArgumentNullException">
  9593. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9594. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9595. public static IQbservable<long> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long>> selector)
  9596. {
  9597. if (source == null)
  9598. throw new ArgumentNullException("source");
  9599. if (selector == null)
  9600. throw new ArgumentNullException("selector");
  9601. return source.Provider.CreateQuery<long>(
  9602. Expression.Call(
  9603. null,
  9604. #if CRIPPLED_REFLECTION
  9605. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long>>))),
  9606. #else
  9607. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9608. #endif
  9609. source.Expression,
  9610. selector
  9611. )
  9612. );
  9613. }
  9614. /// <summary>
  9615. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="T:System.Double" /> value.
  9616. /// </summary>
  9617. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9618. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9619. /// <param name="selector">A transform function to apply to each element.</param>
  9620. /// <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>
  9621. /// <exception cref="T:System.ArgumentNullException">
  9622. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9623. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9624. public static IQbservable<double?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double?>> selector)
  9625. {
  9626. if (source == null)
  9627. throw new ArgumentNullException("source");
  9628. if (selector == null)
  9629. throw new ArgumentNullException("selector");
  9630. return source.Provider.CreateQuery<double?>(
  9631. Expression.Call(
  9632. null,
  9633. #if CRIPPLED_REFLECTION
  9634. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double?>>))),
  9635. #else
  9636. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9637. #endif
  9638. source.Expression,
  9639. selector
  9640. )
  9641. );
  9642. }
  9643. /// <summary>
  9644. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="T:System.Single" /> value.
  9645. /// </summary>
  9646. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9647. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9648. /// <param name="selector">A transform function to apply to each element.</param>
  9649. /// <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>
  9650. /// <exception cref="T:System.ArgumentNullException">
  9651. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9652. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9653. public static IQbservable<float?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float?>> selector)
  9654. {
  9655. if (source == null)
  9656. throw new ArgumentNullException("source");
  9657. if (selector == null)
  9658. throw new ArgumentNullException("selector");
  9659. return source.Provider.CreateQuery<float?>(
  9660. Expression.Call(
  9661. null,
  9662. #if CRIPPLED_REFLECTION
  9663. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float?>>))),
  9664. #else
  9665. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9666. #endif
  9667. source.Expression,
  9668. selector
  9669. )
  9670. );
  9671. }
  9672. /// <summary>
  9673. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="T:System.Decimal" /> value.
  9674. /// </summary>
  9675. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9676. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9677. /// <param name="selector">A transform function to apply to each element.</param>
  9678. /// <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>
  9679. /// <exception cref="T:System.ArgumentNullException">
  9680. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9681. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9682. public static IQbservable<decimal?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal?>> selector)
  9683. {
  9684. if (source == null)
  9685. throw new ArgumentNullException("source");
  9686. if (selector == null)
  9687. throw new ArgumentNullException("selector");
  9688. return source.Provider.CreateQuery<decimal?>(
  9689. Expression.Call(
  9690. null,
  9691. #if CRIPPLED_REFLECTION
  9692. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal?>>))),
  9693. #else
  9694. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9695. #endif
  9696. source.Expression,
  9697. selector
  9698. )
  9699. );
  9700. }
  9701. /// <summary>
  9702. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="T:System.Int32" /> value.
  9703. /// </summary>
  9704. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9705. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9706. /// <param name="selector">A transform function to apply to each element.</param>
  9707. /// <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>
  9708. /// <exception cref="T:System.ArgumentNullException">
  9709. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9710. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9711. public static IQbservable<int?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int?>> selector)
  9712. {
  9713. if (source == null)
  9714. throw new ArgumentNullException("source");
  9715. if (selector == null)
  9716. throw new ArgumentNullException("selector");
  9717. return source.Provider.CreateQuery<int?>(
  9718. Expression.Call(
  9719. null,
  9720. #if CRIPPLED_REFLECTION
  9721. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int?>>))),
  9722. #else
  9723. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9724. #endif
  9725. source.Expression,
  9726. selector
  9727. )
  9728. );
  9729. }
  9730. /// <summary>
  9731. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="T:System.Int64" /> value.
  9732. /// </summary>
  9733. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9734. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9735. /// <param name="selector">A transform function to apply to each element.</param>
  9736. /// <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>
  9737. /// <exception cref="T:System.ArgumentNullException">
  9738. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9739. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9740. public static IQbservable<long?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long?>> selector)
  9741. {
  9742. if (source == null)
  9743. throw new ArgumentNullException("source");
  9744. if (selector == null)
  9745. throw new ArgumentNullException("selector");
  9746. return source.Provider.CreateQuery<long?>(
  9747. Expression.Call(
  9748. null,
  9749. #if CRIPPLED_REFLECTION
  9750. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long?>>))),
  9751. #else
  9752. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9753. #endif
  9754. source.Expression,
  9755. selector
  9756. )
  9757. );
  9758. }
  9759. /// <summary>
  9760. /// Invokes a transform function on each element of a sequence and returns the minimum value.
  9761. /// </summary>
  9762. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9763. /// <typeparam name="TResult">The type of the objects derived from the elements in the source sequence to determine the minimum of.</typeparam>
  9764. /// <param name="source">An observable sequence to determine the mimimum element of.</param>
  9765. /// <param name="selector">A transform function to apply to each element.</param>
  9766. /// <returns>An observable sequence containing a single element with the value that corresponds to the minimum element in the source sequence.</returns>
  9767. /// <exception cref="T:System.ArgumentNullException">
  9768. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9769. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9770. public static IQbservable<TResult> Min<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector)
  9771. {
  9772. if (source == null)
  9773. throw new ArgumentNullException("source");
  9774. if (selector == null)
  9775. throw new ArgumentNullException("selector");
  9776. return source.Provider.CreateQuery<TResult>(
  9777. Expression.Call(
  9778. null,
  9779. #if CRIPPLED_REFLECTION
  9780. InfoOf(() => Qbservable.Min<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>))),
  9781. #else
  9782. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  9783. #endif
  9784. source.Expression,
  9785. selector
  9786. )
  9787. );
  9788. }
  9789. /// <summary>
  9790. /// Invokes a transform function on each element of a sequence and returns the minimum value according to the specified comparer.
  9791. /// </summary>
  9792. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9793. /// <typeparam name="TResult">The type of the objects derived from the elements in the source sequence to determine the minimum of.</typeparam>
  9794. /// <param name="source">An observable sequence to determine the mimimum element of.</param>
  9795. /// <param name="selector">A transform function to apply to each element.</param>
  9796. /// <param name="comparer">Comparer used to compare elements.</param>
  9797. /// <returns>An observable sequence containing a single element with the value that corresponds to the minimum element in the source sequence.</returns>
  9798. /// <exception cref="T:System.ArgumentNullException">
  9799. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="comparer" /> is null.</exception>
  9800. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9801. public static IQbservable<TResult> Min<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector, IComparer<TResult> comparer)
  9802. {
  9803. if (source == null)
  9804. throw new ArgumentNullException("source");
  9805. if (selector == null)
  9806. throw new ArgumentNullException("selector");
  9807. if (comparer == null)
  9808. throw new ArgumentNullException("comparer");
  9809. return source.Provider.CreateQuery<TResult>(
  9810. Expression.Call(
  9811. null,
  9812. #if CRIPPLED_REFLECTION
  9813. InfoOf(() => Qbservable.Min<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>), default(IComparer<TResult>))),
  9814. #else
  9815. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  9816. #endif
  9817. source.Expression,
  9818. selector,
  9819. Expression.Constant(comparer, typeof(IComparer<TResult>))
  9820. )
  9821. );
  9822. }
  9823. /// <summary>
  9824. /// Returns the elements in an observable sequence with the minimum key value.
  9825. /// </summary>
  9826. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9827. /// <typeparam name="TKey">The type of the key computed for each element in the source sequence.</typeparam>
  9828. /// <param name="source">An observable sequence to get the minimum elements for.</param>
  9829. /// <param name="keySelector">Key selector function.</param>
  9830. /// <returns>An observable sequence containing a list of zero or more elements that have a minimum key value.</returns>
  9831. /// <exception cref="T:System.ArgumentNullException">
  9832. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  9833. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9834. public static IQbservable<IList<TSource>> MinBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  9835. {
  9836. if (source == null)
  9837. throw new ArgumentNullException("source");
  9838. if (keySelector == null)
  9839. throw new ArgumentNullException("keySelector");
  9840. return source.Provider.CreateQuery<IList<TSource>>(
  9841. Expression.Call(
  9842. null,
  9843. #if CRIPPLED_REFLECTION
  9844. InfoOf(() => Qbservable.MinBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  9845. #else
  9846. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  9847. #endif
  9848. source.Expression,
  9849. keySelector
  9850. )
  9851. );
  9852. }
  9853. /// <summary>
  9854. /// Returns the elements in an observable sequence with the minimum key value according to the specified comparer.
  9855. /// </summary>
  9856. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9857. /// <typeparam name="TKey">The type of the key computed for each element in the source sequence.</typeparam>
  9858. /// <param name="source">An observable sequence to get the minimum elements for.</param>
  9859. /// <param name="keySelector">Key selector function.</param>
  9860. /// <param name="comparer">Comparer used to compare key values.</param>
  9861. /// <returns>An observable sequence containing a list of zero or more elements that have a minimum key value.</returns>
  9862. /// <exception cref="T:System.ArgumentNullException">
  9863. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  9864. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9865. public static IQbservable<IList<TSource>> MinBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer)
  9866. {
  9867. if (source == null)
  9868. throw new ArgumentNullException("source");
  9869. if (keySelector == null)
  9870. throw new ArgumentNullException("keySelector");
  9871. if (comparer == null)
  9872. throw new ArgumentNullException("comparer");
  9873. return source.Provider.CreateQuery<IList<TSource>>(
  9874. Expression.Call(
  9875. null,
  9876. #if CRIPPLED_REFLECTION
  9877. InfoOf(() => Qbservable.MinBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IComparer<TKey>))),
  9878. #else
  9879. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  9880. #endif
  9881. source.Expression,
  9882. keySelector,
  9883. Expression.Constant(comparer, typeof(IComparer<TKey>))
  9884. )
  9885. );
  9886. }
  9887. /// <summary>
  9888. /// 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.
  9889. /// Enumerators on the resulting sequence never block and can produce the same element repeatedly.
  9890. /// </summary>
  9891. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9892. /// <param name="source">Source observable sequence.</param>
  9893. /// <param name="initialValue">Initial value that will be yielded by the enumerable sequence if no element has been sampled yet.</param>
  9894. /// <returns>The enumerable sequence that returns the last sampled element upon each iteration.</returns>
  9895. /// <exception cref="T:System.ArgumentNullException">
  9896. /// <paramref name="source" /> is null.</exception>
  9897. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  9898. public static IQueryable<TSource> MostRecent<TSource>(this IQbservable<TSource> source, TSource initialValue)
  9899. {
  9900. if (source == null)
  9901. throw new ArgumentNullException("source");
  9902. return ((IQueryProvider)source.Provider).CreateQuery<TSource>(
  9903. Expression.Call(
  9904. null,
  9905. #if CRIPPLED_REFLECTION
  9906. InfoOf(() => Qbservable.MostRecent<TSource>(default(IQbservable<TSource>), default(TSource))),
  9907. #else
  9908. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9909. #endif
  9910. source.Expression,
  9911. Expression.Constant(initialValue, typeof(TSource))
  9912. )
  9913. );
  9914. }
  9915. /// <summary>
  9916. /// Multicasts the source sequence notifications through an instantiated subject into all uses of the sequence within a selector function. Each
  9917. /// subscription to the resulting sequence causes a separate multicast invocation, exposing the sequence resulting from the selector function's
  9918. /// invocation. For specializations with fixed subject types, see Publish, PublishLast, and Replay.
  9919. /// </summary>
  9920. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9921. /// <typeparam name="TIntermediate">The type of the elements produced by the intermediate subject.</typeparam>
  9922. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  9923. /// <param name="source">Source sequence which will be multicasted in the specified selector function.</param>
  9924. /// <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>
  9925. /// <param name="selector">Selector function which can use the multicasted source sequence subject to the policies enforced by the created subject.</param>
  9926. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  9927. /// <exception cref="T:System.ArgumentNullException">
  9928. /// <paramref name="source" /> or <paramref name="subjectSelector" /> or <paramref name="selector" /> is null.</exception>
  9929. 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)
  9930. {
  9931. if (source == null)
  9932. throw new ArgumentNullException("source");
  9933. if (subjectSelector == null)
  9934. throw new ArgumentNullException("subjectSelector");
  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.Multicast<TSource, TIntermediate, TResult>(default(IQbservable<TSource>), default(Expression<Func<ISubject<TSource, TIntermediate>>>), default(Expression<Func<IObservable<TIntermediate>, IObservable<TResult>>>))),
  9942. #else
  9943. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TIntermediate), typeof(TResult)),
  9944. #endif
  9945. source.Expression,
  9946. subjectSelector,
  9947. selector
  9948. )
  9949. );
  9950. }
  9951. /// <summary>
  9952. /// Returns a non-terminating observable sequence, which can be used to denote an infinite duration (e.g. when using reactive joins).
  9953. /// </summary>
  9954. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  9955. /// <typeparam name="TResult">The type used for the IObservable&lt;T&gt; type parameter of the resulting sequence.</typeparam>
  9956. /// <returns>An observable sequence whose observers will never get called.</returns>
  9957. public static IQbservable<TResult> Never<TResult>(this IQbservableProvider provider)
  9958. {
  9959. if (provider == null)
  9960. throw new ArgumentNullException("provider");
  9961. return provider.CreateQuery<TResult>(
  9962. Expression.Call(
  9963. null,
  9964. #if CRIPPLED_REFLECTION
  9965. InfoOf(() => Qbservable.Never<TResult>(default(IQbservableProvider))),
  9966. #else
  9967. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  9968. #endif
  9969. Expression.Constant(provider, typeof(IQbservableProvider))
  9970. )
  9971. );
  9972. }
  9973. /// <summary>
  9974. /// Returns a non-terminating observable sequence, which can be used to denote an infinite duration (e.g. when using reactive joins).
  9975. /// </summary>
  9976. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  9977. /// <typeparam name="TResult">The type used for the IObservable&lt;T&gt; type parameter of the resulting sequence.</typeparam>
  9978. /// <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>
  9979. /// <returns>An observable sequence whose observers will never get called.</returns>
  9980. public static IQbservable<TResult> Never<TResult>(this IQbservableProvider provider, TResult witness)
  9981. {
  9982. if (provider == null)
  9983. throw new ArgumentNullException("provider");
  9984. return provider.CreateQuery<TResult>(
  9985. Expression.Call(
  9986. null,
  9987. #if CRIPPLED_REFLECTION
  9988. InfoOf(() => Qbservable.Never<TResult>(default(IQbservableProvider), default(TResult))),
  9989. #else
  9990. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  9991. #endif
  9992. Expression.Constant(provider, typeof(IQbservableProvider)),
  9993. Expression.Constant(witness, typeof(TResult))
  9994. )
  9995. );
  9996. }
  9997. /// <summary>
  9998. /// Returns an enumerable sequence whose enumeration blocks until the next element in the source observable sequence becomes available.
  9999. /// Enumerators on the resulting sequence will block until the next element becomes available.
  10000. /// </summary>
  10001. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10002. /// <param name="source">Source observable sequence.</param>
  10003. /// <returns>The enumerable sequence that blocks upon each iteration until the next element in the observable source sequence becomes available.</returns>
  10004. /// <exception cref="T:System.ArgumentNullException">
  10005. /// <paramref name="source" /> is null.</exception>
  10006. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  10007. public static IQueryable<TSource> Next<TSource>(this IQbservable<TSource> source)
  10008. {
  10009. if (source == null)
  10010. throw new ArgumentNullException("source");
  10011. return ((IQueryProvider)source.Provider).CreateQuery<TSource>(
  10012. Expression.Call(
  10013. null,
  10014. #if CRIPPLED_REFLECTION
  10015. InfoOf(() => Qbservable.Next<TSource>(default(IQbservable<TSource>))),
  10016. #else
  10017. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10018. #endif
  10019. source.Expression
  10020. )
  10021. );
  10022. }
  10023. /// <summary>
  10024. /// Wraps the source sequence in order to run its observer callbacks on the specified synchronization context.
  10025. /// </summary>
  10026. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10027. /// <param name="source">Source sequence.</param>
  10028. /// <param name="context">Synchronization context to notify observers on.</param>
  10029. /// <returns>The source sequence whose observations happen on the specified synchronization context.</returns>
  10030. /// <exception cref="T:System.ArgumentNullException">
  10031. /// <paramref name="source" /> or <paramref name="context" /> is null.</exception>
  10032. /// <remarks>
  10033. /// This only invokes observer callbacks on a synchronization context. In case the subscription and/or unsubscription actions have side-effects
  10034. /// 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)" />.
  10035. /// </remarks>
  10036. public static IQbservable<TSource> ObserveOn<TSource>(this IQbservable<TSource> source, SynchronizationContext context)
  10037. {
  10038. if (source == null)
  10039. throw new ArgumentNullException("source");
  10040. if (context == null)
  10041. throw new ArgumentNullException("context");
  10042. return source.Provider.CreateQuery<TSource>(
  10043. Expression.Call(
  10044. null,
  10045. #if CRIPPLED_REFLECTION
  10046. InfoOf(() => Qbservable.ObserveOn<TSource>(default(IQbservable<TSource>), default(SynchronizationContext))),
  10047. #else
  10048. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10049. #endif
  10050. source.Expression,
  10051. Expression.Constant(context, typeof(SynchronizationContext))
  10052. )
  10053. );
  10054. }
  10055. /// <summary>
  10056. /// Wraps the source sequence in order to run its observer callbacks on the specified scheduler.
  10057. /// </summary>
  10058. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10059. /// <param name="source">Source sequence.</param>
  10060. /// <param name="scheduler">Scheduler to notify observers on.</param>
  10061. /// <returns>The source sequence whose observations happen on the specified scheduler.</returns>
  10062. /// <exception cref="T:System.ArgumentNullException">
  10063. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  10064. /// <remarks>
  10065. /// This only invokes observer callbacks on a scheduler. In case the subscription and/or unsubscription actions have side-effects
  10066. /// 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)" />.
  10067. /// </remarks>
  10068. public static IQbservable<TSource> ObserveOn<TSource>(this IQbservable<TSource> source, IScheduler scheduler)
  10069. {
  10070. if (source == null)
  10071. throw new ArgumentNullException("source");
  10072. if (scheduler == null)
  10073. throw new ArgumentNullException("scheduler");
  10074. return source.Provider.CreateQuery<TSource>(
  10075. Expression.Call(
  10076. null,
  10077. #if CRIPPLED_REFLECTION
  10078. InfoOf(() => Qbservable.ObserveOn<TSource>(default(IQbservable<TSource>), default(IScheduler))),
  10079. #else
  10080. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10081. #endif
  10082. source.Expression,
  10083. Expression.Constant(scheduler, typeof(IScheduler))
  10084. )
  10085. );
  10086. }
  10087. /// <summary>
  10088. /// Filters the elements of an observable sequence based on the specified type.
  10089. /// </summary>
  10090. /// <typeparam name="TResult">The type to filter the elements in the source sequence on.</typeparam>
  10091. /// <param name="source">The observable sequence that contains the elements to be filtered.</param>
  10092. /// <returns>An observable sequence that contains elements from the input sequence of type TResult.</returns>
  10093. /// <exception cref="T:System.ArgumentNullException">
  10094. /// <paramref name="source" /> is null.</exception>
  10095. public static IQbservable<TResult> OfType<TResult>(this IQbservable<object> source)
  10096. {
  10097. if (source == null)
  10098. throw new ArgumentNullException("source");
  10099. return source.Provider.CreateQuery<TResult>(
  10100. Expression.Call(
  10101. null,
  10102. #if CRIPPLED_REFLECTION
  10103. InfoOf(() => Qbservable.OfType<TResult>(default(IQbservable<object>))),
  10104. #else
  10105. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10106. #endif
  10107. source.Expression
  10108. )
  10109. );
  10110. }
  10111. /// <summary>
  10112. /// Concatenates the second observable sequence to the first observable sequence upon successful or exceptional termination of the first.
  10113. /// </summary>
  10114. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  10115. /// <param name="first">First observable sequence whose exception (if any) is caught.</param>
  10116. /// <param name="second">Second observable sequence used to produce results after the first sequence terminates.</param>
  10117. /// <returns>An observable sequence that concatenates the first and second sequence, even if the first sequence terminates exceptionally.</returns>
  10118. /// <exception cref="T:System.ArgumentNullException">
  10119. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  10120. public static IQbservable<TSource> OnErrorResumeNext<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  10121. {
  10122. if (first == null)
  10123. throw new ArgumentNullException("first");
  10124. if (second == null)
  10125. throw new ArgumentNullException("second");
  10126. return first.Provider.CreateQuery<TSource>(
  10127. Expression.Call(
  10128. null,
  10129. #if CRIPPLED_REFLECTION
  10130. InfoOf(() => Qbservable.OnErrorResumeNext<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  10131. #else
  10132. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10133. #endif
  10134. first.Expression,
  10135. GetSourceExpression(second)
  10136. )
  10137. );
  10138. }
  10139. /// <summary>
  10140. /// Concatenates all of the specified observable sequences, even if the previous observable sequence terminated exceptionally.
  10141. /// </summary>
  10142. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10143. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  10144. /// <param name="sources">Observable sequences to concatenate.</param>
  10145. /// <returns>An observable sequence that concatenates the source sequences, even if a sequence terminates exceptionally.</returns>
  10146. /// <exception cref="T:System.ArgumentNullException">
  10147. /// <paramref name="sources" /> is null.</exception>
  10148. public static IQbservable<TSource> OnErrorResumeNext<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  10149. {
  10150. if (provider == null)
  10151. throw new ArgumentNullException("provider");
  10152. if (sources == null)
  10153. throw new ArgumentNullException("sources");
  10154. return provider.CreateQuery<TSource>(
  10155. Expression.Call(
  10156. null,
  10157. #if CRIPPLED_REFLECTION
  10158. InfoOf(() => Qbservable.OnErrorResumeNext<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  10159. #else
  10160. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10161. #endif
  10162. Expression.Constant(provider, typeof(IQbservableProvider)),
  10163. GetSourceExpression(sources)
  10164. )
  10165. );
  10166. }
  10167. /// <summary>
  10168. /// Concatenates all observable sequences in the given enumerable sequence, even if the previous observable sequence terminated exceptionally.
  10169. /// </summary>
  10170. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10171. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  10172. /// <param name="sources">Observable sequences to concatenate.</param>
  10173. /// <returns>An observable sequence that concatenates the source sequences, even if a sequence terminates exceptionally.</returns>
  10174. /// <exception cref="T:System.ArgumentNullException">
  10175. /// <paramref name="sources" /> is null.</exception>
  10176. public static IQbservable<TSource> OnErrorResumeNext<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  10177. {
  10178. if (provider == null)
  10179. throw new ArgumentNullException("provider");
  10180. if (sources == null)
  10181. throw new ArgumentNullException("sources");
  10182. return provider.CreateQuery<TSource>(
  10183. Expression.Call(
  10184. null,
  10185. #if CRIPPLED_REFLECTION
  10186. InfoOf(() => Qbservable.OnErrorResumeNext<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  10187. #else
  10188. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10189. #endif
  10190. Expression.Constant(provider, typeof(IQbservableProvider)),
  10191. GetSourceExpression(sources)
  10192. )
  10193. );
  10194. }
  10195. /// <summary>
  10196. /// Sorts the elements of a sequence in ascending order according to a key.
  10197. /// </summary>
  10198. /// <typeparam name="TSource">The type of the elements in the <paramref name="source" /> sequence.</typeparam>
  10199. /// <typeparam name="TKey">The type of the sorting key computed for each element in the source sequence.</typeparam>
  10200. /// <param name="source">An observable sequence of values to order.</param>
  10201. /// <param name="keySelector">A function to extract the key for each element.</param>
  10202. /// <returns>An <see cref="T:System.Reactive.Linq.IOrderedObservable`1" /> whose elements are sorted according to a key.</returns>
  10203. /// <exception cref="T:System.ArgumentNullException">
  10204. /// <paramref name="source" /> or <paramref name="keySelector" /> is <see langword="null" />.</exception>
  10205. /// <remarks>
  10206. /// <para>
  10207. /// Ordering requires all of the elements in the <paramref name="source" /> sequence to be observed before it can complete,
  10208. /// which means that all of the elements must be buffered. Ordering an observable sequence is similar to performing an aggregation
  10209. /// such as <see cref="M:System.Reactive.Linq.Observable.ToList``1(System.IObservable{``0})" /> because time information is lost and notifications are only generated when the <paramref name="source" />
  10210. /// sequence calls OnCompleted.
  10211. /// </para>
  10212. /// <alert type="warn">
  10213. /// Do not attempt to order an observable sequence that never calls OnCompleted. There will be no notifications generated, and it
  10214. /// may result in an <see cref="T:System.OutOfMemoryException" /> being thrown.
  10215. /// </alert>
  10216. /// </remarks>
  10217. public static IOrderedQbservable<TSource> OrderBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  10218. {
  10219. if (source == null)
  10220. throw new ArgumentNullException("source");
  10221. if (keySelector == null)
  10222. throw new ArgumentNullException("keySelector");
  10223. return (IOrderedQbservable<TSource>)source.Provider.CreateQuery<TSource>(
  10224. Expression.Call(
  10225. null,
  10226. #if CRIPPLED_REFLECTION
  10227. InfoOf(() => Qbservable.OrderBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  10228. #else
  10229. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  10230. #endif
  10231. source.Expression,
  10232. keySelector
  10233. )
  10234. );
  10235. }
  10236. /// <summary>
  10237. /// Sorts the elements of a sequence in ascending order by using a specified comparer.
  10238. /// </summary>
  10239. /// <typeparam name="TSource">The type of the elements in the <paramref name="source" /> sequence.</typeparam>
  10240. /// <typeparam name="TKey">The type of the sorting key computed for each element in the source sequence.</typeparam>
  10241. /// <param name="source">An observable sequence of values to order.</param>
  10242. /// <param name="keySelector">A function to extract the key for each element.</param>
  10243. /// <param name="comparer">An <see cref="T:System.Collections.Generic.IComparer`1" /> to compare keys.</param>
  10244. /// <returns>An <see cref="T:System.Reactive.Linq.IOrderedObservable`1" /> whose elements are sorted according to a key.</returns>
  10245. /// <exception cref="T:System.ArgumentNullException">
  10246. /// <paramref name="source" />, <paramref name="keySelector" /> or <paramref name="comparer" /> is <see langword="null" />.</exception>
  10247. /// <remarks>
  10248. /// <para>
  10249. /// Ordering requires all of the elements in the <paramref name="source" /> sequence to be observed before it can complete,
  10250. /// which means that all of the elements must be buffered. Ordering an observable sequence is similar to performing an aggregation
  10251. /// such as <see cref="M:System.Reactive.Linq.Observable.ToList``1(System.IObservable{``0})" /> because timing is lost and notifications are only generated when the <paramref name="source" />
  10252. /// sequence calls OnCompleted.
  10253. /// </para>
  10254. /// <alert type="warn">
  10255. /// Do not attempt to order an observable sequence that never calls OnCompleted. There will be no notifications generated, and it
  10256. /// may result in an <see cref="T:System.OutOfMemoryException" /> being thrown.
  10257. /// </alert>
  10258. /// </remarks>
  10259. public static IOrderedQbservable<TSource> OrderBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer)
  10260. {
  10261. if (source == null)
  10262. throw new ArgumentNullException("source");
  10263. if (keySelector == null)
  10264. throw new ArgumentNullException("keySelector");
  10265. if (comparer == null)
  10266. throw new ArgumentNullException("comparer");
  10267. return (IOrderedQbservable<TSource>)source.Provider.CreateQuery<TSource>(
  10268. Expression.Call(
  10269. null,
  10270. #if CRIPPLED_REFLECTION
  10271. InfoOf(() => Qbservable.OrderBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IComparer<TKey>))),
  10272. #else
  10273. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  10274. #endif
  10275. source.Expression,
  10276. keySelector,
  10277. Expression.Constant(comparer, typeof(IComparer<TKey>))
  10278. )
  10279. );
  10280. }
  10281. /// <summary>
  10282. /// Sorts the elements of a sequence in ascending order according to the times at which corresponding observable sequences produce their first notification or complete.
  10283. /// </summary>
  10284. /// <typeparam name="TSource">The type of the elements in the <paramref name="source" /> sequence.</typeparam>
  10285. /// <typeparam name="TOther">The type of the elements in the observable returned by <paramref name="timeSelector" />.</typeparam>
  10286. /// <param name="source">An observable sequence of values to order.</param>
  10287. /// <param name="timeSelector">A function that returns an observable for an element in the <paramref name="source" /> sequence indicating the time at which that element should appear in the ordering.</param>
  10288. /// <returns>An <see cref="T:System.Reactive.Linq.IOrderedObservable`1" /> whose elements are sorted according to the times at which corresponding observable sequences produce their first notification or complete.</returns>
  10289. /// <exception cref="T:System.ArgumentNullException">
  10290. /// <paramref name="source" /> or <paramref name="timeSelector" /> is <see langword="null" />.</exception>
  10291. /// <remarks>
  10292. /// <para>
  10293. /// This overload of OrderBy is similar to a particular usage of SelectMany where the elements in the <paramref name="source" /> sequence are returned based on the times
  10294. /// at which their corresponding inner sequences produce their first notification or complete. Any elements in the inner sequences are discarded.
  10295. /// </para>
  10296. /// <para>
  10297. /// The primary benefits of this overload of OrderBy is that it relates to ordering specifically, thus it's more semantic than SelectMany and it allows an author to avoid
  10298. /// defining an unused query variable when applying SelectMany merely as an ordering operator. It also returns <see cref="T:System.Reactive.Linq.IOrderedObservable`1" /> so that it may
  10299. /// be used in combination with any overloads of ThenBy and ThenByDescending to define queries that order by time and key.
  10300. /// </para>
  10301. /// <alert type="info">
  10302. /// Unlike the other overload of OrderBy, this overload does not buffer any elements and it does not wait for the <paramref name="source" /> sequence to complete before it
  10303. /// pushes notifications. This overload is entirely reactive.
  10304. /// </alert>
  10305. /// <para>
  10306. /// This overload supports using the orderby LINQ query comprehension syntax in C# and Visual Basic by passing an observable sequence as the key.
  10307. /// </para>
  10308. /// <example>
  10309. /// <para>
  10310. /// The following example shows how to use this overload of OrderBy with the orderby LINQ query comprehension syntax in C#.
  10311. /// </para>
  10312. /// <para>
  10313. /// The result of this query is a sequence of integers from 5 to 1, at 1 second intervals.
  10314. /// </para>
  10315. /// <code><![CDATA[IObservable<int> xs =
  10316. /// from x in Observable.Range(1, 5)
  10317. /// orderby Observable.Timer(TimeSpan.FromSeconds(5 - x))
  10318. /// select x;]]></code>
  10319. /// </example>
  10320. /// </remarks>
  10321. public static IOrderedQbservable<TSource> OrderBy<TSource, TOther>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TOther>>> timeSelector)
  10322. {
  10323. if (source == null)
  10324. throw new ArgumentNullException("source");
  10325. if (timeSelector == null)
  10326. throw new ArgumentNullException("timeSelector");
  10327. return (IOrderedQbservable<TSource>)source.Provider.CreateQuery<TSource>(
  10328. Expression.Call(
  10329. null,
  10330. #if CRIPPLED_REFLECTION
  10331. InfoOf(() => Qbservable.OrderBy<TSource, TOther>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TOther>>>))),
  10332. #else
  10333. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)),
  10334. #endif
  10335. source.Expression,
  10336. timeSelector
  10337. )
  10338. );
  10339. }
  10340. /// <summary>
  10341. /// Sorts the elements of a sequence in descending order according to a key.
  10342. /// </summary>
  10343. /// <typeparam name="TSource">The type of the elements in the <paramref name="source" /> sequence.</typeparam>
  10344. /// <typeparam name="TKey">The type of the sorting key computed for each element in the source sequence.</typeparam>
  10345. /// <param name="source">An observable sequence of values to order.</param>
  10346. /// <param name="keySelector">A function to extract the key for each element.</param>
  10347. /// <returns>An <see cref="T:System.Reactive.Linq.IOrderedObservable`1" /> whose elements are sorted in descending order according to a key.</returns>
  10348. /// <exception cref="T:System.ArgumentNullException">
  10349. /// <paramref name="source" /> or <paramref name="keySelector" /> is <see langword="null" />.</exception>
  10350. /// <remarks>
  10351. /// <para>
  10352. /// Ordering requires all of the elements in the <paramref name="source" /> sequence to be observed before it can complete,
  10353. /// which means that all of the elements must be buffered. Ordering an observable sequence is similar to performing an aggregation
  10354. /// such as <see cref="M:System.Reactive.Linq.Observable.ToList``1(System.IObservable{``0})" /> because timing is lost and notifications are only generated when the <paramref name="source" />
  10355. /// sequence calls OnCompleted.
  10356. /// </para>
  10357. /// <alert type="warn">
  10358. /// Do not attempt to order an observable sequence that never calls OnCompleted. There will be no notifications generated, and it
  10359. /// may result in an <see cref="T:System.OutOfMemoryException" /> being thrown.
  10360. /// </alert>
  10361. /// </remarks>
  10362. public static IOrderedQbservable<TSource> OrderByDescending<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  10363. {
  10364. if (source == null)
  10365. throw new ArgumentNullException("source");
  10366. if (keySelector == null)
  10367. throw new ArgumentNullException("keySelector");
  10368. return (IOrderedQbservable<TSource>)source.Provider.CreateQuery<TSource>(
  10369. Expression.Call(
  10370. null,
  10371. #if CRIPPLED_REFLECTION
  10372. InfoOf(() => Qbservable.OrderByDescending<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  10373. #else
  10374. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  10375. #endif
  10376. source.Expression,
  10377. keySelector
  10378. )
  10379. );
  10380. }
  10381. /// <summary>
  10382. /// Sorts the elements of a sequence in descending order by using a specified comparer.
  10383. /// </summary>
  10384. /// <typeparam name="TSource">The type of the elements in the <paramref name="source" /> sequence.</typeparam>
  10385. /// <typeparam name="TKey">The type of the sorting key computed for each element in the source sequence.</typeparam>
  10386. /// <param name="source">An observable sequence of values to order.</param>
  10387. /// <param name="keySelector">A function to extract the key for each element.</param>
  10388. /// <param name="comparer">An <see cref="T:System.Collections.Generic.IComparer`1" /> to compare keys.</param>
  10389. /// <returns>An <see cref="T:System.Reactive.Linq.IOrderedObservable`1" /> whose elements are sorted in descending order according to a key.</returns>
  10390. /// <exception cref="T:System.ArgumentNullException">
  10391. /// <paramref name="source" />, <paramref name="keySelector" /> or <paramref name="comparer" /> is <see langword="null" />.</exception>
  10392. /// <remarks>
  10393. /// <para>
  10394. /// Ordering requires all of the elements in the <paramref name="source" /> sequence to be observed before it can complete,
  10395. /// which means that all of the elements must be buffered. Ordering an observable sequence is similar to performing an aggregation
  10396. /// such as <see cref="M:System.Reactive.Linq.Observable.ToList``1(System.IObservable{``0})" /> because timing is lost and notifications are only generated when the <paramref name="source" />
  10397. /// sequence calls OnCompleted.
  10398. /// </para>
  10399. /// <alert type="warn">
  10400. /// Do not attempt to order an observable sequence that never calls OnCompleted. There will be no notifications generated, and it
  10401. /// may result in an <see cref="T:System.OutOfMemoryException" /> being thrown.
  10402. /// </alert>
  10403. /// </remarks>
  10404. public static IOrderedQbservable<TSource> OrderByDescending<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer)
  10405. {
  10406. if (source == null)
  10407. throw new ArgumentNullException("source");
  10408. if (keySelector == null)
  10409. throw new ArgumentNullException("keySelector");
  10410. if (comparer == null)
  10411. throw new ArgumentNullException("comparer");
  10412. return (IOrderedQbservable<TSource>)source.Provider.CreateQuery<TSource>(
  10413. Expression.Call(
  10414. null,
  10415. #if CRIPPLED_REFLECTION
  10416. InfoOf(() => Qbservable.OrderByDescending<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IComparer<TKey>))),
  10417. #else
  10418. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  10419. #endif
  10420. source.Expression,
  10421. keySelector,
  10422. Expression.Constant(comparer, typeof(IComparer<TKey>))
  10423. )
  10424. );
  10425. }
  10426. /// <summary>
  10427. /// Sorts the elements of a sequence in descending order according to the times at which corresponding observable sequences produce their first notification or complete.
  10428. /// </summary>
  10429. /// <typeparam name="TSource">The type of the elements in the <paramref name="source" /> sequence.</typeparam>
  10430. /// <typeparam name="TOther">The type of the elements in the observable returned by <paramref name="timeSelector" />.</typeparam>
  10431. /// <param name="source">An observable sequence of values to order.</param>
  10432. /// <param name="timeSelector">A function that returns an observable for an element in the <paramref name="source" /> sequence indicating the time at which that element should appear in the ordering.</param>
  10433. /// <returns>An <see cref="T:System.Reactive.Linq.IOrderedObservable`1" /> whose elements are sorted in descending order according to the times at which corresponding observable sequences produce their first notification or complete.</returns>
  10434. /// <exception cref="T:System.ArgumentNullException">
  10435. /// <paramref name="source" /> or <paramref name="timeSelector" /> is <see langword="null" />.</exception>
  10436. /// <remarks>
  10437. /// <para>
  10438. /// Ordering descending by time requires all of the elements in the <paramref name="source" /> sequence to be observed before it can complete,
  10439. /// which means that all of the elements must be buffered. Ordering an observable sequence descending by time is similar to performing an aggregation
  10440. /// such as <see cref="M:System.Reactive.Linq.Observable.ToList``1(System.IObservable{``0})" /> because timing from the <paramref name="source" /> sequence is lost and notifications are only generated when
  10441. /// the <paramref name="source" /> sequence calls OnCompleted.
  10442. /// </para>
  10443. /// <alert type="warn">
  10444. /// Do not attempt to order an observable sequence that never calls OnCompleted. There will be no notifications generated, and it
  10445. /// may result in an <see cref="T:System.OutOfMemoryException" /> being thrown.
  10446. /// </alert>
  10447. /// <para>
  10448. /// This overload of OrderByDescending is similar to a particular usage of SelectMany where the elements in the <paramref name="source" /> sequence are returned based on the times
  10449. /// at which their corresponding inner sequences produce their first notification or complete. Any elements in the inner sequences are discarded.
  10450. /// </para>
  10451. /// <para>
  10452. /// The primary benefits of this overload of OrderByDescending is that it relates to ordering specifically, thus it's more semantic than SelectMany and it allows an author to avoid
  10453. /// defining an unused query variable when applying SelectMany merely as an ordering operator. It also returns <see cref="T:System.Reactive.Linq.IOrderedObservable`1" /> so that it may
  10454. /// be used in combination with any overloads of ThenBy and ThenByDescending to define queries that order by time and key.
  10455. /// </para>
  10456. /// <para>
  10457. /// This overload supports using the orderby LINQ query comprehension syntax in C# and Visual Basic by passing an observable sequence as the key.
  10458. /// </para>
  10459. /// <example>
  10460. /// <para>
  10461. /// The following example shows how to use this overload of OrderByDescending with the orderby LINQ query comprehension syntax in C#.
  10462. /// </para>
  10463. /// <para>
  10464. /// The result of this query is a sequence of integers from 1 to 5, all of them arriving at 5 seconds from the time of subscription.
  10465. /// </para>
  10466. /// <code><![CDATA[IObservable<int> xs =
  10467. /// from x in Observable.Range(1, 5)
  10468. /// orderby Observable.Timer(TimeSpan.FromSeconds(5 - x)) descending
  10469. /// select x;]]></code>
  10470. /// </example>
  10471. /// </remarks>
  10472. public static IOrderedQbservable<TSource> OrderByDescending<TSource, TOther>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TOther>>> timeSelector)
  10473. {
  10474. if (source == null)
  10475. throw new ArgumentNullException("source");
  10476. if (timeSelector == null)
  10477. throw new ArgumentNullException("timeSelector");
  10478. return (IOrderedQbservable<TSource>)source.Provider.CreateQuery<TSource>(
  10479. Expression.Call(
  10480. null,
  10481. #if CRIPPLED_REFLECTION
  10482. InfoOf(() => Qbservable.OrderByDescending<TSource, TOther>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TOther>>>))),
  10483. #else
  10484. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)),
  10485. #endif
  10486. source.Expression,
  10487. timeSelector
  10488. )
  10489. );
  10490. }
  10491. /// <summary>
  10492. /// 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.
  10493. /// This operator is a specialization of Multicast using a regular <see cref="T:System.Reactive.Subjects.Subject`1" />.
  10494. /// </summary>
  10495. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10496. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10497. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10498. /// <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>
  10499. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10500. /// <exception cref="T:System.ArgumentNullException">
  10501. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10502. /// <seealso cref="T:System.Reactive.Subjects.Subject`1" />
  10503. public static IQbservable<TResult> Publish<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector)
  10504. {
  10505. if (source == null)
  10506. throw new ArgumentNullException("source");
  10507. if (selector == null)
  10508. throw new ArgumentNullException("selector");
  10509. return source.Provider.CreateQuery<TResult>(
  10510. Expression.Call(
  10511. null,
  10512. #if CRIPPLED_REFLECTION
  10513. InfoOf(() => Qbservable.Publish<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>))),
  10514. #else
  10515. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10516. #endif
  10517. source.Expression,
  10518. selector
  10519. )
  10520. );
  10521. }
  10522. /// <summary>
  10523. /// 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.
  10524. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.BehaviorSubject`1" />.
  10525. /// </summary>
  10526. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10527. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10528. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10529. /// <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>
  10530. /// <param name="initialValue">Initial value received by observers upon subscription.</param>
  10531. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10532. /// <exception cref="T:System.ArgumentNullException">
  10533. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10534. /// <seealso cref="T:System.Reactive.Subjects.BehaviorSubject`1" />
  10535. public static IQbservable<TResult> Publish<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, TSource initialValue)
  10536. {
  10537. if (source == null)
  10538. throw new ArgumentNullException("source");
  10539. if (selector == null)
  10540. throw new ArgumentNullException("selector");
  10541. return source.Provider.CreateQuery<TResult>(
  10542. Expression.Call(
  10543. null,
  10544. #if CRIPPLED_REFLECTION
  10545. InfoOf(() => Qbservable.Publish<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(TSource))),
  10546. #else
  10547. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10548. #endif
  10549. source.Expression,
  10550. selector,
  10551. Expression.Constant(initialValue, typeof(TSource))
  10552. )
  10553. );
  10554. }
  10555. /// <summary>
  10556. /// 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.
  10557. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.AsyncSubject`1" />.
  10558. /// </summary>
  10559. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10560. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10561. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10562. /// <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>
  10563. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10564. /// <exception cref="T:System.ArgumentNullException">
  10565. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10566. /// <seealso cref="T:System.Reactive.Subjects.AsyncSubject`1" />
  10567. public static IQbservable<TResult> PublishLast<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector)
  10568. {
  10569. if (source == null)
  10570. throw new ArgumentNullException("source");
  10571. if (selector == null)
  10572. throw new ArgumentNullException("selector");
  10573. return source.Provider.CreateQuery<TResult>(
  10574. Expression.Call(
  10575. null,
  10576. #if CRIPPLED_REFLECTION
  10577. InfoOf(() => Qbservable.PublishLast<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>))),
  10578. #else
  10579. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10580. #endif
  10581. source.Expression,
  10582. selector
  10583. )
  10584. );
  10585. }
  10586. /// <summary>
  10587. /// Generates an observable sequence of integral numbers within a specified range.
  10588. /// </summary>
  10589. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10590. /// <param name="start">The value of the first integer in the sequence.</param>
  10591. /// <param name="count">The number of sequential integers to generate.</param>
  10592. /// <returns>An observable sequence that contains a range of sequential integral numbers.</returns>
  10593. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10594. /// <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>
  10595. public static IQbservable<int> Range(this IQbservableProvider provider, int start, int count)
  10596. {
  10597. if (provider == null)
  10598. throw new ArgumentNullException("provider");
  10599. return provider.CreateQuery<int>(
  10600. Expression.Call(
  10601. null,
  10602. #if CRIPPLED_REFLECTION
  10603. InfoOf(() => Qbservable.Range(default(IQbservableProvider), default(int), default(int))),
  10604. #else
  10605. (MethodInfo)MethodInfo.GetCurrentMethod(),
  10606. #endif
  10607. Expression.Constant(provider, typeof(IQbservableProvider)),
  10608. Expression.Constant(start, typeof(int)),
  10609. Expression.Constant(count, typeof(int))
  10610. )
  10611. );
  10612. }
  10613. /// <summary>
  10614. /// Generates an observable sequence of integral numbers within a specified range, using the specified scheduler to send out observer messages.
  10615. /// </summary>
  10616. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10617. /// <param name="start">The value of the first integer in the sequence.</param>
  10618. /// <param name="count">The number of sequential integers to generate.</param>
  10619. /// <param name="scheduler">Scheduler to run the generator loop on.</param>
  10620. /// <returns>An observable sequence that contains a range of sequential integral numbers.</returns>
  10621. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10622. /// <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>
  10623. /// <exception cref="T:System.ArgumentNullException">
  10624. /// <paramref name="scheduler" /> is null.</exception>
  10625. public static IQbservable<int> Range(this IQbservableProvider provider, int start, int count, IScheduler scheduler)
  10626. {
  10627. if (provider == null)
  10628. throw new ArgumentNullException("provider");
  10629. if (scheduler == null)
  10630. throw new ArgumentNullException("scheduler");
  10631. return provider.CreateQuery<int>(
  10632. Expression.Call(
  10633. null,
  10634. #if CRIPPLED_REFLECTION
  10635. InfoOf(() => Qbservable.Range(default(IQbservableProvider), default(int), default(int), default(IScheduler))),
  10636. #else
  10637. (MethodInfo)MethodInfo.GetCurrentMethod(),
  10638. #endif
  10639. Expression.Constant(provider, typeof(IQbservableProvider)),
  10640. Expression.Constant(start, typeof(int)),
  10641. Expression.Constant(count, typeof(int)),
  10642. Expression.Constant(scheduler, typeof(IScheduler))
  10643. )
  10644. );
  10645. }
  10646. /// <summary>
  10647. /// Returns an observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence.
  10648. /// </summary>
  10649. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10650. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10651. /// <param name="source">Connectable observable sequence.</param>
  10652. /// <returns>An observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence.</returns>
  10653. /// <exception cref="T:System.ArgumentNullException">
  10654. /// <paramref name="source" /> is null.</exception>
  10655. public static IQbservable<TSource> RefCount<TSource>(this IQbservableProvider provider, IConnectableObservable<TSource> source)
  10656. {
  10657. if (provider == null)
  10658. throw new ArgumentNullException("provider");
  10659. if (source == null)
  10660. throw new ArgumentNullException("source");
  10661. return provider.CreateQuery<TSource>(
  10662. Expression.Call(
  10663. null,
  10664. #if CRIPPLED_REFLECTION
  10665. InfoOf(() => Qbservable.RefCount<TSource>(default(IQbservableProvider), default(IConnectableObservable<TSource>))),
  10666. #else
  10667. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10668. #endif
  10669. Expression.Constant(provider, typeof(IQbservableProvider)),
  10670. Expression.Constant(source, typeof(IConnectableObservable<TSource>))
  10671. )
  10672. );
  10673. }
  10674. /// <summary>
  10675. /// Generates an observable sequence that repeats the given element infinitely.
  10676. /// </summary>
  10677. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10678. /// <typeparam name="TResult">The type of the element that will be repeated in the produced sequence.</typeparam>
  10679. /// <param name="value">Element to repeat.</param>
  10680. /// <returns>An observable sequence that repeats the given element infinitely.</returns>
  10681. public static IQbservable<TResult> Repeat<TResult>(this IQbservableProvider provider, TResult value)
  10682. {
  10683. if (provider == null)
  10684. throw new ArgumentNullException("provider");
  10685. return provider.CreateQuery<TResult>(
  10686. Expression.Call(
  10687. null,
  10688. #if CRIPPLED_REFLECTION
  10689. InfoOf(() => Qbservable.Repeat<TResult>(default(IQbservableProvider), default(TResult))),
  10690. #else
  10691. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10692. #endif
  10693. Expression.Constant(provider, typeof(IQbservableProvider)),
  10694. Expression.Constant(value, typeof(TResult))
  10695. )
  10696. );
  10697. }
  10698. /// <summary>
  10699. /// Generates an observable sequence that repeats the given element the specified number of times.
  10700. /// </summary>
  10701. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10702. /// <typeparam name="TResult">The type of the element that will be repeated in the produced sequence.</typeparam>
  10703. /// <param name="value">Element to repeat.</param>
  10704. /// <param name="repeatCount">Number of times to repeat the element.</param>
  10705. /// <returns>An observable sequence that repeats the given element the specified number of times.</returns>
  10706. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10707. /// <paramref name="repeatCount" /> is less than zero.</exception>
  10708. public static IQbservable<TResult> Repeat<TResult>(this IQbservableProvider provider, TResult value, int repeatCount)
  10709. {
  10710. if (provider == null)
  10711. throw new ArgumentNullException("provider");
  10712. return provider.CreateQuery<TResult>(
  10713. Expression.Call(
  10714. null,
  10715. #if CRIPPLED_REFLECTION
  10716. InfoOf(() => Qbservable.Repeat<TResult>(default(IQbservableProvider), default(TResult), default(int))),
  10717. #else
  10718. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10719. #endif
  10720. Expression.Constant(provider, typeof(IQbservableProvider)),
  10721. Expression.Constant(value, typeof(TResult)),
  10722. Expression.Constant(repeatCount, typeof(int))
  10723. )
  10724. );
  10725. }
  10726. /// <summary>
  10727. /// Generates an observable sequence that repeats the given element the specified number of times, using the specified scheduler to send out observer messages.
  10728. /// </summary>
  10729. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10730. /// <typeparam name="TResult">The type of the element that will be repeated in the produced sequence.</typeparam>
  10731. /// <param name="value">Element to repeat.</param>
  10732. /// <param name="repeatCount">Number of times to repeat the element.</param>
  10733. /// <param name="scheduler">Scheduler to run the producer loop on.</param>
  10734. /// <returns>An observable sequence that repeats the given element the specified number of times.</returns>
  10735. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10736. /// <paramref name="repeatCount" /> is less than zero.</exception>
  10737. /// <exception cref="T:System.ArgumentNullException">
  10738. /// <paramref name="scheduler" /> is null.</exception>
  10739. public static IQbservable<TResult> Repeat<TResult>(this IQbservableProvider provider, TResult value, int repeatCount, IScheduler scheduler)
  10740. {
  10741. if (provider == null)
  10742. throw new ArgumentNullException("provider");
  10743. if (scheduler == null)
  10744. throw new ArgumentNullException("scheduler");
  10745. return provider.CreateQuery<TResult>(
  10746. Expression.Call(
  10747. null,
  10748. #if CRIPPLED_REFLECTION
  10749. InfoOf(() => Qbservable.Repeat<TResult>(default(IQbservableProvider), default(TResult), default(int), default(IScheduler))),
  10750. #else
  10751. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10752. #endif
  10753. Expression.Constant(provider, typeof(IQbservableProvider)),
  10754. Expression.Constant(value, typeof(TResult)),
  10755. Expression.Constant(repeatCount, typeof(int)),
  10756. Expression.Constant(scheduler, typeof(IScheduler))
  10757. )
  10758. );
  10759. }
  10760. /// <summary>
  10761. /// Generates an observable sequence that repeats the given element infinitely, using the specified scheduler to send out observer messages.
  10762. /// </summary>
  10763. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10764. /// <typeparam name="TResult">The type of the element that will be repeated in the produced sequence.</typeparam>
  10765. /// <param name="value">Element to repeat.</param>
  10766. /// <param name="scheduler">Scheduler to run the producer loop on.</param>
  10767. /// <returns>An observable sequence that repeats the given element infinitely.</returns>
  10768. /// <exception cref="T:System.ArgumentNullException">
  10769. /// <paramref name="scheduler" /> is null.</exception>
  10770. public static IQbservable<TResult> Repeat<TResult>(this IQbservableProvider provider, TResult value, IScheduler scheduler)
  10771. {
  10772. if (provider == null)
  10773. throw new ArgumentNullException("provider");
  10774. if (scheduler == null)
  10775. throw new ArgumentNullException("scheduler");
  10776. return provider.CreateQuery<TResult>(
  10777. Expression.Call(
  10778. null,
  10779. #if CRIPPLED_REFLECTION
  10780. InfoOf(() => Qbservable.Repeat<TResult>(default(IQbservableProvider), default(TResult), default(IScheduler))),
  10781. #else
  10782. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10783. #endif
  10784. Expression.Constant(provider, typeof(IQbservableProvider)),
  10785. Expression.Constant(value, typeof(TResult)),
  10786. Expression.Constant(scheduler, typeof(IScheduler))
  10787. )
  10788. );
  10789. }
  10790. /// <summary>
  10791. /// Repeats the observable sequence indefinitely.
  10792. /// </summary>
  10793. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10794. /// <param name="source">Observable sequence to repeat.</param>
  10795. /// <returns>The observable sequence producing the elements of the given sequence repeatedly and sequentially.</returns>
  10796. /// <exception cref="T:System.ArgumentNullException">
  10797. /// <paramref name="source" /> is null.</exception>
  10798. public static IQbservable<TSource> Repeat<TSource>(this IQbservable<TSource> source)
  10799. {
  10800. if (source == null)
  10801. throw new ArgumentNullException("source");
  10802. return source.Provider.CreateQuery<TSource>(
  10803. Expression.Call(
  10804. null,
  10805. #if CRIPPLED_REFLECTION
  10806. InfoOf(() => Qbservable.Repeat<TSource>(default(IQbservable<TSource>))),
  10807. #else
  10808. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10809. #endif
  10810. source.Expression
  10811. )
  10812. );
  10813. }
  10814. /// <summary>
  10815. /// Repeats the observable sequence a specified number of times.
  10816. /// </summary>
  10817. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10818. /// <param name="source">Observable sequence to repeat.</param>
  10819. /// <param name="repeatCount">Number of times to repeat the sequence.</param>
  10820. /// <returns>The observable sequence producing the elements of the given sequence repeatedly.</returns>
  10821. /// <exception cref="T:System.ArgumentNullException">
  10822. /// <paramref name="source" /> is null.</exception>
  10823. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10824. /// <paramref name="repeatCount" /> is less than zero.</exception>
  10825. public static IQbservable<TSource> Repeat<TSource>(this IQbservable<TSource> source, int repeatCount)
  10826. {
  10827. if (source == null)
  10828. throw new ArgumentNullException("source");
  10829. return source.Provider.CreateQuery<TSource>(
  10830. Expression.Call(
  10831. null,
  10832. #if CRIPPLED_REFLECTION
  10833. InfoOf(() => Qbservable.Repeat<TSource>(default(IQbservable<TSource>), default(int))),
  10834. #else
  10835. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10836. #endif
  10837. source.Expression,
  10838. Expression.Constant(repeatCount, typeof(int))
  10839. )
  10840. );
  10841. }
  10842. /// <summary>
  10843. /// 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.
  10844. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10845. /// </summary>
  10846. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10847. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10848. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10849. /// <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>
  10850. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10851. /// <exception cref="T:System.ArgumentNullException">
  10852. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10853. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10854. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector)
  10855. {
  10856. if (source == null)
  10857. throw new ArgumentNullException("source");
  10858. if (selector == null)
  10859. throw new ArgumentNullException("selector");
  10860. return source.Provider.CreateQuery<TResult>(
  10861. Expression.Call(
  10862. null,
  10863. #if CRIPPLED_REFLECTION
  10864. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>))),
  10865. #else
  10866. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10867. #endif
  10868. source.Expression,
  10869. selector
  10870. )
  10871. );
  10872. }
  10873. /// <summary>
  10874. /// 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.
  10875. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10876. /// </summary>
  10877. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10878. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10879. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10880. /// <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>
  10881. /// <param name="bufferSize">Maximum element count of the replay buffer.</param>
  10882. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10883. /// <exception cref="T:System.ArgumentNullException">
  10884. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10885. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10886. /// <paramref name="bufferSize" /> is less than zero.</exception>
  10887. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10888. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, int bufferSize)
  10889. {
  10890. if (source == null)
  10891. throw new ArgumentNullException("source");
  10892. if (selector == null)
  10893. throw new ArgumentNullException("selector");
  10894. return source.Provider.CreateQuery<TResult>(
  10895. Expression.Call(
  10896. null,
  10897. #if CRIPPLED_REFLECTION
  10898. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(int))),
  10899. #else
  10900. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10901. #endif
  10902. source.Expression,
  10903. selector,
  10904. Expression.Constant(bufferSize, typeof(int))
  10905. )
  10906. );
  10907. }
  10908. /// <summary>
  10909. /// 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.
  10910. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10911. /// </summary>
  10912. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10913. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10914. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10915. /// <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>
  10916. /// <param name="bufferSize">Maximum element count of the replay buffer.</param>
  10917. /// <param name="scheduler">Scheduler where connected observers within the selector function will be invoked on.</param>
  10918. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10919. /// <exception cref="T:System.ArgumentNullException">
  10920. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="scheduler" /> is null.</exception>
  10921. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10922. /// <paramref name="bufferSize" /> is less than zero.</exception>
  10923. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10924. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, int bufferSize, IScheduler scheduler)
  10925. {
  10926. if (source == null)
  10927. throw new ArgumentNullException("source");
  10928. if (selector == null)
  10929. throw new ArgumentNullException("selector");
  10930. if (scheduler == null)
  10931. throw new ArgumentNullException("scheduler");
  10932. return source.Provider.CreateQuery<TResult>(
  10933. Expression.Call(
  10934. null,
  10935. #if CRIPPLED_REFLECTION
  10936. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(int), default(IScheduler))),
  10937. #else
  10938. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10939. #endif
  10940. source.Expression,
  10941. selector,
  10942. Expression.Constant(bufferSize, typeof(int)),
  10943. Expression.Constant(scheduler, typeof(IScheduler))
  10944. )
  10945. );
  10946. }
  10947. /// <summary>
  10948. /// 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.
  10949. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10950. /// </summary>
  10951. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10952. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10953. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10954. /// <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>
  10955. /// <param name="bufferSize">Maximum element count of the replay buffer.</param>
  10956. /// <param name="window">Maximum time length of the replay buffer.</param>
  10957. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10958. /// <exception cref="T:System.ArgumentNullException">
  10959. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10960. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10961. /// <paramref name="bufferSize" /> is less than zero.</exception>
  10962. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10963. /// <paramref name="window" /> is less than TimeSpan.Zero.</exception>
  10964. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10965. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, int bufferSize, TimeSpan window)
  10966. {
  10967. if (source == null)
  10968. throw new ArgumentNullException("source");
  10969. if (selector == null)
  10970. throw new ArgumentNullException("selector");
  10971. return source.Provider.CreateQuery<TResult>(
  10972. Expression.Call(
  10973. null,
  10974. #if CRIPPLED_REFLECTION
  10975. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(int), default(TimeSpan))),
  10976. #else
  10977. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10978. #endif
  10979. source.Expression,
  10980. selector,
  10981. Expression.Constant(bufferSize, typeof(int)),
  10982. Expression.Constant(window, typeof(TimeSpan))
  10983. )
  10984. );
  10985. }
  10986. /// <summary>
  10987. /// 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.
  10988. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10989. /// </summary>
  10990. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10991. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10992. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10993. /// <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>
  10994. /// <param name="bufferSize">Maximum element count of the replay buffer.</param>
  10995. /// <param name="window">Maximum time length of the replay buffer.</param>
  10996. /// <param name="scheduler">Scheduler where connected observers within the selector function will be invoked on.</param>
  10997. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10998. /// <exception cref="T:System.ArgumentNullException">
  10999. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="scheduler" /> is null.</exception>
  11000. /// <exception cref="T:System.ArgumentOutOfRangeException">
  11001. /// <paramref name="bufferSize" /> is less than zero.</exception>
  11002. /// <exception cref="T:System.ArgumentOutOfRangeException">
  11003. /// <paramref name="window" /> is less than TimeSpan.Zero.</exception>
  11004. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  11005. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, int bufferSize, TimeSpan window, IScheduler scheduler)
  11006. {
  11007. if (source == null)
  11008. throw new ArgumentNullException("source");
  11009. if (selector == null)
  11010. throw new ArgumentNullException("selector");
  11011. if (scheduler == null)
  11012. throw new ArgumentNullException("scheduler");
  11013. return source.Provider.CreateQuery<TResult>(
  11014. Expression.Call(
  11015. null,
  11016. #if CRIPPLED_REFLECTION
  11017. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(int), default(TimeSpan), default(IScheduler))),
  11018. #else
  11019. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11020. #endif
  11021. source.Expression,
  11022. selector,
  11023. Expression.Constant(bufferSize, typeof(int)),
  11024. Expression.Constant(window, typeof(TimeSpan)),
  11025. Expression.Constant(scheduler, typeof(IScheduler))
  11026. )
  11027. );
  11028. }
  11029. /// <summary>
  11030. /// 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.
  11031. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  11032. /// </summary>
  11033. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11034. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  11035. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  11036. /// <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>
  11037. /// <param name="scheduler">Scheduler where connected observers within the selector function will be invoked on.</param>
  11038. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  11039. /// <exception cref="T:System.ArgumentNullException">
  11040. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="scheduler" /> is null.</exception>
  11041. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  11042. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, IScheduler scheduler)
  11043. {
  11044. if (source == null)
  11045. throw new ArgumentNullException("source");
  11046. if (selector == null)
  11047. throw new ArgumentNullException("selector");
  11048. if (scheduler == null)
  11049. throw new ArgumentNullException("scheduler");
  11050. return source.Provider.CreateQuery<TResult>(
  11051. Expression.Call(
  11052. null,
  11053. #if CRIPPLED_REFLECTION
  11054. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(IScheduler))),
  11055. #else
  11056. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11057. #endif
  11058. source.Expression,
  11059. selector,
  11060. Expression.Constant(scheduler, typeof(IScheduler))
  11061. )
  11062. );
  11063. }
  11064. /// <summary>
  11065. /// 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.
  11066. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  11067. /// </summary>
  11068. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11069. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  11070. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  11071. /// <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>
  11072. /// <param name="window">Maximum time length of the replay buffer.</param>
  11073. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  11074. /// <exception cref="T:System.ArgumentNullException">
  11075. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11076. /// <exception cref="T:System.ArgumentOutOfRangeException">
  11077. /// <paramref name="window" /> is less than TimeSpan.Zero.</exception>
  11078. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  11079. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, TimeSpan window)
  11080. {
  11081. if (source == null)
  11082. throw new ArgumentNullException("source");
  11083. if (selector == null)
  11084. throw new ArgumentNullException("selector");
  11085. return source.Provider.CreateQuery<TResult>(
  11086. Expression.Call(
  11087. null,
  11088. #if CRIPPLED_REFLECTION
  11089. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(TimeSpan))),
  11090. #else
  11091. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11092. #endif
  11093. source.Expression,
  11094. selector,
  11095. Expression.Constant(window, typeof(TimeSpan))
  11096. )
  11097. );
  11098. }
  11099. /// <summary>
  11100. /// 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.
  11101. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  11102. /// </summary>
  11103. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11104. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  11105. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  11106. /// <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>
  11107. /// <param name="window">Maximum time length of the replay buffer.</param>
  11108. /// <param name="scheduler">Scheduler where connected observers within the selector function will be invoked on.</param>
  11109. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  11110. /// <exception cref="T:System.ArgumentNullException">
  11111. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="scheduler" /> is null.</exception>
  11112. /// <exception cref="T:System.ArgumentOutOfRangeException">
  11113. /// <paramref name="window" /> is less than TimeSpan.Zero.</exception>
  11114. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  11115. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, TimeSpan window, IScheduler scheduler)
  11116. {
  11117. if (source == null)
  11118. throw new ArgumentNullException("source");
  11119. if (selector == null)
  11120. throw new ArgumentNullException("selector");
  11121. if (scheduler == null)
  11122. throw new ArgumentNullException("scheduler");
  11123. return source.Provider.CreateQuery<TResult>(
  11124. Expression.Call(
  11125. null,
  11126. #if CRIPPLED_REFLECTION
  11127. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(TimeSpan), default(IScheduler))),
  11128. #else
  11129. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11130. #endif
  11131. source.Expression,
  11132. selector,
  11133. Expression.Constant(window, typeof(TimeSpan)),
  11134. Expression.Constant(scheduler, typeof(IScheduler))
  11135. )
  11136. );
  11137. }
  11138. /// <summary>
  11139. /// Repeats the source observable sequence until it successfully terminates.
  11140. /// </summary>
  11141. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11142. /// <param name="source">Observable sequence to repeat until it successfully terminates.</param>
  11143. /// <returns>An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.</returns>
  11144. /// <exception cref="T:System.ArgumentNullException">
  11145. /// <paramref name="source" /> is null.</exception>
  11146. public static IQbservable<TSource> Retry<TSource>(this IQbservable<TSource> source)
  11147. {
  11148. if (source == null)
  11149. throw new ArgumentNullException("source");
  11150. return source.Provider.CreateQuery<TSource>(
  11151. Expression.Call(
  11152. null,
  11153. #if CRIPPLED_REFLECTION
  11154. InfoOf(() => Qbservable.Retry<TSource>(default(IQbservable<TSource>))),
  11155. #else
  11156. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11157. #endif
  11158. source.Expression
  11159. )
  11160. );
  11161. }
  11162. /// <summary>
  11163. /// Repeats the source observable sequence the specified number of times or until it successfully terminates.
  11164. /// </summary>
  11165. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11166. /// <param name="source">Observable sequence to repeat until it successfully terminates.</param>
  11167. /// <param name="retryCount">Number of times to repeat the sequence.</param>
  11168. /// <returns>An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.</returns>
  11169. /// <exception cref="T:System.ArgumentNullException">
  11170. /// <paramref name="source" /> is null.</exception>
  11171. /// <exception cref="T:System.ArgumentOutOfRangeException">
  11172. /// <paramref name="retryCount" /> is less than zero.</exception>
  11173. public static IQbservable<TSource> Retry<TSource>(this IQbservable<TSource> source, int retryCount)
  11174. {
  11175. if (source == null)
  11176. throw new ArgumentNullException("source");
  11177. return source.Provider.CreateQuery<TSource>(
  11178. Expression.Call(
  11179. null,
  11180. #if CRIPPLED_REFLECTION
  11181. InfoOf(() => Qbservable.Retry<TSource>(default(IQbservable<TSource>), default(int))),
  11182. #else
  11183. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11184. #endif
  11185. source.Expression,
  11186. Expression.Constant(retryCount, typeof(int))
  11187. )
  11188. );
  11189. }
  11190. /// <summary>
  11191. /// Returns an observable sequence that contains a single element.
  11192. /// </summary>
  11193. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  11194. /// <typeparam name="TResult">The type of the element that will be returned in the produced sequence.</typeparam>
  11195. /// <param name="value">Single element in the resulting observable sequence.</param>
  11196. /// <returns>An observable sequence containing the single specified element.</returns>
  11197. public static IQbservable<TResult> Return<TResult>(this IQbservableProvider provider, TResult value)
  11198. {
  11199. if (provider == null)
  11200. throw new ArgumentNullException("provider");
  11201. return provider.CreateQuery<TResult>(
  11202. Expression.Call(
  11203. null,
  11204. #if CRIPPLED_REFLECTION
  11205. InfoOf(() => Qbservable.Return<TResult>(default(IQbservableProvider), default(TResult))),
  11206. #else
  11207. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  11208. #endif
  11209. Expression.Constant(provider, typeof(IQbservableProvider)),
  11210. Expression.Constant(value, typeof(TResult))
  11211. )
  11212. );
  11213. }
  11214. /// <summary>
  11215. /// Returns an observable sequence that contains a single element, using the specified scheduler to send out observer messages.
  11216. /// </summary>
  11217. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  11218. /// <typeparam name="TResult">The type of the element that will be returned in the produced sequence.</typeparam>
  11219. /// <param name="value">Single element in the resulting observable sequence.</param>
  11220. /// <param name="scheduler">Scheduler to send the single element on.</param>
  11221. /// <returns>An observable sequence containing the single specified element.</returns>
  11222. /// <exception cref="T:System.ArgumentNullException">
  11223. /// <paramref name="scheduler" /> is null.</exception>
  11224. public static IQbservable<TResult> Return<TResult>(this IQbservableProvider provider, TResult value, IScheduler scheduler)
  11225. {
  11226. if (provider == null)
  11227. throw new ArgumentNullException("provider");
  11228. if (scheduler == null)
  11229. throw new ArgumentNullException("scheduler");
  11230. return provider.CreateQuery<TResult>(
  11231. Expression.Call(
  11232. null,
  11233. #if CRIPPLED_REFLECTION
  11234. InfoOf(() => Qbservable.Return<TResult>(default(IQbservableProvider), default(TResult), default(IScheduler))),
  11235. #else
  11236. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  11237. #endif
  11238. Expression.Constant(provider, typeof(IQbservableProvider)),
  11239. Expression.Constant(value, typeof(TResult)),
  11240. Expression.Constant(scheduler, typeof(IScheduler))
  11241. )
  11242. );
  11243. }
  11244. /// <summary>
  11245. /// Samples the observable sequence at each interval.
  11246. /// Upon each sampling tick, the latest element (if any) in the source sequence during the last sampling interval is sent to the resulting sequence.
  11247. /// </summary>
  11248. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11249. /// <param name="source">Source sequence to sample.</param>
  11250. /// <param name="interval">Interval at which to sample. If this value is equal to TimeSpan.Zero, the scheduler will continuously sample the stream.</param>
  11251. /// <returns>Sampled observable sequence.</returns>
  11252. /// <exception cref="T:System.ArgumentNullException">
  11253. /// <paramref name="source" /> is null.</exception>
  11254. /// <exception cref="T:System.ArgumentOutOfRangeException">
  11255. /// <paramref name="interval" /> is less than TimeSpan.Zero.</exception>
  11256. /// <remarks>
  11257. /// Specifying a TimeSpan.Zero value for <paramref name="interval" /> doesn't guarantee all source sequence elements will be preserved. This is a side-effect
  11258. /// of the asynchrony introduced by the scheduler, where the sampling action may not execute immediately, despite the TimeSpan.Zero due time.
  11259. /// </remarks>
  11260. public static IQbservable<TSource> Sample<TSource>(this IQbservable<TSource> source, TimeSpan interval)
  11261. {
  11262. if (source == null)
  11263. throw new ArgumentNullException("source");
  11264. return source.Provider.CreateQuery<TSource>(
  11265. Expression.Call(
  11266. null,
  11267. #if CRIPPLED_REFLECTION
  11268. InfoOf(() => Qbservable.Sample<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  11269. #else
  11270. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11271. #endif
  11272. source.Expression,
  11273. Expression.Constant(interval, typeof(TimeSpan))
  11274. )
  11275. );
  11276. }
  11277. /// <summary>
  11278. /// Samples the observable sequence at each interval, using the specified scheduler to run sampling timers.
  11279. /// Upon each sampling tick, the latest element (if any) in the source sequence during the last sampling interval is sent to the resulting sequence.
  11280. /// </summary>
  11281. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11282. /// <param name="source">Source sequence to sample.</param>
  11283. /// <param name="interval">Interval at which to sample. If this value is equal to TimeSpan.Zero, the scheduler will continuously sample the stream.</param>
  11284. /// <param name="scheduler">Scheduler to run the sampling timer on.</param>
  11285. /// <returns>Sampled observable sequence.</returns>
  11286. /// <exception cref="T:System.ArgumentNullException">
  11287. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  11288. /// <exception cref="T:System.ArgumentOutOfRangeException">
  11289. /// <paramref name="interval" /> is less than TimeSpan.Zero.</exception>
  11290. /// <remarks>
  11291. /// Specifying a TimeSpan.Zero value for <paramref name="interval" /> doesn't guarantee all source sequence elements will be preserved. This is a side-effect
  11292. /// of the asynchrony introduced by the scheduler, where the sampling action may not execute immediately, despite the TimeSpan.Zero due time.
  11293. /// </remarks>
  11294. public static IQbservable<TSource> Sample<TSource>(this IQbservable<TSource> source, TimeSpan interval, IScheduler scheduler)
  11295. {
  11296. if (source == null)
  11297. throw new ArgumentNullException("source");
  11298. if (scheduler == null)
  11299. throw new ArgumentNullException("scheduler");
  11300. return source.Provider.CreateQuery<TSource>(
  11301. Expression.Call(
  11302. null,
  11303. #if CRIPPLED_REFLECTION
  11304. InfoOf(() => Qbservable.Sample<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  11305. #else
  11306. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11307. #endif
  11308. source.Expression,
  11309. Expression.Constant(interval, typeof(TimeSpan)),
  11310. Expression.Constant(scheduler, typeof(IScheduler))
  11311. )
  11312. );
  11313. }
  11314. /// <summary>
  11315. /// Samples the source observable sequence using a samper observable sequence producing sampling ticks.
  11316. /// Upon each sampling tick, the latest element (if any) in the source sequence during the last sampling interval is sent to the resulting sequence.
  11317. /// </summary>
  11318. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11319. /// <typeparam name="TSample">The type of the elements in the sampling sequence.</typeparam>
  11320. /// <param name="source">Source sequence to sample.</param>
  11321. /// <param name="sampler">Sampling tick sequence.</param>
  11322. /// <returns>Sampled observable sequence.</returns>
  11323. /// <exception cref="T:System.ArgumentNullException">
  11324. /// <paramref name="source" /> or <paramref name="sampler" /> is null.</exception>
  11325. public static IQbservable<TSource> Sample<TSource, TSample>(this IQbservable<TSource> source, IObservable<TSample> sampler)
  11326. {
  11327. if (source == null)
  11328. throw new ArgumentNullException("source");
  11329. if (sampler == null)
  11330. throw new ArgumentNullException("sampler");
  11331. return source.Provider.CreateQuery<TSource>(
  11332. Expression.Call(
  11333. null,
  11334. #if CRIPPLED_REFLECTION
  11335. InfoOf(() => Qbservable.Sample<TSource, TSample>(default(IQbservable<TSource>), default(IObservable<TSample>))),
  11336. #else
  11337. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TSample)),
  11338. #endif
  11339. source.Expression,
  11340. GetSourceExpression(sampler)
  11341. )
  11342. );
  11343. }
  11344. /// <summary>
  11345. /// Applies an accumulator function over an observable sequence and returns each intermediate result.
  11346. /// 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})" />.
  11347. /// </summary>
  11348. /// <typeparam name="TSource">The type of the elements in the source sequence and the result of the aggregation.</typeparam>
  11349. /// <param name="source">An observable sequence to accumulate over.</param>
  11350. /// <param name="accumulator">An accumulator function to be invoked on each element.</param>
  11351. /// <returns>An observable sequence containing the accumulated values.</returns>
  11352. /// <exception cref="T:System.ArgumentNullException">
  11353. /// <paramref name="source" /> or <paramref name="accumulator" /> is null.</exception>
  11354. public static IQbservable<TSource> Scan<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, TSource, TSource>> accumulator)
  11355. {
  11356. if (source == null)
  11357. throw new ArgumentNullException("source");
  11358. if (accumulator == null)
  11359. throw new ArgumentNullException("accumulator");
  11360. return source.Provider.CreateQuery<TSource>(
  11361. Expression.Call(
  11362. null,
  11363. #if CRIPPLED_REFLECTION
  11364. InfoOf(() => Qbservable.Scan<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, TSource, TSource>>))),
  11365. #else
  11366. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11367. #endif
  11368. source.Expression,
  11369. accumulator
  11370. )
  11371. );
  11372. }
  11373. /// <summary>
  11374. /// Applies an accumulator function over an observable sequence and returns each intermediate result. The specified seed value is used as the initial accumulator value.
  11375. /// 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})" />.
  11376. /// </summary>
  11377. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11378. /// <typeparam name="TAccumulate">The type of the result of the aggregation.</typeparam>
  11379. /// <param name="source">An observable sequence to accumulate over.</param>
  11380. /// <param name="seed">The initial accumulator value.</param>
  11381. /// <param name="accumulator">An accumulator function to be invoked on each element.</param>
  11382. /// <returns>An observable sequence containing the accumulated values.</returns>
  11383. /// <exception cref="T:System.ArgumentNullException">
  11384. /// <paramref name="source" /> or <paramref name="accumulator" /> is null.</exception>
  11385. public static IQbservable<TAccumulate> Scan<TSource, TAccumulate>(this IQbservable<TSource> source, TAccumulate seed, Expression<Func<TAccumulate, TSource, TAccumulate>> accumulator)
  11386. {
  11387. if (source == null)
  11388. throw new ArgumentNullException("source");
  11389. if (accumulator == null)
  11390. throw new ArgumentNullException("accumulator");
  11391. return source.Provider.CreateQuery<TAccumulate>(
  11392. Expression.Call(
  11393. null,
  11394. #if CRIPPLED_REFLECTION
  11395. InfoOf(() => Qbservable.Scan<TSource, TAccumulate>(default(IQbservable<TSource>), default(TAccumulate), default(Expression<Func<TAccumulate, TSource, TAccumulate>>))),
  11396. #else
  11397. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)),
  11398. #endif
  11399. source.Expression,
  11400. Expression.Constant(seed, typeof(TAccumulate)),
  11401. accumulator
  11402. )
  11403. );
  11404. }
  11405. /// <summary>
  11406. /// Projects each element of an observable sequence into a new form.
  11407. /// </summary>
  11408. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11409. /// <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>
  11410. /// <param name="source">A sequence of elements to invoke a transform function on.</param>
  11411. /// <param name="selector">A transform function to apply to each source element.</param>
  11412. /// <returns>An observable sequence whose elements are the result of invoking the transform function on each element of source.</returns>
  11413. /// <exception cref="T:System.ArgumentNullException">
  11414. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11415. public static IQbservable<TResult> Select<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector)
  11416. {
  11417. if (source == null)
  11418. throw new ArgumentNullException("source");
  11419. if (selector == null)
  11420. throw new ArgumentNullException("selector");
  11421. return source.Provider.CreateQuery<TResult>(
  11422. Expression.Call(
  11423. null,
  11424. #if CRIPPLED_REFLECTION
  11425. InfoOf(() => Qbservable.Select<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>))),
  11426. #else
  11427. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11428. #endif
  11429. source.Expression,
  11430. selector
  11431. )
  11432. );
  11433. }
  11434. /// <summary>
  11435. /// Projects each element of an observable sequence into a new form by incorporating the element's index.
  11436. /// </summary>
  11437. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11438. /// <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>
  11439. /// <param name="source">A sequence of elements to invoke a transform function on.</param>
  11440. /// <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>
  11441. /// <returns>An observable sequence whose elements are the result of invoking the transform function on each element of source.</returns>
  11442. /// <exception cref="T:System.ArgumentNullException">
  11443. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11444. public static IQbservable<TResult> Select<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, TResult>> selector)
  11445. {
  11446. if (source == null)
  11447. throw new ArgumentNullException("source");
  11448. if (selector == null)
  11449. throw new ArgumentNullException("selector");
  11450. return source.Provider.CreateQuery<TResult>(
  11451. Expression.Call(
  11452. null,
  11453. #if CRIPPLED_REFLECTION
  11454. InfoOf(() => Qbservable.Select<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, TResult>>))),
  11455. #else
  11456. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11457. #endif
  11458. source.Expression,
  11459. selector
  11460. )
  11461. );
  11462. }
  11463. /// <summary>
  11464. /// 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.
  11465. /// </summary>
  11466. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11467. /// <typeparam name="TCollection">The type of the elements in the projected intermediate sequences.</typeparam>
  11468. /// <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>
  11469. /// <param name="source">An observable sequence of elements to project.</param>
  11470. /// <param name="collectionSelector">A transform function to apply to each element.</param>
  11471. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
  11472. /// <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>
  11473. /// <exception cref="T:System.ArgumentNullException">
  11474. /// <paramref name="source" /> or <paramref name="collectionSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11475. public static IQbservable<TResult> SelectMany<TSource, TCollection, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TCollection>>> collectionSelector, Expression<Func<TSource, TCollection, TResult>> resultSelector)
  11476. {
  11477. if (source == null)
  11478. throw new ArgumentNullException("source");
  11479. if (collectionSelector == null)
  11480. throw new ArgumentNullException("collectionSelector");
  11481. if (resultSelector == null)
  11482. throw new ArgumentNullException("resultSelector");
  11483. return source.Provider.CreateQuery<TResult>(
  11484. Expression.Call(
  11485. null,
  11486. #if CRIPPLED_REFLECTION
  11487. InfoOf(() => Qbservable.SelectMany<TSource, TCollection, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TCollection>>>), default(Expression<Func<TSource, TCollection, TResult>>))),
  11488. #else
  11489. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)),
  11490. #endif
  11491. source.Expression,
  11492. collectionSelector,
  11493. resultSelector
  11494. )
  11495. );
  11496. }
  11497. /// <summary>
  11498. /// Projects each element of an observable sequence to an observable sequence by incorporating the element's index, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
  11499. /// </summary>
  11500. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11501. /// <typeparam name="TCollection">The type of the elements in the projected intermediate sequences.</typeparam>
  11502. /// <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>
  11503. /// <param name="source">An observable sequence of elements to project.</param>
  11504. /// <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>
  11505. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence; the second parameter of the function represents the index of the source element and the fourth parameter represents the index of the intermediate element.</param>
  11506. /// <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>
  11507. /// <exception cref="T:System.ArgumentNullException">
  11508. /// <paramref name="source" /> or <paramref name="collectionSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11509. 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)
  11510. {
  11511. if (source == null)
  11512. throw new ArgumentNullException("source");
  11513. if (collectionSelector == null)
  11514. throw new ArgumentNullException("collectionSelector");
  11515. if (resultSelector == null)
  11516. throw new ArgumentNullException("resultSelector");
  11517. return source.Provider.CreateQuery<TResult>(
  11518. Expression.Call(
  11519. null,
  11520. #if CRIPPLED_REFLECTION
  11521. InfoOf(() => Qbservable.SelectMany<TSource, TCollection, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, IObservable<TCollection>>>), default(Expression<Func<TSource, int, TCollection, int, TResult>>))),
  11522. #else
  11523. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)),
  11524. #endif
  11525. source.Expression,
  11526. collectionSelector,
  11527. resultSelector
  11528. )
  11529. );
  11530. }
  11531. /// <summary>
  11532. /// 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.
  11533. /// </summary>
  11534. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11535. /// <typeparam name="TCollection">The type of the elements in the projected intermediate enumerable sequences.</typeparam>
  11536. /// <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>
  11537. /// <param name="source">An observable sequence of elements to project.</param>
  11538. /// <param name="collectionSelector">A transform function to apply to each element.</param>
  11539. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
  11540. /// <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>
  11541. /// <exception cref="T:System.ArgumentNullException">
  11542. /// <paramref name="source" /> or <paramref name="collectionSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11543. /// <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>
  11544. public static IQbservable<TResult> SelectMany<TSource, TCollection, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, IEnumerable<TCollection>>> collectionSelector, Expression<Func<TSource, TCollection, TResult>> resultSelector)
  11545. {
  11546. if (source == null)
  11547. throw new ArgumentNullException("source");
  11548. if (collectionSelector == null)
  11549. throw new ArgumentNullException("collectionSelector");
  11550. if (resultSelector == null)
  11551. throw new ArgumentNullException("resultSelector");
  11552. return source.Provider.CreateQuery<TResult>(
  11553. Expression.Call(
  11554. null,
  11555. #if CRIPPLED_REFLECTION
  11556. InfoOf(() => Qbservable.SelectMany<TSource, TCollection, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, IEnumerable<TCollection>>>), default(Expression<Func<TSource, TCollection, TResult>>))),
  11557. #else
  11558. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)),
  11559. #endif
  11560. source.Expression,
  11561. collectionSelector,
  11562. resultSelector
  11563. )
  11564. );
  11565. }
  11566. /// <summary>
  11567. /// Projects each element of an observable sequence to an enumerable sequence by incorporating the element's index, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
  11568. /// </summary>
  11569. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11570. /// <typeparam name="TCollection">The type of the elements in the projected intermediate enumerable sequences.</typeparam>
  11571. /// <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>
  11572. /// <param name="source">An observable sequence of elements to project.</param>
  11573. /// <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>
  11574. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence; the second parameter of the function represents the index of the source element and the fourth parameter represents the index of the intermediate element.</param>
  11575. /// <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>
  11576. /// <exception cref="T:System.ArgumentNullException">
  11577. /// <paramref name="source" /> or <paramref name="collectionSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11578. /// <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>
  11579. 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)
  11580. {
  11581. if (source == null)
  11582. throw new ArgumentNullException("source");
  11583. if (collectionSelector == null)
  11584. throw new ArgumentNullException("collectionSelector");
  11585. if (resultSelector == null)
  11586. throw new ArgumentNullException("resultSelector");
  11587. return source.Provider.CreateQuery<TResult>(
  11588. Expression.Call(
  11589. null,
  11590. #if CRIPPLED_REFLECTION
  11591. InfoOf(() => Qbservable.SelectMany<TSource, TCollection, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, IEnumerable<TCollection>>>), default(Expression<Func<TSource, int, TCollection, int, TResult>>))),
  11592. #else
  11593. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)),
  11594. #endif
  11595. source.Expression,
  11596. collectionSelector,
  11597. resultSelector
  11598. )
  11599. );
  11600. }
  11601. /// <summary>
  11602. /// Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
  11603. /// </summary>
  11604. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11605. /// <typeparam name="TOther">The type of the elements in the other sequence and the elements in the result sequence.</typeparam>
  11606. /// <param name="source">An observable sequence of elements to project.</param>
  11607. /// <param name="other">An observable sequence to project each element from the source sequence onto.</param>
  11608. /// <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>
  11609. /// <exception cref="T:System.ArgumentNullException">
  11610. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  11611. public static IQbservable<TOther> SelectMany<TSource, TOther>(this IQbservable<TSource> source, IObservable<TOther> other)
  11612. {
  11613. if (source == null)
  11614. throw new ArgumentNullException("source");
  11615. if (other == null)
  11616. throw new ArgumentNullException("other");
  11617. return source.Provider.CreateQuery<TOther>(
  11618. Expression.Call(
  11619. null,
  11620. #if CRIPPLED_REFLECTION
  11621. InfoOf(() => Qbservable.SelectMany<TSource, TOther>(default(IQbservable<TSource>), default(IObservable<TOther>))),
  11622. #else
  11623. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)),
  11624. #endif
  11625. source.Expression,
  11626. GetSourceExpression(other)
  11627. )
  11628. );
  11629. }
  11630. /// <summary>
  11631. /// Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  11632. /// </summary>
  11633. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11634. /// <typeparam name="TResult">The type of the elements in the projected inner sequences and the elements in the merged result sequence.</typeparam>
  11635. /// <param name="source">An observable sequence of notifications to project.</param>
  11636. /// <param name="onNext">A transform function to apply to each element.</param>
  11637. /// <param name="onError">A transform function to apply when an error occurs in the source sequence.</param>
  11638. /// <param name="onCompleted">A transform function to apply when the end of the source sequence is reached.</param>
  11639. /// <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>
  11640. /// <exception cref="T:System.ArgumentNullException">
  11641. /// <paramref name="source" /> or <paramref name="onNext" /> or <paramref name="onError" /> or <paramref name="onCompleted" /> is null.</exception>
  11642. 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)
  11643. {
  11644. if (source == null)
  11645. throw new ArgumentNullException("source");
  11646. if (onNext == null)
  11647. throw new ArgumentNullException("onNext");
  11648. if (onError == null)
  11649. throw new ArgumentNullException("onError");
  11650. if (onCompleted == null)
  11651. throw new ArgumentNullException("onCompleted");
  11652. return source.Provider.CreateQuery<TResult>(
  11653. Expression.Call(
  11654. null,
  11655. #if CRIPPLED_REFLECTION
  11656. 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>>>))),
  11657. #else
  11658. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11659. #endif
  11660. source.Expression,
  11661. onNext,
  11662. onError,
  11663. onCompleted
  11664. )
  11665. );
  11666. }
  11667. /// <summary>
  11668. /// Projects each notification of an observable sequence to an observable sequence by incorporating the element's index and merges the resulting observable sequences into one observable sequence.
  11669. /// </summary>
  11670. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11671. /// <typeparam name="TResult">The type of the elements in the projected inner sequences and the elements in the merged result sequence.</typeparam>
  11672. /// <param name="source">An observable sequence of notifications to project.</param>
  11673. /// <param name="onNext">A transform function to apply to each element; the second parameter of the function represents the index of the source element.</param>
  11674. /// <param name="onError">A transform function to apply when an error occurs in the source sequence.</param>
  11675. /// <param name="onCompleted">A transform function to apply when the end of the source sequence is reached.</param>
  11676. /// <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>
  11677. /// <exception cref="T:System.ArgumentNullException">
  11678. /// <paramref name="source" /> or <paramref name="onNext" /> or <paramref name="onError" /> or <paramref name="onCompleted" /> is null.</exception>
  11679. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, IObservable<TResult>>> onNext, Expression<Func<Exception, IObservable<TResult>>> onError, Expression<Func<IObservable<TResult>>> onCompleted)
  11680. {
  11681. if (source == null)
  11682. throw new ArgumentNullException("source");
  11683. if (onNext == null)
  11684. throw new ArgumentNullException("onNext");
  11685. if (onError == null)
  11686. throw new ArgumentNullException("onError");
  11687. if (onCompleted == null)
  11688. throw new ArgumentNullException("onCompleted");
  11689. return source.Provider.CreateQuery<TResult>(
  11690. Expression.Call(
  11691. null,
  11692. #if CRIPPLED_REFLECTION
  11693. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, IObservable<TResult>>>), default(Expression<Func<Exception, IObservable<TResult>>>), default(Expression<Func<IObservable<TResult>>>))),
  11694. #else
  11695. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11696. #endif
  11697. source.Expression,
  11698. onNext,
  11699. onError,
  11700. onCompleted
  11701. )
  11702. );
  11703. }
  11704. #if !NO_TPL
  11705. /// <summary>
  11706. /// Projects each element of an observable sequence to a task with cancellation support and merges all of the task results into one observable sequence.
  11707. /// </summary>
  11708. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11709. /// <typeparam name="TResult">The type of the result produced by the projected tasks and the elements in the merged result sequence.</typeparam>
  11710. /// <param name="source">An observable sequence of elements to project.</param>
  11711. /// <param name="selector">A transform function to apply to each element.</param>
  11712. /// <returns>An observable sequence whose elements are the result of the tasks executed for each element of the input sequence.</returns>
  11713. /// <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>
  11714. /// <exception cref="T:System.ArgumentNullException">
  11715. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11716. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, CancellationToken, Task<TResult>>> selector)
  11717. {
  11718. if (source == null)
  11719. throw new ArgumentNullException("source");
  11720. if (selector == null)
  11721. throw new ArgumentNullException("selector");
  11722. return source.Provider.CreateQuery<TResult>(
  11723. Expression.Call(
  11724. null,
  11725. #if CRIPPLED_REFLECTION
  11726. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, CancellationToken, Task<TResult>>>))),
  11727. #else
  11728. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11729. #endif
  11730. source.Expression,
  11731. selector
  11732. )
  11733. );
  11734. }
  11735. #endif
  11736. #if !NO_TPL
  11737. /// <summary>
  11738. /// Projects each element of an observable sequence to a task by incorporating the element's index with cancellation support and merges all of the task results into one observable sequence.
  11739. /// </summary>
  11740. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11741. /// <typeparam name="TResult">The type of the result produced by the projected tasks and the elements in the merged result sequence.</typeparam>
  11742. /// <param name="source">An observable sequence of elements to project.</param>
  11743. /// <param name="selector">A transform function to apply to each element; the second parameter of the function represents the index of the source element.</param>
  11744. /// <returns>An observable sequence whose elements are the result of the tasks executed for each element of the input sequence.</returns>
  11745. /// <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>
  11746. /// <exception cref="T:System.ArgumentNullException">
  11747. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11748. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, CancellationToken, Task<TResult>>> selector)
  11749. {
  11750. if (source == null)
  11751. throw new ArgumentNullException("source");
  11752. if (selector == null)
  11753. throw new ArgumentNullException("selector");
  11754. return source.Provider.CreateQuery<TResult>(
  11755. Expression.Call(
  11756. null,
  11757. #if CRIPPLED_REFLECTION
  11758. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, CancellationToken, Task<TResult>>>))),
  11759. #else
  11760. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11761. #endif
  11762. source.Expression,
  11763. selector
  11764. )
  11765. );
  11766. }
  11767. #endif
  11768. /// <summary>
  11769. /// Projects each element of an observable sequence to an enumerable sequence and concatenates the resulting enumerable sequences into one observable sequence.
  11770. /// </summary>
  11771. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11772. /// <typeparam name="TResult">The type of the elements in the projected inner enumerable sequences and the elements in the merged result sequence.</typeparam>
  11773. /// <param name="source">An observable sequence of elements to project.</param>
  11774. /// <param name="selector">A transform function to apply to each element.</param>
  11775. /// <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>
  11776. /// <exception cref="T:System.ArgumentNullException">
  11777. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11778. /// <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>
  11779. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, IEnumerable<TResult>>> selector)
  11780. {
  11781. if (source == null)
  11782. throw new ArgumentNullException("source");
  11783. if (selector == null)
  11784. throw new ArgumentNullException("selector");
  11785. return source.Provider.CreateQuery<TResult>(
  11786. Expression.Call(
  11787. null,
  11788. #if CRIPPLED_REFLECTION
  11789. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, IEnumerable<TResult>>>))),
  11790. #else
  11791. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11792. #endif
  11793. source.Expression,
  11794. selector
  11795. )
  11796. );
  11797. }
  11798. /// <summary>
  11799. /// Projects each element of an observable sequence to an enumerable sequence by incorporating the element's index and concatenates the resulting enumerable sequences into one observable sequence.
  11800. /// </summary>
  11801. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11802. /// <typeparam name="TResult">The type of the elements in the projected inner enumerable sequences and the elements in the merged result sequence.</typeparam>
  11803. /// <param name="source">An observable sequence of elements to project.</param>
  11804. /// <param name="selector">A transform function to apply to each element; the second parameter of the function represents the index of the source element.</param>
  11805. /// <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>
  11806. /// <exception cref="T:System.ArgumentNullException">
  11807. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11808. /// <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>
  11809. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, IEnumerable<TResult>>> selector)
  11810. {
  11811. if (source == null)
  11812. throw new ArgumentNullException("source");
  11813. if (selector == null)
  11814. throw new ArgumentNullException("selector");
  11815. return source.Provider.CreateQuery<TResult>(
  11816. Expression.Call(
  11817. null,
  11818. #if CRIPPLED_REFLECTION
  11819. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, IEnumerable<TResult>>>))),
  11820. #else
  11821. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11822. #endif
  11823. source.Expression,
  11824. selector
  11825. )
  11826. );
  11827. }
  11828. /// <summary>
  11829. /// Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  11830. /// </summary>
  11831. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11832. /// <typeparam name="TResult">The type of the elements in the projected inner sequences and the elements in the merged result sequence.</typeparam>
  11833. /// <param name="source">An observable sequence of elements to project.</param>
  11834. /// <param name="selector">A transform function to apply to each element.</param>
  11835. /// <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>
  11836. /// <exception cref="T:System.ArgumentNullException">
  11837. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11838. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TResult>>> selector)
  11839. {
  11840. if (source == null)
  11841. throw new ArgumentNullException("source");
  11842. if (selector == null)
  11843. throw new ArgumentNullException("selector");
  11844. return source.Provider.CreateQuery<TResult>(
  11845. Expression.Call(
  11846. null,
  11847. #if CRIPPLED_REFLECTION
  11848. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TResult>>>))),
  11849. #else
  11850. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11851. #endif
  11852. source.Expression,
  11853. selector
  11854. )
  11855. );
  11856. }
  11857. /// <summary>
  11858. /// Projects each element of an observable sequence to an observable sequence by incorporating the element's index and merges the resulting observable sequences into one observable sequence.
  11859. /// </summary>
  11860. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11861. /// <typeparam name="TResult">The type of the elements in the projected inner sequences and the elements in the merged result sequence.</typeparam>
  11862. /// <param name="source">An observable sequence of elements to project.</param>
  11863. /// <param name="selector">A transform function to apply to each element; the second parameter of the function represents the index of the source element.</param>
  11864. /// <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>
  11865. /// <exception cref="T:System.ArgumentNullException">
  11866. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11867. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, IObservable<TResult>>> selector)
  11868. {
  11869. if (source == null)
  11870. throw new ArgumentNullException("source");
  11871. if (selector == null)
  11872. throw new ArgumentNullException("selector");
  11873. return source.Provider.CreateQuery<TResult>(
  11874. Expression.Call(
  11875. null,
  11876. #if CRIPPLED_REFLECTION
  11877. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, IObservable<TResult>>>))),
  11878. #else
  11879. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11880. #endif
  11881. source.Expression,
  11882. selector
  11883. )
  11884. );
  11885. }
  11886. #if !NO_TPL
  11887. /// <summary>
  11888. /// Projects each element of an observable sequence to a task and merges all of the task results into one observable sequence.
  11889. /// </summary>
  11890. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11891. /// <typeparam name="TResult">The type of the result produced by the projected tasks and the elements in the merged result sequence.</typeparam>
  11892. /// <param name="source">An observable sequence of elements to project.</param>
  11893. /// <param name="selector">A transform function to apply to each element.</param>
  11894. /// <returns>An observable sequence whose elements are the result of the tasks executed for each element of the input sequence.</returns>
  11895. /// <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>
  11896. /// <exception cref="T:System.ArgumentNullException">
  11897. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11898. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, Task<TResult>>> selector)
  11899. {
  11900. if (source == null)
  11901. throw new ArgumentNullException("source");
  11902. if (selector == null)
  11903. throw new ArgumentNullException("selector");
  11904. return source.Provider.CreateQuery<TResult>(
  11905. Expression.Call(
  11906. null,
  11907. #if CRIPPLED_REFLECTION
  11908. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, Task<TResult>>>))),
  11909. #else
  11910. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11911. #endif
  11912. source.Expression,
  11913. selector
  11914. )
  11915. );
  11916. }
  11917. #endif
  11918. #if !NO_TPL
  11919. /// <summary>
  11920. /// Projects each element of an observable sequence to a task by incorporating the element's index and merges all of the task results into one observable sequence.
  11921. /// </summary>
  11922. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11923. /// <typeparam name="TResult">The type of the result produced by the projected tasks and the elements in the merged result sequence.</typeparam>
  11924. /// <param name="source">An observable sequence of elements to project.</param>
  11925. /// <param name="selector">A transform function to apply to each element; the second parameter of the function represents the index of the source element.</param>
  11926. /// <returns>An observable sequence whose elements are the result of the tasks executed for each element of the input sequence.</returns>
  11927. /// <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>
  11928. /// <exception cref="T:System.ArgumentNullException">
  11929. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11930. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, Task<TResult>>> selector)
  11931. {
  11932. if (source == null)
  11933. throw new ArgumentNullException("source");
  11934. if (selector == null)
  11935. throw new ArgumentNullException("selector");
  11936. return source.Provider.CreateQuery<TResult>(
  11937. Expression.Call(
  11938. null,
  11939. #if CRIPPLED_REFLECTION
  11940. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, Task<TResult>>>))),
  11941. #else
  11942. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11943. #endif
  11944. source.Expression,
  11945. selector
  11946. )
  11947. );
  11948. }
  11949. #endif
  11950. #if !NO_TPL
  11951. /// <summary>
  11952. /// 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.
  11953. /// </summary>
  11954. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11955. /// <typeparam name="TTaskResult">The type of the results produced by the projected intermediate tasks.</typeparam>
  11956. /// <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>
  11957. /// <param name="source">An observable sequence of elements to project.</param>
  11958. /// <param name="taskSelector">A transform function to apply to each element.</param>
  11959. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
  11960. /// <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>
  11961. /// <exception cref="T:System.ArgumentNullException">
  11962. /// <paramref name="source" /> or <paramref name="taskSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11963. /// <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>
  11964. public static IQbservable<TResult> SelectMany<TSource, TTaskResult, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, Task<TTaskResult>>> taskSelector, Expression<Func<TSource, TTaskResult, TResult>> resultSelector)
  11965. {
  11966. if (source == null)
  11967. throw new ArgumentNullException("source");
  11968. if (taskSelector == null)
  11969. throw new ArgumentNullException("taskSelector");
  11970. if (resultSelector == null)
  11971. throw new ArgumentNullException("resultSelector");
  11972. return source.Provider.CreateQuery<TResult>(
  11973. Expression.Call(
  11974. null,
  11975. #if CRIPPLED_REFLECTION
  11976. InfoOf(() => Qbservable.SelectMany<TSource, TTaskResult, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, Task<TTaskResult>>>), default(Expression<Func<TSource, TTaskResult, TResult>>))),
  11977. #else
  11978. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTaskResult), typeof(TResult)),
  11979. #endif
  11980. source.Expression,
  11981. taskSelector,
  11982. resultSelector
  11983. )
  11984. );
  11985. }
  11986. #endif
  11987. #if !NO_TPL
  11988. /// <summary>
  11989. /// Projects each element of an observable sequence to a task by incorporating the element's index, invokes the result selector for the source element and the task result, and merges the results into one observable sequence.
  11990. /// </summary>
  11991. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11992. /// <typeparam name="TTaskResult">The type of the results produced by the projected intermediate tasks.</typeparam>
  11993. /// <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>
  11994. /// <param name="source">An observable sequence of elements to project.</param>
  11995. /// <param name="taskSelector">A transform function to apply to each element; the second parameter of the function represents the index of the source element.</param>
  11996. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence; the second parameter of the function represents the index of the source element.</param>
  11997. /// <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>
  11998. /// <exception cref="T:System.ArgumentNullException">
  11999. /// <paramref name="source" /> or <paramref name="taskSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  12000. /// <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>
  12001. public static IQbservable<TResult> SelectMany<TSource, TTaskResult, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, Task<TTaskResult>>> taskSelector, Expression<Func<TSource, int, TTaskResult, TResult>> resultSelector)
  12002. {
  12003. if (source == null)
  12004. throw new ArgumentNullException("source");
  12005. if (taskSelector == null)
  12006. throw new ArgumentNullException("taskSelector");
  12007. if (resultSelector == null)
  12008. throw new ArgumentNullException("resultSelector");
  12009. return source.Provider.CreateQuery<TResult>(
  12010. Expression.Call(
  12011. null,
  12012. #if CRIPPLED_REFLECTION
  12013. InfoOf(() => Qbservable.SelectMany<TSource, TTaskResult, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, Task<TTaskResult>>>), default(Expression<Func<TSource, int, TTaskResult, TResult>>))),
  12014. #else
  12015. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTaskResult), typeof(TResult)),
  12016. #endif
  12017. source.Expression,
  12018. taskSelector,
  12019. resultSelector
  12020. )
  12021. );
  12022. }
  12023. #endif
  12024. #if !NO_TPL
  12025. /// <summary>
  12026. /// 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.
  12027. /// </summary>
  12028. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12029. /// <typeparam name="TTaskResult">The type of the results produced by the projected intermediate tasks.</typeparam>
  12030. /// <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>
  12031. /// <param name="source">An observable sequence of elements to project.</param>
  12032. /// <param name="taskSelector">A transform function to apply to each element.</param>
  12033. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
  12034. /// <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>
  12035. /// <exception cref="T:System.ArgumentNullException">
  12036. /// <paramref name="source" /> or <paramref name="taskSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  12037. /// <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>
  12038. 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)
  12039. {
  12040. if (source == null)
  12041. throw new ArgumentNullException("source");
  12042. if (taskSelector == null)
  12043. throw new ArgumentNullException("taskSelector");
  12044. if (resultSelector == null)
  12045. throw new ArgumentNullException("resultSelector");
  12046. return source.Provider.CreateQuery<TResult>(
  12047. Expression.Call(
  12048. null,
  12049. #if CRIPPLED_REFLECTION
  12050. InfoOf(() => Qbservable.SelectMany<TSource, TTaskResult, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, CancellationToken, Task<TTaskResult>>>), default(Expression<Func<TSource, TTaskResult, TResult>>))),
  12051. #else
  12052. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTaskResult), typeof(TResult)),
  12053. #endif
  12054. source.Expression,
  12055. taskSelector,
  12056. resultSelector
  12057. )
  12058. );
  12059. }
  12060. #endif
  12061. #if !NO_TPL
  12062. /// <summary>
  12063. /// Projects each element of an observable sequence to a task by incorporating the element's index with cancellation support, invokes the result selector for the source element and the task result, and merges the results into one observable sequence.
  12064. /// </summary>
  12065. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12066. /// <typeparam name="TTaskResult">The type of the results produced by the projected intermediate tasks.</typeparam>
  12067. /// <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>
  12068. /// <param name="source">An observable sequence of elements to project.</param>
  12069. /// <param name="taskSelector">A transform function to apply to each element; the second parameter of the function represents the index of the source element.</param>
  12070. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence; the second parameter of the function represents the index of the source element.</param>
  12071. /// <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>
  12072. /// <exception cref="T:System.ArgumentNullException">
  12073. /// <paramref name="source" /> or <paramref name="taskSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  12074. /// <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>
  12075. public static IQbservable<TResult> SelectMany<TSource, TTaskResult, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, CancellationToken, Task<TTaskResult>>> taskSelector, Expression<Func<TSource, int, TTaskResult, TResult>> resultSelector)
  12076. {
  12077. if (source == null)
  12078. throw new ArgumentNullException("source");
  12079. if (taskSelector == null)
  12080. throw new ArgumentNullException("taskSelector");
  12081. if (resultSelector == null)
  12082. throw new ArgumentNullException("resultSelector");
  12083. return source.Provider.CreateQuery<TResult>(
  12084. Expression.Call(
  12085. null,
  12086. #if CRIPPLED_REFLECTION
  12087. InfoOf(() => Qbservable.SelectMany<TSource, TTaskResult, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, CancellationToken, Task<TTaskResult>>>), default(Expression<Func<TSource, int, TTaskResult, TResult>>))),
  12088. #else
  12089. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTaskResult), typeof(TResult)),
  12090. #endif
  12091. source.Expression,
  12092. taskSelector,
  12093. resultSelector
  12094. )
  12095. );
  12096. }
  12097. #endif
  12098. /// <summary>
  12099. /// Determines whether two sequences are equal by comparing the elements pairwise.
  12100. /// </summary>
  12101. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12102. /// <param name="first">First observable sequence to compare.</param>
  12103. /// <param name="second">Second observable sequence to compare.</param>
  12104. /// <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>
  12105. /// <exception cref="T:System.ArgumentNullException">
  12106. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  12107. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12108. public static IQbservable<bool> SequenceEqual<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  12109. {
  12110. if (first == null)
  12111. throw new ArgumentNullException("first");
  12112. if (second == null)
  12113. throw new ArgumentNullException("second");
  12114. return first.Provider.CreateQuery<bool>(
  12115. Expression.Call(
  12116. null,
  12117. #if CRIPPLED_REFLECTION
  12118. InfoOf(() => Qbservable.SequenceEqual<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  12119. #else
  12120. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12121. #endif
  12122. first.Expression,
  12123. GetSourceExpression(second)
  12124. )
  12125. );
  12126. }
  12127. /// <summary>
  12128. /// Determines whether an observable and enumerable sequence are equal by comparing the elements pairwise.
  12129. /// </summary>
  12130. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12131. /// <param name="first">First observable sequence to compare.</param>
  12132. /// <param name="second">Second observable sequence to compare.</param>
  12133. /// <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>
  12134. /// <exception cref="T:System.ArgumentNullException">
  12135. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  12136. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12137. public static IQbservable<bool> SequenceEqual<TSource>(this IQbservable<TSource> first, IEnumerable<TSource> second)
  12138. {
  12139. if (first == null)
  12140. throw new ArgumentNullException("first");
  12141. if (second == null)
  12142. throw new ArgumentNullException("second");
  12143. return first.Provider.CreateQuery<bool>(
  12144. Expression.Call(
  12145. null,
  12146. #if CRIPPLED_REFLECTION
  12147. InfoOf(() => Qbservable.SequenceEqual<TSource>(default(IQbservable<TSource>), default(IEnumerable<TSource>))),
  12148. #else
  12149. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12150. #endif
  12151. first.Expression,
  12152. GetSourceExpression(second)
  12153. )
  12154. );
  12155. }
  12156. /// <summary>
  12157. /// Determines whether two sequences are equal by comparing the elements pairwise using a specified equality comparer.
  12158. /// </summary>
  12159. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12160. /// <param name="first">First observable sequence to compare.</param>
  12161. /// <param name="second">Second observable sequence to compare.</param>
  12162. /// <param name="comparer">Comparer used to compare elements of both sequences.</param>
  12163. /// <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>
  12164. /// <exception cref="T:System.ArgumentNullException">
  12165. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="comparer" /> is null.</exception>
  12166. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12167. public static IQbservable<bool> SequenceEqual<TSource>(this IQbservable<TSource> first, IObservable<TSource> second, IEqualityComparer<TSource> comparer)
  12168. {
  12169. if (first == null)
  12170. throw new ArgumentNullException("first");
  12171. if (second == null)
  12172. throw new ArgumentNullException("second");
  12173. if (comparer == null)
  12174. throw new ArgumentNullException("comparer");
  12175. return first.Provider.CreateQuery<bool>(
  12176. Expression.Call(
  12177. null,
  12178. #if CRIPPLED_REFLECTION
  12179. InfoOf(() => Qbservable.SequenceEqual<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>), default(IEqualityComparer<TSource>))),
  12180. #else
  12181. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12182. #endif
  12183. first.Expression,
  12184. GetSourceExpression(second),
  12185. Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))
  12186. )
  12187. );
  12188. }
  12189. /// <summary>
  12190. /// Determines whether an observable and enumerable sequence are equal by comparing the elements pairwise using a specified equality comparer.
  12191. /// </summary>
  12192. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12193. /// <param name="first">First observable sequence to compare.</param>
  12194. /// <param name="second">Second observable sequence to compare.</param>
  12195. /// <param name="comparer">Comparer used to compare elements of both sequences.</param>
  12196. /// <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>
  12197. /// <exception cref="T:System.ArgumentNullException">
  12198. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="comparer" /> is null.</exception>
  12199. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12200. public static IQbservable<bool> SequenceEqual<TSource>(this IQbservable<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
  12201. {
  12202. if (first == null)
  12203. throw new ArgumentNullException("first");
  12204. if (second == null)
  12205. throw new ArgumentNullException("second");
  12206. if (comparer == null)
  12207. throw new ArgumentNullException("comparer");
  12208. return first.Provider.CreateQuery<bool>(
  12209. Expression.Call(
  12210. null,
  12211. #if CRIPPLED_REFLECTION
  12212. InfoOf(() => Qbservable.SequenceEqual<TSource>(default(IQbservable<TSource>), default(IEnumerable<TSource>), default(IEqualityComparer<TSource>))),
  12213. #else
  12214. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12215. #endif
  12216. first.Expression,
  12217. GetSourceExpression(second),
  12218. Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))
  12219. )
  12220. );
  12221. }
  12222. /// <summary>
  12223. /// Returns the only element of an observable sequence, and reports an exception if there is not exactly one element in the observable sequence.
  12224. /// </summary>
  12225. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12226. /// <param name="source">Source observable sequence.</param>
  12227. /// <returns>Sequence containing the single element in the observable sequence.</returns>
  12228. /// <exception cref="T:System.ArgumentNullException">
  12229. /// <paramref name="source" /> is null.</exception>
  12230. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence contains more than one element. -or- The source sequence is empty.</exception>
  12231. public static IQbservable<TSource> SingleAsync<TSource>(this IQbservable<TSource> source)
  12232. {
  12233. if (source == null)
  12234. throw new ArgumentNullException("source");
  12235. return source.Provider.CreateQuery<TSource>(
  12236. Expression.Call(
  12237. null,
  12238. #if CRIPPLED_REFLECTION
  12239. InfoOf(() => Qbservable.SingleAsync<TSource>(default(IQbservable<TSource>))),
  12240. #else
  12241. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12242. #endif
  12243. source.Expression
  12244. )
  12245. );
  12246. }
  12247. /// <summary>
  12248. /// 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.
  12249. /// </summary>
  12250. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12251. /// <param name="source">Source observable sequence.</param>
  12252. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  12253. /// <returns>Sequence containing the single element in the observable sequence that satisfies the condition in the predicate.</returns>
  12254. /// <exception cref="T:System.ArgumentNullException">
  12255. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  12256. /// <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>
  12257. public static IQbservable<TSource> SingleAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  12258. {
  12259. if (source == null)
  12260. throw new ArgumentNullException("source");
  12261. if (predicate == null)
  12262. throw new ArgumentNullException("predicate");
  12263. return source.Provider.CreateQuery<TSource>(
  12264. Expression.Call(
  12265. null,
  12266. #if CRIPPLED_REFLECTION
  12267. InfoOf(() => Qbservable.SingleAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  12268. #else
  12269. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12270. #endif
  12271. source.Expression,
  12272. predicate
  12273. )
  12274. );
  12275. }
  12276. /// <summary>
  12277. /// 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.
  12278. /// </summary>
  12279. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12280. /// <param name="source">Source observable sequence.</param>
  12281. /// <returns>Sequence containing the single element in the observable sequence, or a default value if no such element exists.</returns>
  12282. /// <exception cref="T:System.ArgumentNullException">
  12283. /// <paramref name="source" /> is null.</exception>
  12284. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence contains more than one element.</exception>
  12285. public static IQbservable<TSource> SingleOrDefaultAsync<TSource>(this IQbservable<TSource> source)
  12286. {
  12287. if (source == null)
  12288. throw new ArgumentNullException("source");
  12289. return source.Provider.CreateQuery<TSource>(
  12290. Expression.Call(
  12291. null,
  12292. #if CRIPPLED_REFLECTION
  12293. InfoOf(() => Qbservable.SingleOrDefaultAsync<TSource>(default(IQbservable<TSource>))),
  12294. #else
  12295. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12296. #endif
  12297. source.Expression
  12298. )
  12299. );
  12300. }
  12301. /// <summary>
  12302. /// 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.
  12303. /// </summary>
  12304. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12305. /// <param name="source">Source observable sequence.</param>
  12306. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  12307. /// <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>
  12308. /// <exception cref="T:System.ArgumentNullException">
  12309. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  12310. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The sequence contains more than one element that satisfies the condition in the predicate.</exception>
  12311. public static IQbservable<TSource> SingleOrDefaultAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  12312. {
  12313. if (source == null)
  12314. throw new ArgumentNullException("source");
  12315. if (predicate == null)
  12316. throw new ArgumentNullException("predicate");
  12317. return source.Provider.CreateQuery<TSource>(
  12318. Expression.Call(
  12319. null,
  12320. #if CRIPPLED_REFLECTION
  12321. InfoOf(() => Qbservable.SingleOrDefaultAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  12322. #else
  12323. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12324. #endif
  12325. source.Expression,
  12326. predicate
  12327. )
  12328. );
  12329. }
  12330. /// <summary>
  12331. /// Bypasses a specified number of elements in an observable sequence and then returns the remaining elements.
  12332. /// </summary>
  12333. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12334. /// <param name="source">The sequence to take elements from.</param>
  12335. /// <param name="count">The number of elements to skip before returning the remaining elements.</param>
  12336. /// <returns>An observable sequence that contains the elements that occur after the specified index in the input sequence.</returns>
  12337. /// <exception cref="T:System.ArgumentNullException">
  12338. /// <paramref name="source" /> is null.</exception>
  12339. /// <exception cref="T:System.ArgumentOutOfRangeException">
  12340. /// <paramref name="count" /> is less than zero.</exception>
  12341. public static IQbservable<TSource> Skip<TSource>(this IQbservable<TSource> source, int count)
  12342. {
  12343. if (source == null)
  12344. throw new ArgumentNullException("source");
  12345. return source.Provider.CreateQuery<TSource>(
  12346. Expression.Call(
  12347. null,
  12348. #if CRIPPLED_REFLECTION
  12349. InfoOf(() => Qbservable.Skip<TSource>(default(IQbservable<TSource>), default(int))),
  12350. #else
  12351. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12352. #endif
  12353. source.Expression,
  12354. Expression.Constant(count, typeof(int))
  12355. )
  12356. );
  12357. }
  12358. /// <summary>
  12359. /// Skips elements for the specified duration from the start of the observable source sequence.
  12360. /// </summary>
  12361. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12362. /// <param name="source">Source sequence to skip elements for.</param>
  12363. /// <param name="duration">Duration for skipping elements from the start of the sequence.</param>
  12364. /// <returns>An observable sequence with the elements skipped during the specified duration from the start of the source sequence.</returns>
  12365. /// <exception cref="T:System.ArgumentNullException">
  12366. /// <paramref name="source" /> is null.</exception>
  12367. /// <exception cref="T:System.ArgumentOutOfRangeException">
  12368. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  12369. /// <remarks>
  12370. /// <para>
  12371. /// Specifying a TimeSpan.Zero value for <paramref name="duration" /> doesn't guarantee no elements will be dropped from the start of the source sequence.
  12372. /// 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
  12373. /// may not execute immediately, despite the TimeSpan.Zero due time.
  12374. /// </para>
  12375. /// <para>
  12376. /// Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the <paramref name="duration" />.
  12377. /// </para>
  12378. /// </remarks>
  12379. public static IQbservable<TSource> Skip<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  12380. {
  12381. if (source == null)
  12382. throw new ArgumentNullException("source");
  12383. return source.Provider.CreateQuery<TSource>(
  12384. Expression.Call(
  12385. null,
  12386. #if CRIPPLED_REFLECTION
  12387. InfoOf(() => Qbservable.Skip<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  12388. #else
  12389. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12390. #endif
  12391. source.Expression,
  12392. Expression.Constant(duration, typeof(TimeSpan))
  12393. )
  12394. );
  12395. }
  12396. /// <summary>
  12397. /// Skips elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers.
  12398. /// </summary>
  12399. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12400. /// <param name="source">Source sequence to skip elements for.</param>
  12401. /// <param name="duration">Duration for skipping elements from the start of the sequence.</param>
  12402. /// <param name="scheduler">Scheduler to run the timer on.</param>
  12403. /// <returns>An observable sequence with the elements skipped during the specified duration from the start of the source sequence.</returns>
  12404. /// <exception cref="T:System.ArgumentNullException">
  12405. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  12406. /// <exception cref="T:System.ArgumentOutOfRangeException">
  12407. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  12408. /// <remarks>
  12409. /// <para>
  12410. /// Specifying a TimeSpan.Zero value for <paramref name="duration" /> doesn't guarantee no elements will be dropped from the start of the source sequence.
  12411. /// 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
  12412. /// may not execute immediately, despite the TimeSpan.Zero due time.
  12413. /// </para>
  12414. /// <para>
  12415. /// Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the <paramref name="duration" />.
  12416. /// </para>
  12417. /// </remarks>
  12418. public static IQbservable<TSource> Skip<TSource>(this IQbservable<TSource> source, TimeSpan duration, 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.Skip<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  12429. #else
  12430. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12431. #endif
  12432. source.Expression,
  12433. Expression.Constant(duration, typeof(TimeSpan)),
  12434. Expression.Constant(scheduler, typeof(IScheduler))
  12435. )
  12436. );
  12437. }
  12438. /// <summary>
  12439. /// Bypasses a specified number of elements at the end of an observable sequence.
  12440. /// </summary>
  12441. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12442. /// <param name="source">Source sequence.</param>
  12443. /// <param name="count">Number of elements to bypass at the end of the source sequence.</param>
  12444. /// <returns>An observable sequence containing the source sequence elements except for the bypassed ones at the end.</returns>
  12445. /// <exception cref="T:System.ArgumentNullException">
  12446. /// <paramref name="source" /> is null.</exception>
  12447. /// <exception cref="T:System.ArgumentOutOfRangeException">
  12448. /// <paramref name="count" /> is less than zero.</exception>
  12449. /// <remarks>
  12450. /// This operator accumulates a queue with a length enough to store the first <paramref name="count" /> elements. As more elements are
  12451. /// received, elements are taken from the front of the queue and produced on the result sequence. This causes elements to be delayed.
  12452. /// </remarks>
  12453. public static IQbservable<TSource> SkipLast<TSource>(this IQbservable<TSource> source, int count)
  12454. {
  12455. if (source == null)
  12456. throw new ArgumentNullException("source");
  12457. return source.Provider.CreateQuery<TSource>(
  12458. Expression.Call(
  12459. null,
  12460. #if CRIPPLED_REFLECTION
  12461. InfoOf(() => Qbservable.SkipLast<TSource>(default(IQbservable<TSource>), default(int))),
  12462. #else
  12463. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12464. #endif
  12465. source.Expression,
  12466. Expression.Constant(count, typeof(int))
  12467. )
  12468. );
  12469. }
  12470. /// <summary>
  12471. /// Skips elements for the specified duration from the end of the observable source sequence.
  12472. /// </summary>
  12473. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12474. /// <param name="source">Source sequence to skip elements for.</param>
  12475. /// <param name="duration">Duration for skipping elements from the end of the sequence.</param>
  12476. /// <returns>An observable sequence with the elements skipped during the specified duration from the end of the source sequence.</returns>
  12477. /// <exception cref="T:System.ArgumentNullException">
  12478. /// <paramref name="source" /> is null.</exception>
  12479. /// <exception cref="T:System.ArgumentOutOfRangeException">
  12480. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  12481. /// <remarks>
  12482. /// This operator accumulates a queue with a length enough to store elements received during the initial <paramref name="duration" /> window.
  12483. /// As more elements are received, elements older than the specified <paramref name="duration" /> are taken from the queue and produced on the
  12484. /// result sequence. This causes elements to be delayed with <paramref name="duration" />.
  12485. /// </remarks>
  12486. public static IQbservable<TSource> SkipLast<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  12487. {
  12488. if (source == null)
  12489. throw new ArgumentNullException("source");
  12490. return source.Provider.CreateQuery<TSource>(
  12491. Expression.Call(
  12492. null,
  12493. #if CRIPPLED_REFLECTION
  12494. InfoOf(() => Qbservable.SkipLast<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  12495. #else
  12496. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12497. #endif
  12498. source.Expression,
  12499. Expression.Constant(duration, typeof(TimeSpan))
  12500. )
  12501. );
  12502. }
  12503. /// <summary>
  12504. /// Skips elements for the specified duration from the end of the observable source sequence, using the specified scheduler to run timers.
  12505. /// </summary>
  12506. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12507. /// <param name="source">Source sequence to skip elements for.</param>
  12508. /// <param name="duration">Duration for skipping elements from the end of the sequence.</param>
  12509. /// <param name="scheduler">Scheduler to run the timer on.</param>
  12510. /// <returns>An observable sequence with the elements skipped during the specified duration from the end of the source sequence.</returns>
  12511. /// <exception cref="T:System.ArgumentNullException">
  12512. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  12513. /// <exception cref="T:System.ArgumentOutOfRangeException">
  12514. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  12515. /// <remarks>
  12516. /// This operator accumulates a queue with a length enough to store elements received during the initial <paramref name="duration" /> window.
  12517. /// As more elements are received, elements older than the specified <paramref name="duration" /> are taken from the queue and produced on the
  12518. /// result sequence. This causes elements to be delayed with <paramref name="duration" />.
  12519. /// </remarks>
  12520. public static IQbservable<TSource> SkipLast<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  12521. {
  12522. if (source == null)
  12523. throw new ArgumentNullException("source");
  12524. if (scheduler == null)
  12525. throw new ArgumentNullException("scheduler");
  12526. return source.Provider.CreateQuery<TSource>(
  12527. Expression.Call(
  12528. null,
  12529. #if CRIPPLED_REFLECTION
  12530. InfoOf(() => Qbservable.SkipLast<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  12531. #else
  12532. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12533. #endif
  12534. source.Expression,
  12535. Expression.Constant(duration, typeof(TimeSpan)),
  12536. Expression.Constant(scheduler, typeof(IScheduler))
  12537. )
  12538. );
  12539. }
  12540. /// <summary>
  12541. /// Skips elements from the observable source sequence until the specified start time.
  12542. /// </summary>
  12543. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12544. /// <param name="source">Source sequence to skip elements for.</param>
  12545. /// <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>
  12546. /// <returns>An observable sequence with the elements skipped until the specified start time.</returns>
  12547. /// <exception cref="T:System.ArgumentNullException">
  12548. /// <paramref name="source" /> is null.</exception>
  12549. /// <remarks>
  12550. /// Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the <paramref name="startTime" />.
  12551. /// </remarks>
  12552. public static IQbservable<TSource> SkipUntil<TSource>(this IQbservable<TSource> source, DateTimeOffset startTime)
  12553. {
  12554. if (source == null)
  12555. throw new ArgumentNullException("source");
  12556. return source.Provider.CreateQuery<TSource>(
  12557. Expression.Call(
  12558. null,
  12559. #if CRIPPLED_REFLECTION
  12560. InfoOf(() => Qbservable.SkipUntil<TSource>(default(IQbservable<TSource>), default(DateTimeOffset))),
  12561. #else
  12562. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12563. #endif
  12564. source.Expression,
  12565. Expression.Constant(startTime, typeof(DateTimeOffset))
  12566. )
  12567. );
  12568. }
  12569. /// <summary>
  12570. /// Skips elements from the observable source sequence until the specified start time, using the specified scheduler to run timers.
  12571. /// </summary>
  12572. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12573. /// <param name="source">Source sequence to skip elements for.</param>
  12574. /// <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>
  12575. /// <param name="scheduler">Scheduler to run the timer on.</param>
  12576. /// <returns>An observable sequence with the elements skipped until the specified start time.</returns>
  12577. /// <exception cref="T:System.ArgumentNullException">
  12578. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  12579. /// <remarks>
  12580. /// Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the <paramref name="startTime" />.
  12581. /// </remarks>
  12582. public static IQbservable<TSource> SkipUntil<TSource>(this IQbservable<TSource> source, DateTimeOffset startTime, IScheduler scheduler)
  12583. {
  12584. if (source == null)
  12585. throw new ArgumentNullException("source");
  12586. if (scheduler == null)
  12587. throw new ArgumentNullException("scheduler");
  12588. return source.Provider.CreateQuery<TSource>(
  12589. Expression.Call(
  12590. null,
  12591. #if CRIPPLED_REFLECTION
  12592. InfoOf(() => Qbservable.SkipUntil<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IScheduler))),
  12593. #else
  12594. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12595. #endif
  12596. source.Expression,
  12597. Expression.Constant(startTime, typeof(DateTimeOffset)),
  12598. Expression.Constant(scheduler, typeof(IScheduler))
  12599. )
  12600. );
  12601. }
  12602. /// <summary>
  12603. /// Returns the elements from the source observable sequence only after the other observable sequence produces an element.
  12604. /// </summary>
  12605. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12606. /// <typeparam name="TOther">The type of the elements in the other sequence that indicates the end of skip behavior.</typeparam>
  12607. /// <param name="source">Source sequence to propagate elements for.</param>
  12608. /// <param name="other">Observable sequence that triggers propagation of elements of the source sequence.</param>
  12609. /// <returns>An observable sequence containing the elements of the source sequence starting from the point the other sequence triggered propagation.</returns>
  12610. /// <exception cref="T:System.ArgumentNullException">
  12611. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  12612. public static IQbservable<TSource> SkipUntil<TSource, TOther>(this IQbservable<TSource> source, IObservable<TOther> other)
  12613. {
  12614. if (source == null)
  12615. throw new ArgumentNullException("source");
  12616. if (other == null)
  12617. throw new ArgumentNullException("other");
  12618. return source.Provider.CreateQuery<TSource>(
  12619. Expression.Call(
  12620. null,
  12621. #if CRIPPLED_REFLECTION
  12622. InfoOf(() => Qbservable.SkipUntil<TSource, TOther>(default(IQbservable<TSource>), default(IObservable<TOther>))),
  12623. #else
  12624. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)),
  12625. #endif
  12626. source.Expression,
  12627. GetSourceExpression(other)
  12628. )
  12629. );
  12630. }
  12631. /// <summary>
  12632. /// Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements.
  12633. /// </summary>
  12634. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12635. /// <param name="source">An observable sequence to return elements from.</param>
  12636. /// <param name="predicate">A function to test each element for a condition.</param>
  12637. /// <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>
  12638. /// <exception cref="T:System.ArgumentNullException">
  12639. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  12640. public static IQbservable<TSource> SkipWhile<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  12641. {
  12642. if (source == null)
  12643. throw new ArgumentNullException("source");
  12644. if (predicate == null)
  12645. throw new ArgumentNullException("predicate");
  12646. return source.Provider.CreateQuery<TSource>(
  12647. Expression.Call(
  12648. null,
  12649. #if CRIPPLED_REFLECTION
  12650. InfoOf(() => Qbservable.SkipWhile<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  12651. #else
  12652. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12653. #endif
  12654. source.Expression,
  12655. predicate
  12656. )
  12657. );
  12658. }
  12659. /// <summary>
  12660. /// Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements.
  12661. /// The element's index is used in the logic of the predicate function.
  12662. /// </summary>
  12663. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12664. /// <param name="source">An observable sequence to return elements from.</param>
  12665. /// <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>
  12666. /// <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>
  12667. /// <exception cref="T:System.ArgumentNullException">
  12668. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  12669. public static IQbservable<TSource> SkipWhile<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int, bool>> predicate)
  12670. {
  12671. if (source == null)
  12672. throw new ArgumentNullException("source");
  12673. if (predicate == null)
  12674. throw new ArgumentNullException("predicate");
  12675. return source.Provider.CreateQuery<TSource>(
  12676. Expression.Call(
  12677. null,
  12678. #if CRIPPLED_REFLECTION
  12679. InfoOf(() => Qbservable.SkipWhile<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, bool>>))),
  12680. #else
  12681. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12682. #endif
  12683. source.Expression,
  12684. predicate
  12685. )
  12686. );
  12687. }
  12688. /// <summary>
  12689. /// Invokes the action asynchronously, surfacing the result through an observable sequence.
  12690. /// </summary>
  12691. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  12692. /// <param name="action">Action to run asynchronously.</param>
  12693. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12694. /// <exception cref="T:System.ArgumentNullException">
  12695. /// <paramref name="action" /> is null.</exception>
  12696. /// <remarks>
  12697. /// <list type="bullet">
  12698. /// <item>
  12699. /// <description>The action is called immediately, not during the subscription of the resulting sequence.</description>
  12700. /// </item>
  12701. /// <item>
  12702. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12703. /// </item>
  12704. /// </list>
  12705. /// </remarks>
  12706. public static IQbservable<Unit> Start(this IQbservableProvider provider, Expression<Action> action)
  12707. {
  12708. if (provider == null)
  12709. throw new ArgumentNullException("provider");
  12710. if (action == null)
  12711. throw new ArgumentNullException("action");
  12712. return provider.CreateQuery<Unit>(
  12713. Expression.Call(
  12714. null,
  12715. #if CRIPPLED_REFLECTION
  12716. InfoOf(() => Qbservable.Start(default(IQbservableProvider), default(Expression<Action>))),
  12717. #else
  12718. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12719. #endif
  12720. Expression.Constant(provider, typeof(IQbservableProvider)),
  12721. action
  12722. )
  12723. );
  12724. }
  12725. /// <summary>
  12726. /// Invokes the action asynchronously on the specified scheduler, surfacing the result through an observable sequence.
  12727. /// </summary>
  12728. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  12729. /// <param name="action">Action to run asynchronously.</param>
  12730. /// <param name="scheduler">Scheduler to run the action on.</param>
  12731. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12732. /// <exception cref="T:System.ArgumentNullException">
  12733. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  12734. /// <remarks>
  12735. /// <list type="bullet">
  12736. /// <item>
  12737. /// <description>The action is called immediately, not during the subscription of the resulting sequence.</description>
  12738. /// </item>
  12739. /// <item>
  12740. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12741. /// </item>
  12742. /// </list>
  12743. /// </remarks>
  12744. public static IQbservable<Unit> Start(this IQbservableProvider provider, Expression<Action> action, IScheduler scheduler)
  12745. {
  12746. if (provider == null)
  12747. throw new ArgumentNullException("provider");
  12748. if (action == null)
  12749. throw new ArgumentNullException("action");
  12750. if (scheduler == null)
  12751. throw new ArgumentNullException("scheduler");
  12752. return provider.CreateQuery<Unit>(
  12753. Expression.Call(
  12754. null,
  12755. #if CRIPPLED_REFLECTION
  12756. InfoOf(() => Qbservable.Start(default(IQbservableProvider), default(Expression<Action>), default(IScheduler))),
  12757. #else
  12758. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12759. #endif
  12760. Expression.Constant(provider, typeof(IQbservableProvider)),
  12761. action,
  12762. Expression.Constant(scheduler, typeof(IScheduler))
  12763. )
  12764. );
  12765. }
  12766. /// <summary>
  12767. /// Invokes the specified function asynchronously, surfacing the result through an observable sequence.
  12768. /// </summary>
  12769. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  12770. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  12771. /// <param name="function">Function to run asynchronously.</param>
  12772. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12773. /// <exception cref="T:System.ArgumentNullException">
  12774. /// <paramref name="function" /> is null.</exception>
  12775. /// <remarks>
  12776. /// <list type="bullet">
  12777. /// <item>
  12778. /// <description>The function is called immediately, not during the subscription of the resulting sequence.</description>
  12779. /// </item>
  12780. /// <item>
  12781. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12782. /// </item>
  12783. /// </list>
  12784. /// </remarks>
  12785. public static IQbservable<TResult> Start<TResult>(this IQbservableProvider provider, Expression<Func<TResult>> function)
  12786. {
  12787. if (provider == null)
  12788. throw new ArgumentNullException("provider");
  12789. if (function == null)
  12790. throw new ArgumentNullException("function");
  12791. return provider.CreateQuery<TResult>(
  12792. Expression.Call(
  12793. null,
  12794. #if CRIPPLED_REFLECTION
  12795. InfoOf(() => Qbservable.Start<TResult>(default(IQbservableProvider), default(Expression<Func<TResult>>))),
  12796. #else
  12797. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12798. #endif
  12799. Expression.Constant(provider, typeof(IQbservableProvider)),
  12800. function
  12801. )
  12802. );
  12803. }
  12804. /// <summary>
  12805. /// Invokes the specified function asynchronously on the specified scheduler, surfacing the result through an observable sequence
  12806. /// </summary>
  12807. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  12808. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  12809. /// <param name="function">Function to run asynchronously.</param>
  12810. /// <param name="scheduler">Scheduler to run the function on.</param>
  12811. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12812. /// <exception cref="T:System.ArgumentNullException">
  12813. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  12814. /// <remarks>
  12815. /// <list type="bullet">
  12816. /// <item>
  12817. /// <description>The function is called immediately, not during the subscription of the resulting sequence.</description>
  12818. /// </item>
  12819. /// <item>
  12820. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12821. /// </item>
  12822. /// </list>
  12823. /// </remarks>
  12824. public static IQbservable<TResult> Start<TResult>(this IQbservableProvider provider, Expression<Func<TResult>> function, IScheduler scheduler)
  12825. {
  12826. if (provider == null)
  12827. throw new ArgumentNullException("provider");
  12828. if (function == null)
  12829. throw new ArgumentNullException("function");
  12830. if (scheduler == null)
  12831. throw new ArgumentNullException("scheduler");
  12832. return provider.CreateQuery<TResult>(
  12833. Expression.Call(
  12834. null,
  12835. #if CRIPPLED_REFLECTION
  12836. InfoOf(() => Qbservable.Start<TResult>(default(IQbservableProvider), default(Expression<Func<TResult>>), default(IScheduler))),
  12837. #else
  12838. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12839. #endif
  12840. Expression.Constant(provider, typeof(IQbservableProvider)),
  12841. function,
  12842. Expression.Constant(scheduler, typeof(IScheduler))
  12843. )
  12844. );
  12845. }
  12846. #if !NO_TPL
  12847. /// <summary>
  12848. /// Invokes the asynchronous action, surfacing the result through an observable sequence.
  12849. /// </summary>
  12850. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  12851. /// <param name="actionAsync">Asynchronous action to run.</param>
  12852. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12853. /// <exception cref="T:System.ArgumentNullException">
  12854. /// <paramref name="actionAsync" /> is null.</exception>
  12855. /// <remarks>
  12856. /// <list type="bullet">
  12857. /// <item>
  12858. /// <description>The action is started immediately, not during the subscription of the resulting sequence.</description>
  12859. /// </item>
  12860. /// <item>
  12861. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12862. /// </item>
  12863. /// </list>
  12864. /// </remarks>
  12865. public static IQbservable<Unit> StartAsync(this IQbservableProvider provider, Expression<Func<Task>> actionAsync)
  12866. {
  12867. if (provider == null)
  12868. throw new ArgumentNullException("provider");
  12869. if (actionAsync == null)
  12870. throw new ArgumentNullException("actionAsync");
  12871. return provider.CreateQuery<Unit>(
  12872. Expression.Call(
  12873. null,
  12874. #if CRIPPLED_REFLECTION
  12875. InfoOf(() => Qbservable.StartAsync(default(IQbservableProvider), default(Expression<Func<Task>>))),
  12876. #else
  12877. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12878. #endif
  12879. Expression.Constant(provider, typeof(IQbservableProvider)),
  12880. actionAsync
  12881. )
  12882. );
  12883. }
  12884. #endif
  12885. #if !NO_TPL
  12886. /// <summary>
  12887. /// Invokes the asynchronous action, surfacing the result through an observable sequence.
  12888. /// The CancellationToken is shared by all subscriptions on the resulting observable sequence. See the remarks section for more information.
  12889. /// </summary>
  12890. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  12891. /// <param name="actionAsync">Asynchronous action to run.</param>
  12892. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12893. /// <exception cref="T:System.ArgumentNullException">
  12894. /// <paramref name="actionAsync" /> is null.</exception>
  12895. /// <remarks>
  12896. /// <list type="bullet">
  12897. /// <item>
  12898. /// <description>The action is started immediately, not during the subscription of the resulting sequence.</description>
  12899. /// </item>
  12900. /// <item>
  12901. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12902. /// </item>
  12903. /// <item>
  12904. /// <description>
  12905. /// If any subscription to the resulting sequence is disposed, the CancellationToken is set. The observer associated to the disposed
  12906. /// subscription won't see the TaskCanceledException, but other observers will. You can protect against this using the Catch operator.
  12907. /// Be careful when handing out the resulting sequence because of this behavior. The most common use is to have a single subscription
  12908. /// to the resulting sequence, which controls the CancellationToken state. Alternatively, you can control subscription behavior using
  12909. /// multicast operators.
  12910. /// </description>
  12911. /// </item>
  12912. /// </list>
  12913. /// </remarks>
  12914. public static IQbservable<Unit> StartAsync(this IQbservableProvider provider, Expression<Func<CancellationToken, Task>> actionAsync)
  12915. {
  12916. if (provider == null)
  12917. throw new ArgumentNullException("provider");
  12918. if (actionAsync == null)
  12919. throw new ArgumentNullException("actionAsync");
  12920. return provider.CreateQuery<Unit>(
  12921. Expression.Call(
  12922. null,
  12923. #if CRIPPLED_REFLECTION
  12924. InfoOf(() => Qbservable.StartAsync(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task>>))),
  12925. #else
  12926. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12927. #endif
  12928. Expression.Constant(provider, typeof(IQbservableProvider)),
  12929. actionAsync
  12930. )
  12931. );
  12932. }
  12933. #endif
  12934. #if !NO_TPL
  12935. /// <summary>
  12936. /// Invokes the asynchronous function, surfacing the result through an observable sequence.
  12937. /// </summary>
  12938. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  12939. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  12940. /// <param name="functionAsync">Asynchronous function to run.</param>
  12941. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12942. /// <exception cref="T:System.ArgumentNullException">
  12943. /// <paramref name="functionAsync" /> is null.</exception>
  12944. /// <remarks>
  12945. /// <list type="bullet">
  12946. /// <item>
  12947. /// <description>The function is started immediately, not during the subscription of the resulting sequence.</description>
  12948. /// </item>
  12949. /// <item>
  12950. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12951. /// </item>
  12952. /// </list>
  12953. /// </remarks>
  12954. public static IQbservable<TResult> StartAsync<TResult>(this IQbservableProvider provider, Expression<Func<Task<TResult>>> functionAsync)
  12955. {
  12956. if (provider == null)
  12957. throw new ArgumentNullException("provider");
  12958. if (functionAsync == null)
  12959. throw new ArgumentNullException("functionAsync");
  12960. return provider.CreateQuery<TResult>(
  12961. Expression.Call(
  12962. null,
  12963. #if CRIPPLED_REFLECTION
  12964. InfoOf(() => Qbservable.StartAsync<TResult>(default(IQbservableProvider), default(Expression<Func<Task<TResult>>>))),
  12965. #else
  12966. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12967. #endif
  12968. Expression.Constant(provider, typeof(IQbservableProvider)),
  12969. functionAsync
  12970. )
  12971. );
  12972. }
  12973. #endif
  12974. #if !NO_TPL
  12975. /// <summary>
  12976. /// Invokes the asynchronous function, surfacing the result through an observable sequence.
  12977. /// The CancellationToken is shared by all subscriptions on the resulting observable sequence. See the remarks section for more information.
  12978. /// </summary>
  12979. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  12980. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  12981. /// <param name="functionAsync">Asynchronous function to run.</param>
  12982. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12983. /// <exception cref="T:System.ArgumentNullException">
  12984. /// <paramref name="functionAsync" /> is null.</exception>
  12985. /// <remarks>
  12986. /// <list type="bullet">
  12987. /// <item>
  12988. /// <description>The function is started immediately, not during the subscription of the resulting sequence.</description>
  12989. /// </item>
  12990. /// <item>
  12991. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12992. /// </item>
  12993. /// <item>
  12994. /// <description>
  12995. /// If any subscription to the resulting sequence is disposed, the CancellationToken is set. The observer associated to the disposed
  12996. /// subscription won't see the TaskCanceledException, but other observers will. You can protect against this using the Catch operator.
  12997. /// Be careful when handing out the resulting sequence because of this behavior. The most common use is to have a single subscription
  12998. /// to the resulting sequence, which controls the CancellationToken state. Alternatively, you can control subscription behavior using
  12999. /// multicast operators.
  13000. /// </description>
  13001. /// </item>
  13002. /// </list>
  13003. /// </remarks>
  13004. public static IQbservable<TResult> StartAsync<TResult>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<TResult>>> functionAsync)
  13005. {
  13006. if (provider == null)
  13007. throw new ArgumentNullException("provider");
  13008. if (functionAsync == null)
  13009. throw new ArgumentNullException("functionAsync");
  13010. return provider.CreateQuery<TResult>(
  13011. Expression.Call(
  13012. null,
  13013. #if CRIPPLED_REFLECTION
  13014. InfoOf(() => Qbservable.StartAsync<TResult>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<TResult>>>))),
  13015. #else
  13016. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  13017. #endif
  13018. Expression.Constant(provider, typeof(IQbservableProvider)),
  13019. functionAsync
  13020. )
  13021. );
  13022. }
  13023. #endif
  13024. /// <summary>
  13025. /// Prepends a sequence of values to an observable sequence.
  13026. /// </summary>
  13027. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13028. /// <param name="source">Source sequence to prepend values to.</param>
  13029. /// <param name="scheduler">Scheduler to emit the prepended values on.</param>
  13030. /// <param name="values">Values to prepend to the specified sequence.</param>
  13031. /// <returns>The source sequence prepended with the specified values.</returns>
  13032. /// <exception cref="T:System.ArgumentNullException">
  13033. /// <paramref name="source" /> or <paramref name="scheduler" /> or <paramref name="values" /> is null.</exception>
  13034. public static IQbservable<TSource> StartWith<TSource>(this IQbservable<TSource> source, IScheduler scheduler, params TSource[] values)
  13035. {
  13036. if (source == null)
  13037. throw new ArgumentNullException("source");
  13038. if (scheduler == null)
  13039. throw new ArgumentNullException("scheduler");
  13040. if (values == null)
  13041. throw new ArgumentNullException("values");
  13042. return source.Provider.CreateQuery<TSource>(
  13043. Expression.Call(
  13044. null,
  13045. #if CRIPPLED_REFLECTION
  13046. InfoOf(() => Qbservable.StartWith<TSource>(default(IQbservable<TSource>), default(IScheduler), default(TSource[]))),
  13047. #else
  13048. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13049. #endif
  13050. source.Expression,
  13051. Expression.Constant(scheduler, typeof(IScheduler)),
  13052. Expression.Constant(values, typeof(TSource[]))
  13053. )
  13054. );
  13055. }
  13056. /// <summary>
  13057. /// Prepends a sequence of values to an observable sequence.
  13058. /// </summary>
  13059. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13060. /// <param name="source">Source sequence to prepend values to.</param>
  13061. /// <param name="scheduler">Scheduler to emit the prepended values on.</param>
  13062. /// <param name="values">Values to prepend to the specified sequence.</param>
  13063. /// <returns>The source sequence prepended with the specified values.</returns>
  13064. /// <exception cref="T:System.ArgumentNullException">
  13065. /// <paramref name="source" /> or <paramref name="scheduler" /> or <paramref name="values" /> is null.</exception>
  13066. public static IQbservable<TSource> StartWith<TSource>(this IQbservable<TSource> source, IScheduler scheduler, IEnumerable<TSource> values)
  13067. {
  13068. if (source == null)
  13069. throw new ArgumentNullException("source");
  13070. if (scheduler == null)
  13071. throw new ArgumentNullException("scheduler");
  13072. if (values == null)
  13073. throw new ArgumentNullException("values");
  13074. return source.Provider.CreateQuery<TSource>(
  13075. Expression.Call(
  13076. null,
  13077. #if CRIPPLED_REFLECTION
  13078. InfoOf(() => Qbservable.StartWith<TSource>(default(IQbservable<TSource>), default(IScheduler), default(IEnumerable<TSource>))),
  13079. #else
  13080. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13081. #endif
  13082. source.Expression,
  13083. Expression.Constant(scheduler, typeof(IScheduler)),
  13084. GetSourceExpression(values)
  13085. )
  13086. );
  13087. }
  13088. /// <summary>
  13089. /// Prepends a sequence of values to an observable sequence.
  13090. /// </summary>
  13091. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13092. /// <param name="source">Source sequence to prepend values to.</param>
  13093. /// <param name="values">Values to prepend to the specified sequence.</param>
  13094. /// <returns>The source sequence prepended with the specified values.</returns>
  13095. /// <exception cref="T:System.ArgumentNullException">
  13096. /// <paramref name="source" /> or <paramref name="values" /> is null.</exception>
  13097. public static IQbservable<TSource> StartWith<TSource>(this IQbservable<TSource> source, params TSource[] values)
  13098. {
  13099. if (source == null)
  13100. throw new ArgumentNullException("source");
  13101. if (values == null)
  13102. throw new ArgumentNullException("values");
  13103. return source.Provider.CreateQuery<TSource>(
  13104. Expression.Call(
  13105. null,
  13106. #if CRIPPLED_REFLECTION
  13107. InfoOf(() => Qbservable.StartWith<TSource>(default(IQbservable<TSource>), default(TSource[]))),
  13108. #else
  13109. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13110. #endif
  13111. source.Expression,
  13112. Expression.Constant(values, typeof(TSource[]))
  13113. )
  13114. );
  13115. }
  13116. /// <summary>
  13117. /// Prepends a sequence of values to an observable sequence.
  13118. /// </summary>
  13119. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13120. /// <param name="source">Source sequence to prepend values to.</param>
  13121. /// <param name="values">Values to prepend to the specified sequence.</param>
  13122. /// <returns>The source sequence prepended with the specified values.</returns>
  13123. /// <exception cref="T:System.ArgumentNullException">
  13124. /// <paramref name="source" /> or <paramref name="values" /> is null.</exception>
  13125. public static IQbservable<TSource> StartWith<TSource>(this IQbservable<TSource> source, IEnumerable<TSource> values)
  13126. {
  13127. if (source == null)
  13128. throw new ArgumentNullException("source");
  13129. if (values == null)
  13130. throw new ArgumentNullException("values");
  13131. return source.Provider.CreateQuery<TSource>(
  13132. Expression.Call(
  13133. null,
  13134. #if CRIPPLED_REFLECTION
  13135. InfoOf(() => Qbservable.StartWith<TSource>(default(IQbservable<TSource>), default(IEnumerable<TSource>))),
  13136. #else
  13137. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13138. #endif
  13139. source.Expression,
  13140. GetSourceExpression(values)
  13141. )
  13142. );
  13143. }
  13144. /// <summary>
  13145. /// Wraps the source sequence in order to run its subscription and unsubscription logic on the specified synchronization context. This operation is not commonly used;
  13146. /// see the remarks section for more information on the distinction between SubscribeOn and ObserveOn.
  13147. /// </summary>
  13148. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13149. /// <param name="source">Source sequence.</param>
  13150. /// <param name="context">Synchronization context to perform subscription and unsubscription actions on.</param>
  13151. /// <returns>The source sequence whose subscriptions and unsubscriptions happen on the specified synchronization context.</returns>
  13152. /// <exception cref="T:System.ArgumentNullException">
  13153. /// <paramref name="source" /> or <paramref name="context" /> is null.</exception>
  13154. /// <remarks>
  13155. /// This only performs the side-effects of subscription and unsubscription on the specified synchronization context. In order to invoke observer
  13156. /// callbacks on a synchronization context, use <see cref="M:System.Reactive.Linq.Observable.ObserveOn``1(System.IObservable{``0},System.Threading.SynchronizationContext)" />.
  13157. /// </remarks>
  13158. public static IQbservable<TSource> SubscribeOn<TSource>(this IQbservable<TSource> source, SynchronizationContext context)
  13159. {
  13160. if (source == null)
  13161. throw new ArgumentNullException("source");
  13162. if (context == null)
  13163. throw new ArgumentNullException("context");
  13164. return source.Provider.CreateQuery<TSource>(
  13165. Expression.Call(
  13166. null,
  13167. #if CRIPPLED_REFLECTION
  13168. InfoOf(() => Qbservable.SubscribeOn<TSource>(default(IQbservable<TSource>), default(SynchronizationContext))),
  13169. #else
  13170. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13171. #endif
  13172. source.Expression,
  13173. Expression.Constant(context, typeof(SynchronizationContext))
  13174. )
  13175. );
  13176. }
  13177. /// <summary>
  13178. /// Wraps the source sequence in order to run its subscription and unsubscription logic on the specified scheduler. This operation is not commonly used;
  13179. /// see the remarks section for more information on the distinction between SubscribeOn and ObserveOn.
  13180. /// </summary>
  13181. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13182. /// <param name="source">Source sequence.</param>
  13183. /// <param name="scheduler">Scheduler to perform subscription and unsubscription actions on.</param>
  13184. /// <returns>The source sequence whose subscriptions and unsubscriptions happen on the specified scheduler.</returns>
  13185. /// <exception cref="T:System.ArgumentNullException">
  13186. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13187. /// <remarks>
  13188. /// This only performs the side-effects of subscription and unsubscription on the specified scheduler. In order to invoke observer
  13189. /// callbacks on a scheduler, use <see cref="M:System.Reactive.Linq.Observable.ObserveOn``1(System.IObservable{``0},System.Reactive.Concurrency.IScheduler)" />.
  13190. /// </remarks>
  13191. public static IQbservable<TSource> SubscribeOn<TSource>(this IQbservable<TSource> source, IScheduler scheduler)
  13192. {
  13193. if (source == null)
  13194. throw new ArgumentNullException("source");
  13195. if (scheduler == null)
  13196. throw new ArgumentNullException("scheduler");
  13197. return source.Provider.CreateQuery<TSource>(
  13198. Expression.Call(
  13199. null,
  13200. #if CRIPPLED_REFLECTION
  13201. InfoOf(() => Qbservable.SubscribeOn<TSource>(default(IQbservable<TSource>), default(IScheduler))),
  13202. #else
  13203. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13204. #endif
  13205. source.Expression,
  13206. Expression.Constant(scheduler, typeof(IScheduler))
  13207. )
  13208. );
  13209. }
  13210. /// <summary>
  13211. /// Computes the sum of a sequence of <see cref="T:System.Decimal" /> values.
  13212. /// </summary>
  13213. /// <param name="source">A sequence of <see cref="T:System.Decimal" /> values to calculate the sum of.</param>
  13214. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13215. /// <exception cref="T:System.ArgumentNullException">
  13216. /// <paramref name="source" /> is null.</exception>
  13217. /// <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>
  13218. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13219. public static IQbservable<decimal> Sum(this IQbservable<decimal> source)
  13220. {
  13221. if (source == null)
  13222. throw new ArgumentNullException("source");
  13223. return source.Provider.CreateQuery<decimal>(
  13224. Expression.Call(
  13225. null,
  13226. #if CRIPPLED_REFLECTION
  13227. InfoOf(() => Qbservable.Sum(default(IQbservable<decimal>))),
  13228. #else
  13229. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13230. #endif
  13231. source.Expression
  13232. )
  13233. );
  13234. }
  13235. /// <summary>
  13236. /// Computes the sum of a sequence of <see cref="T:System.Double" /> values.
  13237. /// </summary>
  13238. /// <param name="source">A sequence of <see cref="T:System.Double" /> values to calculate the sum of.</param>
  13239. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13240. /// <exception cref="T:System.ArgumentNullException">
  13241. /// <paramref name="source" /> is null.</exception>
  13242. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13243. public static IQbservable<double> Sum(this IQbservable<double> source)
  13244. {
  13245. if (source == null)
  13246. throw new ArgumentNullException("source");
  13247. return source.Provider.CreateQuery<double>(
  13248. Expression.Call(
  13249. null,
  13250. #if CRIPPLED_REFLECTION
  13251. InfoOf(() => Qbservable.Sum(default(IQbservable<double>))),
  13252. #else
  13253. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13254. #endif
  13255. source.Expression
  13256. )
  13257. );
  13258. }
  13259. /// <summary>
  13260. /// Computes the sum of a sequence of <see cref="T:System.Int32" /> values.
  13261. /// </summary>
  13262. /// <param name="source">A sequence of <see cref="T:System.Int32" /> values to calculate the sum of.</param>
  13263. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13264. /// <exception cref="T:System.ArgumentNullException">
  13265. /// <paramref name="source" /> is null.</exception>
  13266. /// <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>
  13267. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13268. public static IQbservable<int> Sum(this IQbservable<int> source)
  13269. {
  13270. if (source == null)
  13271. throw new ArgumentNullException("source");
  13272. return source.Provider.CreateQuery<int>(
  13273. Expression.Call(
  13274. null,
  13275. #if CRIPPLED_REFLECTION
  13276. InfoOf(() => Qbservable.Sum(default(IQbservable<int>))),
  13277. #else
  13278. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13279. #endif
  13280. source.Expression
  13281. )
  13282. );
  13283. }
  13284. /// <summary>
  13285. /// Computes the sum of a sequence of <see cref="T:System.Int64" /> values.
  13286. /// </summary>
  13287. /// <param name="source">A sequence of <see cref="T:System.Int64" /> values to calculate the sum of.</param>
  13288. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13289. /// <exception cref="T:System.ArgumentNullException">
  13290. /// <paramref name="source" /> is null.</exception>
  13291. /// <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>
  13292. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13293. public static IQbservable<long> Sum(this IQbservable<long> source)
  13294. {
  13295. if (source == null)
  13296. throw new ArgumentNullException("source");
  13297. return source.Provider.CreateQuery<long>(
  13298. Expression.Call(
  13299. null,
  13300. #if CRIPPLED_REFLECTION
  13301. InfoOf(() => Qbservable.Sum(default(IQbservable<long>))),
  13302. #else
  13303. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13304. #endif
  13305. source.Expression
  13306. )
  13307. );
  13308. }
  13309. /// <summary>
  13310. /// Computes the sum of a sequence of nullable <see cref="T:System.Decimal" /> values.
  13311. /// </summary>
  13312. /// <param name="source">A sequence of nullable <see cref="T:System.Decimal" /> values to calculate the sum of.</param>
  13313. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13314. /// <exception cref="T:System.ArgumentNullException">
  13315. /// <paramref name="source" /> is null.</exception>
  13316. /// <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>
  13317. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13318. public static IQbservable<decimal?> Sum(this IQbservable<decimal?> source)
  13319. {
  13320. if (source == null)
  13321. throw new ArgumentNullException("source");
  13322. return source.Provider.CreateQuery<decimal?>(
  13323. Expression.Call(
  13324. null,
  13325. #if CRIPPLED_REFLECTION
  13326. InfoOf(() => Qbservable.Sum(default(IQbservable<decimal?>))),
  13327. #else
  13328. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13329. #endif
  13330. source.Expression
  13331. )
  13332. );
  13333. }
  13334. /// <summary>
  13335. /// Computes the sum of a sequence of nullable <see cref="T:System.Double" /> values.
  13336. /// </summary>
  13337. /// <param name="source">A sequence of nullable <see cref="T:System.Double" /> values to calculate the sum of.</param>
  13338. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13339. /// <exception cref="T:System.ArgumentNullException">
  13340. /// <paramref name="source" /> is null.</exception>
  13341. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13342. public static IQbservable<double?> Sum(this IQbservable<double?> source)
  13343. {
  13344. if (source == null)
  13345. throw new ArgumentNullException("source");
  13346. return source.Provider.CreateQuery<double?>(
  13347. Expression.Call(
  13348. null,
  13349. #if CRIPPLED_REFLECTION
  13350. InfoOf(() => Qbservable.Sum(default(IQbservable<double?>))),
  13351. #else
  13352. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13353. #endif
  13354. source.Expression
  13355. )
  13356. );
  13357. }
  13358. /// <summary>
  13359. /// Computes the sum of a sequence of nullable <see cref="T:System.Int32" /> values.
  13360. /// </summary>
  13361. /// <param name="source">A sequence of nullable <see cref="T:System.Int32" /> values to calculate the sum of.</param>
  13362. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13363. /// <exception cref="T:System.ArgumentNullException">
  13364. /// <paramref name="source" /> is null.</exception>
  13365. /// <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>
  13366. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13367. public static IQbservable<int?> Sum(this IQbservable<int?> source)
  13368. {
  13369. if (source == null)
  13370. throw new ArgumentNullException("source");
  13371. return source.Provider.CreateQuery<int?>(
  13372. Expression.Call(
  13373. null,
  13374. #if CRIPPLED_REFLECTION
  13375. InfoOf(() => Qbservable.Sum(default(IQbservable<int?>))),
  13376. #else
  13377. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13378. #endif
  13379. source.Expression
  13380. )
  13381. );
  13382. }
  13383. /// <summary>
  13384. /// Computes the sum of a sequence of nullable <see cref="T:System.Int64" /> values.
  13385. /// </summary>
  13386. /// <param name="source">A sequence of nullable <see cref="T:System.Int64" /> values to calculate the sum of.</param>
  13387. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13388. /// <exception cref="T:System.ArgumentNullException">
  13389. /// <paramref name="source" /> is null.</exception>
  13390. /// <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>
  13391. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13392. public static IQbservable<long?> Sum(this IQbservable<long?> source)
  13393. {
  13394. if (source == null)
  13395. throw new ArgumentNullException("source");
  13396. return source.Provider.CreateQuery<long?>(
  13397. Expression.Call(
  13398. null,
  13399. #if CRIPPLED_REFLECTION
  13400. InfoOf(() => Qbservable.Sum(default(IQbservable<long?>))),
  13401. #else
  13402. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13403. #endif
  13404. source.Expression
  13405. )
  13406. );
  13407. }
  13408. /// <summary>
  13409. /// Computes the sum of a sequence of nullable <see cref="T:System.Single" /> values.
  13410. /// </summary>
  13411. /// <param name="source">A sequence of nullable <see cref="T:System.Single" /> values to calculate the sum of.</param>
  13412. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13413. /// <exception cref="T:System.ArgumentNullException">
  13414. /// <paramref name="source" /> is null.</exception>
  13415. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13416. public static IQbservable<float?> Sum(this IQbservable<float?> source)
  13417. {
  13418. if (source == null)
  13419. throw new ArgumentNullException("source");
  13420. return source.Provider.CreateQuery<float?>(
  13421. Expression.Call(
  13422. null,
  13423. #if CRIPPLED_REFLECTION
  13424. InfoOf(() => Qbservable.Sum(default(IQbservable<float?>))),
  13425. #else
  13426. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13427. #endif
  13428. source.Expression
  13429. )
  13430. );
  13431. }
  13432. /// <summary>
  13433. /// Computes the sum of a sequence of <see cref="T:System.Single" /> values.
  13434. /// </summary>
  13435. /// <param name="source">A sequence of <see cref="T:System.Single" /> values to calculate the sum of.</param>
  13436. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13437. /// <exception cref="T:System.ArgumentNullException">
  13438. /// <paramref name="source" /> is null.</exception>
  13439. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13440. public static IQbservable<float> Sum(this IQbservable<float> source)
  13441. {
  13442. if (source == null)
  13443. throw new ArgumentNullException("source");
  13444. return source.Provider.CreateQuery<float>(
  13445. Expression.Call(
  13446. null,
  13447. #if CRIPPLED_REFLECTION
  13448. InfoOf(() => Qbservable.Sum(default(IQbservable<float>))),
  13449. #else
  13450. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13451. #endif
  13452. source.Expression
  13453. )
  13454. );
  13455. }
  13456. /// <summary>
  13457. /// 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.
  13458. /// </summary>
  13459. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13460. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13461. /// <param name="selector">A transform function to apply to each element.</param>
  13462. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13463. /// <exception cref="T:System.ArgumentNullException">
  13464. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13465. /// <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>
  13466. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13467. public static IQbservable<int?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int?>> selector)
  13468. {
  13469. if (source == null)
  13470. throw new ArgumentNullException("source");
  13471. if (selector == null)
  13472. throw new ArgumentNullException("selector");
  13473. return source.Provider.CreateQuery<int?>(
  13474. Expression.Call(
  13475. null,
  13476. #if CRIPPLED_REFLECTION
  13477. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int?>>))),
  13478. #else
  13479. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13480. #endif
  13481. source.Expression,
  13482. selector
  13483. )
  13484. );
  13485. }
  13486. /// <summary>
  13487. /// 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.
  13488. /// </summary>
  13489. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13490. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13491. /// <param name="selector">A transform function to apply to each element.</param>
  13492. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13493. /// <exception cref="T:System.ArgumentNullException">
  13494. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13495. /// <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>
  13496. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13497. public static IQbservable<long?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long?>> selector)
  13498. {
  13499. if (source == null)
  13500. throw new ArgumentNullException("source");
  13501. if (selector == null)
  13502. throw new ArgumentNullException("selector");
  13503. return source.Provider.CreateQuery<long?>(
  13504. Expression.Call(
  13505. null,
  13506. #if CRIPPLED_REFLECTION
  13507. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long?>>))),
  13508. #else
  13509. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13510. #endif
  13511. source.Expression,
  13512. selector
  13513. )
  13514. );
  13515. }
  13516. /// <summary>
  13517. /// 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.
  13518. /// </summary>
  13519. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13520. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13521. /// <param name="selector">A transform function to apply to each element.</param>
  13522. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13523. /// <exception cref="T:System.ArgumentNullException">
  13524. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13525. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13526. public static IQbservable<double> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double>> selector)
  13527. {
  13528. if (source == null)
  13529. throw new ArgumentNullException("source");
  13530. if (selector == null)
  13531. throw new ArgumentNullException("selector");
  13532. return source.Provider.CreateQuery<double>(
  13533. Expression.Call(
  13534. null,
  13535. #if CRIPPLED_REFLECTION
  13536. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double>>))),
  13537. #else
  13538. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13539. #endif
  13540. source.Expression,
  13541. selector
  13542. )
  13543. );
  13544. }
  13545. /// <summary>
  13546. /// 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.
  13547. /// </summary>
  13548. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13549. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13550. /// <param name="selector">A transform function to apply to each element.</param>
  13551. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13552. /// <exception cref="T:System.ArgumentNullException">
  13553. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13554. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13555. public static IQbservable<float> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float>> selector)
  13556. {
  13557. if (source == null)
  13558. throw new ArgumentNullException("source");
  13559. if (selector == null)
  13560. throw new ArgumentNullException("selector");
  13561. return source.Provider.CreateQuery<float>(
  13562. Expression.Call(
  13563. null,
  13564. #if CRIPPLED_REFLECTION
  13565. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float>>))),
  13566. #else
  13567. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13568. #endif
  13569. source.Expression,
  13570. selector
  13571. )
  13572. );
  13573. }
  13574. /// <summary>
  13575. /// 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.
  13576. /// </summary>
  13577. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13578. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13579. /// <param name="selector">A transform function to apply to each element.</param>
  13580. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13581. /// <exception cref="T:System.ArgumentNullException">
  13582. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13583. /// <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>
  13584. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13585. public static IQbservable<decimal> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal>> selector)
  13586. {
  13587. if (source == null)
  13588. throw new ArgumentNullException("source");
  13589. if (selector == null)
  13590. throw new ArgumentNullException("selector");
  13591. return source.Provider.CreateQuery<decimal>(
  13592. Expression.Call(
  13593. null,
  13594. #if CRIPPLED_REFLECTION
  13595. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal>>))),
  13596. #else
  13597. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13598. #endif
  13599. source.Expression,
  13600. selector
  13601. )
  13602. );
  13603. }
  13604. /// <summary>
  13605. /// 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.
  13606. /// </summary>
  13607. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13608. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13609. /// <param name="selector">A transform function to apply to each element.</param>
  13610. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13611. /// <exception cref="T:System.ArgumentNullException">
  13612. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13613. /// <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>
  13614. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13615. public static IQbservable<int> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int>> selector)
  13616. {
  13617. if (source == null)
  13618. throw new ArgumentNullException("source");
  13619. if (selector == null)
  13620. throw new ArgumentNullException("selector");
  13621. return source.Provider.CreateQuery<int>(
  13622. Expression.Call(
  13623. null,
  13624. #if CRIPPLED_REFLECTION
  13625. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int>>))),
  13626. #else
  13627. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13628. #endif
  13629. source.Expression,
  13630. selector
  13631. )
  13632. );
  13633. }
  13634. /// <summary>
  13635. /// 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.
  13636. /// </summary>
  13637. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13638. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13639. /// <param name="selector">A transform function to apply to each element.</param>
  13640. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13641. /// <exception cref="T:System.ArgumentNullException">
  13642. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13643. /// <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>
  13644. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13645. public static IQbservable<long> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long>> selector)
  13646. {
  13647. if (source == null)
  13648. throw new ArgumentNullException("source");
  13649. if (selector == null)
  13650. throw new ArgumentNullException("selector");
  13651. return source.Provider.CreateQuery<long>(
  13652. Expression.Call(
  13653. null,
  13654. #if CRIPPLED_REFLECTION
  13655. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long>>))),
  13656. #else
  13657. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13658. #endif
  13659. source.Expression,
  13660. selector
  13661. )
  13662. );
  13663. }
  13664. /// <summary>
  13665. /// 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.
  13666. /// </summary>
  13667. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13668. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13669. /// <param name="selector">A transform function to apply to each element.</param>
  13670. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13671. /// <exception cref="T:System.ArgumentNullException">
  13672. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13673. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13674. public static IQbservable<double?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double?>> selector)
  13675. {
  13676. if (source == null)
  13677. throw new ArgumentNullException("source");
  13678. if (selector == null)
  13679. throw new ArgumentNullException("selector");
  13680. return source.Provider.CreateQuery<double?>(
  13681. Expression.Call(
  13682. null,
  13683. #if CRIPPLED_REFLECTION
  13684. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double?>>))),
  13685. #else
  13686. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13687. #endif
  13688. source.Expression,
  13689. selector
  13690. )
  13691. );
  13692. }
  13693. /// <summary>
  13694. /// 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.
  13695. /// </summary>
  13696. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13697. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13698. /// <param name="selector">A transform function to apply to each element.</param>
  13699. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13700. /// <exception cref="T:System.ArgumentNullException">
  13701. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13702. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13703. public static IQbservable<float?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float?>> selector)
  13704. {
  13705. if (source == null)
  13706. throw new ArgumentNullException("source");
  13707. if (selector == null)
  13708. throw new ArgumentNullException("selector");
  13709. return source.Provider.CreateQuery<float?>(
  13710. Expression.Call(
  13711. null,
  13712. #if CRIPPLED_REFLECTION
  13713. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float?>>))),
  13714. #else
  13715. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13716. #endif
  13717. source.Expression,
  13718. selector
  13719. )
  13720. );
  13721. }
  13722. /// <summary>
  13723. /// 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.
  13724. /// </summary>
  13725. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13726. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13727. /// <param name="selector">A transform function to apply to each element.</param>
  13728. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13729. /// <exception cref="T:System.ArgumentNullException">
  13730. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13731. /// <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>
  13732. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13733. public static IQbservable<decimal?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal?>> selector)
  13734. {
  13735. if (source == null)
  13736. throw new ArgumentNullException("source");
  13737. if (selector == null)
  13738. throw new ArgumentNullException("selector");
  13739. return source.Provider.CreateQuery<decimal?>(
  13740. Expression.Call(
  13741. null,
  13742. #if CRIPPLED_REFLECTION
  13743. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal?>>))),
  13744. #else
  13745. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13746. #endif
  13747. source.Expression,
  13748. selector
  13749. )
  13750. );
  13751. }
  13752. /// <summary>
  13753. /// Switches between the inner observable sequences such that the resulting sequence always produces elements from the most recently received inner observable sequence.
  13754. /// Each time a new inner observable sequence is received, the previous inner observable sequence is unsubscribed from.
  13755. /// </summary>
  13756. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  13757. /// <param name="sources">Observable sequence of inner observable sequences.</param>
  13758. /// <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>
  13759. /// <exception cref="T:System.ArgumentNullException">
  13760. /// <paramref name="sources" /> is null.</exception>
  13761. public static IQbservable<TSource> Switch<TSource>(this IQbservable<IObservable<TSource>> sources)
  13762. {
  13763. if (sources == null)
  13764. throw new ArgumentNullException("sources");
  13765. return sources.Provider.CreateQuery<TSource>(
  13766. Expression.Call(
  13767. null,
  13768. #if CRIPPLED_REFLECTION
  13769. InfoOf(() => Qbservable.Switch<TSource>(default(IQbservable<IObservable<TSource>>))),
  13770. #else
  13771. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13772. #endif
  13773. sources.Expression
  13774. )
  13775. );
  13776. }
  13777. #if !NO_TPL
  13778. /// <summary>
  13779. /// Switches between the tasks such that the resulting sequence always produces results from the most recently received task.
  13780. /// Each time a new task is received, the previous task's result is ignored.
  13781. /// </summary>
  13782. /// <typeparam name="TSource">The type of the results produced by the source tasks.</typeparam>
  13783. /// <param name="sources">Observable sequence of tasks.</param>
  13784. /// <returns>The observable sequence that at any point in time produces the result of the most recent task that has been received.</returns>
  13785. /// <exception cref="T:System.ArgumentNullException">
  13786. /// <paramref name="sources" /> is null.</exception>
  13787. /// <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>
  13788. public static IQbservable<TSource> Switch<TSource>(this IQbservable<Task<TSource>> sources)
  13789. {
  13790. if (sources == null)
  13791. throw new ArgumentNullException("sources");
  13792. return sources.Provider.CreateQuery<TSource>(
  13793. Expression.Call(
  13794. null,
  13795. #if CRIPPLED_REFLECTION
  13796. InfoOf(() => Qbservable.Switch<TSource>(default(IQbservable<Task<TSource>>))),
  13797. #else
  13798. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13799. #endif
  13800. sources.Expression
  13801. )
  13802. );
  13803. }
  13804. #endif
  13805. /// <summary>
  13806. /// Synchronizes the observable sequence such that observer notifications cannot be delivered concurrently.
  13807. /// This overload is useful to "fix" an observable sequence that exhibits concurrent callbacks on individual observers, which is invalid behavior for the query processor.
  13808. /// </summary>
  13809. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13810. /// <param name="source">Source sequence.</param>
  13811. /// <returns>The source sequence whose outgoing calls to observers are synchronized.</returns>
  13812. /// <exception cref="T:System.ArgumentNullException">
  13813. /// <paramref name="source" /> is null.</exception>
  13814. /// <remarks>
  13815. /// It's invalid behavior - according to the observer grammar - for a sequence to exhibit concurrent callbacks on a given observer.
  13816. /// This operator can be used to "fix" a source that doesn't conform to this rule.
  13817. /// </remarks>
  13818. public static IQbservable<TSource> Synchronize<TSource>(this IQbservable<TSource> source)
  13819. {
  13820. if (source == null)
  13821. throw new ArgumentNullException("source");
  13822. return source.Provider.CreateQuery<TSource>(
  13823. Expression.Call(
  13824. null,
  13825. #if CRIPPLED_REFLECTION
  13826. InfoOf(() => Qbservable.Synchronize<TSource>(default(IQbservable<TSource>))),
  13827. #else
  13828. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13829. #endif
  13830. source.Expression
  13831. )
  13832. );
  13833. }
  13834. /// <summary>
  13835. /// Synchronizes the observable sequence such that observer notifications cannot be delivered concurrently, using the specified gate object.
  13836. /// 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.
  13837. /// </summary>
  13838. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13839. /// <param name="source">Source sequence.</param>
  13840. /// <param name="gate">Gate object to synchronize each observer call on.</param>
  13841. /// <returns>The source sequence whose outgoing calls to observers are synchronized on the given gate object.</returns>
  13842. /// <exception cref="T:System.ArgumentNullException">
  13843. /// <paramref name="source" /> or <paramref name="gate" /> is null.</exception>
  13844. public static IQbservable<TSource> Synchronize<TSource>(this IQbservable<TSource> source, object gate)
  13845. {
  13846. if (source == null)
  13847. throw new ArgumentNullException("source");
  13848. if (gate == null)
  13849. throw new ArgumentNullException("gate");
  13850. return source.Provider.CreateQuery<TSource>(
  13851. Expression.Call(
  13852. null,
  13853. #if CRIPPLED_REFLECTION
  13854. InfoOf(() => Qbservable.Synchronize<TSource>(default(IQbservable<TSource>), default(object))),
  13855. #else
  13856. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13857. #endif
  13858. source.Expression,
  13859. Expression.Constant(gate, typeof(object))
  13860. )
  13861. );
  13862. }
  13863. /// <summary>
  13864. /// Returns a specified number of contiguous elements from the start of an observable sequence.
  13865. /// </summary>
  13866. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13867. /// <param name="source">The sequence to take elements from.</param>
  13868. /// <param name="count">The number of elements to return.</param>
  13869. /// <returns>An observable sequence that contains the specified number of elements from the start of the input sequence.</returns>
  13870. /// <exception cref="T:System.ArgumentNullException">
  13871. /// <paramref name="source" /> is null.</exception>
  13872. /// <exception cref="T:System.ArgumentOutOfRangeException">
  13873. /// <paramref name="count" /> is less than zero.</exception>
  13874. public static IQbservable<TSource> Take<TSource>(this IQbservable<TSource> source, int count)
  13875. {
  13876. if (source == null)
  13877. throw new ArgumentNullException("source");
  13878. return source.Provider.CreateQuery<TSource>(
  13879. Expression.Call(
  13880. null,
  13881. #if CRIPPLED_REFLECTION
  13882. InfoOf(() => Qbservable.Take<TSource>(default(IQbservable<TSource>), default(int))),
  13883. #else
  13884. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13885. #endif
  13886. source.Expression,
  13887. Expression.Constant(count, typeof(int))
  13888. )
  13889. );
  13890. }
  13891. /// <summary>
  13892. /// 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).
  13893. /// </summary>
  13894. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13895. /// <param name="source">The sequence to take elements from.</param>
  13896. /// <param name="count">The number of elements to return.</param>
  13897. /// <param name="scheduler">Scheduler used to produce an OnCompleted message in case <paramref name="count">count</paramref> is set to 0.</param>
  13898. /// <returns>An observable sequence that contains the specified number of elements from the start of the input sequence.</returns>
  13899. /// <exception cref="T:System.ArgumentNullException">
  13900. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13901. /// <exception cref="T:System.ArgumentOutOfRangeException">
  13902. /// <paramref name="count" /> is less than zero.</exception>
  13903. public static IQbservable<TSource> Take<TSource>(this IQbservable<TSource> source, int count, IScheduler scheduler)
  13904. {
  13905. if (source == null)
  13906. throw new ArgumentNullException("source");
  13907. if (scheduler == null)
  13908. throw new ArgumentNullException("scheduler");
  13909. return source.Provider.CreateQuery<TSource>(
  13910. Expression.Call(
  13911. null,
  13912. #if CRIPPLED_REFLECTION
  13913. InfoOf(() => Qbservable.Take<TSource>(default(IQbservable<TSource>), default(int), default(IScheduler))),
  13914. #else
  13915. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13916. #endif
  13917. source.Expression,
  13918. Expression.Constant(count, typeof(int)),
  13919. Expression.Constant(scheduler, typeof(IScheduler))
  13920. )
  13921. );
  13922. }
  13923. /// <summary>
  13924. /// Takes elements for the specified duration from the start of the observable source sequence.
  13925. /// </summary>
  13926. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13927. /// <param name="source">Source sequence to take elements from.</param>
  13928. /// <param name="duration">Duration for taking elements from the start of the sequence.</param>
  13929. /// <returns>An observable sequence with the elements taken during the specified duration from the start of the source sequence.</returns>
  13930. /// <exception cref="T:System.ArgumentNullException">
  13931. /// <paramref name="source" /> is null.</exception>
  13932. /// <exception cref="T:System.ArgumentOutOfRangeException">
  13933. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  13934. /// <remarks>
  13935. /// Specifying a TimeSpan.Zero value for <paramref name="duration" /> doesn't guarantee an empty sequence will be returned. This is a side-effect
  13936. /// of the asynchrony introduced by the scheduler, where the action that stops forwarding callbacks from the source sequence may not execute
  13937. /// immediately, despite the TimeSpan.Zero due time.
  13938. /// </remarks>
  13939. public static IQbservable<TSource> Take<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  13940. {
  13941. if (source == null)
  13942. throw new ArgumentNullException("source");
  13943. return source.Provider.CreateQuery<TSource>(
  13944. Expression.Call(
  13945. null,
  13946. #if CRIPPLED_REFLECTION
  13947. InfoOf(() => Qbservable.Take<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  13948. #else
  13949. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13950. #endif
  13951. source.Expression,
  13952. Expression.Constant(duration, typeof(TimeSpan))
  13953. )
  13954. );
  13955. }
  13956. /// <summary>
  13957. /// Takes elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers.
  13958. /// </summary>
  13959. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13960. /// <param name="source">Source sequence to take elements from.</param>
  13961. /// <param name="duration">Duration for taking elements from the start of the sequence.</param>
  13962. /// <param name="scheduler">Scheduler to run the timer on.</param>
  13963. /// <returns>An observable sequence with the elements taken during the specified duration from the start of the source sequence.</returns>
  13964. /// <exception cref="T:System.ArgumentNullException">
  13965. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13966. /// <exception cref="T:System.ArgumentOutOfRangeException">
  13967. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  13968. /// <remarks>
  13969. /// Specifying a TimeSpan.Zero value for <paramref name="duration" /> doesn't guarantee an empty sequence will be returned. This is a side-effect
  13970. /// of the asynchrony introduced by the scheduler, where the action that stops forwarding callbacks from the source sequence may not execute
  13971. /// immediately, despite the TimeSpan.Zero due time.
  13972. /// </remarks>
  13973. public static IQbservable<TSource> Take<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  13974. {
  13975. if (source == null)
  13976. throw new ArgumentNullException("source");
  13977. if (scheduler == null)
  13978. throw new ArgumentNullException("scheduler");
  13979. return source.Provider.CreateQuery<TSource>(
  13980. Expression.Call(
  13981. null,
  13982. #if CRIPPLED_REFLECTION
  13983. InfoOf(() => Qbservable.Take<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  13984. #else
  13985. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13986. #endif
  13987. source.Expression,
  13988. Expression.Constant(duration, typeof(TimeSpan)),
  13989. Expression.Constant(scheduler, typeof(IScheduler))
  13990. )
  13991. );
  13992. }
  13993. /// <summary>
  13994. /// Returns a specified number of contiguous elements from the end of an observable sequence.
  13995. /// </summary>
  13996. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13997. /// <param name="source">Source sequence.</param>
  13998. /// <param name="count">Number of elements to take from the end of the source sequence.</param>
  13999. /// <returns>An observable sequence containing the specified number of elements from the end of the source sequence.</returns>
  14000. /// <exception cref="T:System.ArgumentNullException">
  14001. /// <paramref name="source" /> is null.</exception>
  14002. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14003. /// <paramref name="count" /> is less than zero.</exception>
  14004. /// <remarks>
  14005. /// This operator accumulates a buffer with a length enough to store elements <paramref name="count" /> elements. Upon completion of
  14006. /// the source sequence, this buffer is drained on the result sequence. This causes the elements to be delayed.
  14007. /// </remarks>
  14008. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, int count)
  14009. {
  14010. if (source == null)
  14011. throw new ArgumentNullException("source");
  14012. return source.Provider.CreateQuery<TSource>(
  14013. Expression.Call(
  14014. null,
  14015. #if CRIPPLED_REFLECTION
  14016. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(int))),
  14017. #else
  14018. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14019. #endif
  14020. source.Expression,
  14021. Expression.Constant(count, typeof(int))
  14022. )
  14023. );
  14024. }
  14025. /// <summary>
  14026. /// Returns a specified number of contiguous elements from the end of an observable sequence, using the specified scheduler to drain the queue.
  14027. /// </summary>
  14028. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14029. /// <param name="source">Source sequence.</param>
  14030. /// <param name="count">Number of elements to take from the end of the source sequence.</param>
  14031. /// <param name="scheduler">Scheduler used to drain the queue upon completion of the source sequence.</param>
  14032. /// <returns>An observable sequence containing the specified number of elements from the end of the source sequence.</returns>
  14033. /// <exception cref="T:System.ArgumentNullException">
  14034. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14035. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14036. /// <paramref name="count" /> is less than zero.</exception>
  14037. /// <remarks>
  14038. /// This operator accumulates a buffer with a length enough to store elements <paramref name="count" /> elements. Upon completion of
  14039. /// the source sequence, this buffer is drained on the result sequence. This causes the elements to be delayed.
  14040. /// </remarks>
  14041. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, int count, IScheduler scheduler)
  14042. {
  14043. if (source == null)
  14044. throw new ArgumentNullException("source");
  14045. if (scheduler == null)
  14046. throw new ArgumentNullException("scheduler");
  14047. return source.Provider.CreateQuery<TSource>(
  14048. Expression.Call(
  14049. null,
  14050. #if CRIPPLED_REFLECTION
  14051. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(int), default(IScheduler))),
  14052. #else
  14053. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14054. #endif
  14055. source.Expression,
  14056. Expression.Constant(count, typeof(int)),
  14057. Expression.Constant(scheduler, typeof(IScheduler))
  14058. )
  14059. );
  14060. }
  14061. /// <summary>
  14062. /// Returns elements within the specified duration from the end of the observable source sequence.
  14063. /// </summary>
  14064. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14065. /// <param name="source">Source sequence to take elements from.</param>
  14066. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  14067. /// <returns>An observable sequence with the elements taken during the specified duration from the end of the source sequence.</returns>
  14068. /// <exception cref="T:System.ArgumentNullException">
  14069. /// <paramref name="source" /> is null.</exception>
  14070. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14071. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  14072. /// <remarks>
  14073. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  14074. /// the source sequence. Upon completion of the source sequence, this buffer is drained on the result sequence. This causes the result elements
  14075. /// to be delayed with <paramref name="duration" />.
  14076. /// </remarks>
  14077. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  14078. {
  14079. if (source == null)
  14080. throw new ArgumentNullException("source");
  14081. return source.Provider.CreateQuery<TSource>(
  14082. Expression.Call(
  14083. null,
  14084. #if CRIPPLED_REFLECTION
  14085. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  14086. #else
  14087. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14088. #endif
  14089. source.Expression,
  14090. Expression.Constant(duration, typeof(TimeSpan))
  14091. )
  14092. );
  14093. }
  14094. /// <summary>
  14095. /// Returns elements within the specified duration from the end of the observable source sequence, using the specified scheduler to run timers.
  14096. /// </summary>
  14097. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14098. /// <param name="source">Source sequence to take elements from.</param>
  14099. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  14100. /// <param name="scheduler">Scheduler to run the timer on.</param>
  14101. /// <returns>An observable sequence with the elements taken during the specified duration from the end of the source sequence.</returns>
  14102. /// <exception cref="T:System.ArgumentNullException">
  14103. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14104. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14105. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  14106. /// <remarks>
  14107. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  14108. /// the source sequence. Upon completion of the source sequence, this buffer is drained on the result sequence. This causes the result elements
  14109. /// to be delayed with <paramref name="duration" />.
  14110. /// </remarks>
  14111. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  14112. {
  14113. if (source == null)
  14114. throw new ArgumentNullException("source");
  14115. if (scheduler == null)
  14116. throw new ArgumentNullException("scheduler");
  14117. return source.Provider.CreateQuery<TSource>(
  14118. Expression.Call(
  14119. null,
  14120. #if CRIPPLED_REFLECTION
  14121. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  14122. #else
  14123. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14124. #endif
  14125. source.Expression,
  14126. Expression.Constant(duration, typeof(TimeSpan)),
  14127. Expression.Constant(scheduler, typeof(IScheduler))
  14128. )
  14129. );
  14130. }
  14131. /// <summary>
  14132. /// 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.
  14133. /// </summary>
  14134. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14135. /// <param name="source">Source sequence to take elements from.</param>
  14136. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  14137. /// <param name="timerScheduler">Scheduler to run the timer on.</param>
  14138. /// <param name="loopScheduler">Scheduler to drain the collected elements.</param>
  14139. /// <returns>An observable sequence with the elements taken during the specified duration from the end of the source sequence.</returns>
  14140. /// <exception cref="T:System.ArgumentNullException">
  14141. /// <paramref name="source" /> or <paramref name="timerScheduler" /> or <paramref name="loopScheduler" /> is null.</exception>
  14142. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14143. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  14144. /// <remarks>
  14145. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  14146. /// the source sequence. Upon completion of the source sequence, this buffer is drained on the result sequence. This causes the result elements
  14147. /// to be delayed with <paramref name="duration" />.
  14148. /// </remarks>
  14149. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler timerScheduler, IScheduler loopScheduler)
  14150. {
  14151. if (source == null)
  14152. throw new ArgumentNullException("source");
  14153. if (timerScheduler == null)
  14154. throw new ArgumentNullException("timerScheduler");
  14155. if (loopScheduler == null)
  14156. throw new ArgumentNullException("loopScheduler");
  14157. return source.Provider.CreateQuery<TSource>(
  14158. Expression.Call(
  14159. null,
  14160. #if CRIPPLED_REFLECTION
  14161. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler), default(IScheduler))),
  14162. #else
  14163. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14164. #endif
  14165. source.Expression,
  14166. Expression.Constant(duration, typeof(TimeSpan)),
  14167. Expression.Constant(timerScheduler, typeof(IScheduler)),
  14168. Expression.Constant(loopScheduler, typeof(IScheduler))
  14169. )
  14170. );
  14171. }
  14172. /// <summary>
  14173. /// Returns a list with the specified number of contiguous elements from the end of an observable sequence.
  14174. /// </summary>
  14175. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14176. /// <param name="source">Source sequence.</param>
  14177. /// <param name="count">Number of elements to take from the end of the source sequence.</param>
  14178. /// <returns>An observable sequence containing a single list with the specified number of elements from the end of the source sequence.</returns>
  14179. /// <exception cref="T:System.ArgumentNullException">
  14180. /// <paramref name="source" /> is null.</exception>
  14181. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14182. /// <paramref name="count" /> is less than zero.</exception>
  14183. /// <remarks>
  14184. /// This operator accumulates a buffer with a length enough to store <paramref name="count" /> elements. Upon completion of the
  14185. /// source sequence, this buffer is produced on the result sequence.
  14186. /// </remarks>
  14187. public static IQbservable<IList<TSource>> TakeLastBuffer<TSource>(this IQbservable<TSource> source, int count)
  14188. {
  14189. if (source == null)
  14190. throw new ArgumentNullException("source");
  14191. return source.Provider.CreateQuery<IList<TSource>>(
  14192. Expression.Call(
  14193. null,
  14194. #if CRIPPLED_REFLECTION
  14195. InfoOf(() => Qbservable.TakeLastBuffer<TSource>(default(IQbservable<TSource>), default(int))),
  14196. #else
  14197. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14198. #endif
  14199. source.Expression,
  14200. Expression.Constant(count, typeof(int))
  14201. )
  14202. );
  14203. }
  14204. /// <summary>
  14205. /// Returns a list with the elements within the specified duration from the end of the observable source sequence.
  14206. /// </summary>
  14207. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14208. /// <param name="source">Source sequence to take elements from.</param>
  14209. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  14210. /// <returns>An observable sequence containing a single list with the elements taken during the specified duration from the end of the source sequence.</returns>
  14211. /// <exception cref="T:System.ArgumentNullException">
  14212. /// <paramref name="source" /> is null.</exception>
  14213. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14214. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  14215. /// <remarks>
  14216. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  14217. /// the source sequence. Upon completion of the source sequence, this buffer is produced on the result sequence.
  14218. /// </remarks>
  14219. public static IQbservable<IList<TSource>> TakeLastBuffer<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  14220. {
  14221. if (source == null)
  14222. throw new ArgumentNullException("source");
  14223. return source.Provider.CreateQuery<IList<TSource>>(
  14224. Expression.Call(
  14225. null,
  14226. #if CRIPPLED_REFLECTION
  14227. InfoOf(() => Qbservable.TakeLastBuffer<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  14228. #else
  14229. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14230. #endif
  14231. source.Expression,
  14232. Expression.Constant(duration, typeof(TimeSpan))
  14233. )
  14234. );
  14235. }
  14236. /// <summary>
  14237. /// 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.
  14238. /// </summary>
  14239. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14240. /// <param name="source">Source sequence to take elements from.</param>
  14241. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  14242. /// <param name="scheduler">Scheduler to run the timer on.</param>
  14243. /// <returns>An observable sequence containing a single list with the elements taken during the specified duration from the end of the source sequence.</returns>
  14244. /// <exception cref="T:System.ArgumentNullException">
  14245. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14246. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14247. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  14248. /// <remarks>
  14249. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  14250. /// the source sequence. Upon completion of the source sequence, this buffer is produced on the result sequence.
  14251. /// </remarks>
  14252. public static IQbservable<IList<TSource>> TakeLastBuffer<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  14253. {
  14254. if (source == null)
  14255. throw new ArgumentNullException("source");
  14256. if (scheduler == null)
  14257. throw new ArgumentNullException("scheduler");
  14258. return source.Provider.CreateQuery<IList<TSource>>(
  14259. Expression.Call(
  14260. null,
  14261. #if CRIPPLED_REFLECTION
  14262. InfoOf(() => Qbservable.TakeLastBuffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  14263. #else
  14264. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14265. #endif
  14266. source.Expression,
  14267. Expression.Constant(duration, typeof(TimeSpan)),
  14268. Expression.Constant(scheduler, typeof(IScheduler))
  14269. )
  14270. );
  14271. }
  14272. /// <summary>
  14273. /// Takes elements for the specified duration until the specified end time.
  14274. /// </summary>
  14275. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14276. /// <param name="source">Source sequence to take elements from.</param>
  14277. /// <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>
  14278. /// <returns>An observable sequence with the elements taken until the specified end time.</returns>
  14279. /// <exception cref="T:System.ArgumentNullException">
  14280. /// <paramref name="source" /> is null.</exception>
  14281. public static IQbservable<TSource> TakeUntil<TSource>(this IQbservable<TSource> source, DateTimeOffset endTime)
  14282. {
  14283. if (source == null)
  14284. throw new ArgumentNullException("source");
  14285. return source.Provider.CreateQuery<TSource>(
  14286. Expression.Call(
  14287. null,
  14288. #if CRIPPLED_REFLECTION
  14289. InfoOf(() => Qbservable.TakeUntil<TSource>(default(IQbservable<TSource>), default(DateTimeOffset))),
  14290. #else
  14291. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14292. #endif
  14293. source.Expression,
  14294. Expression.Constant(endTime, typeof(DateTimeOffset))
  14295. )
  14296. );
  14297. }
  14298. /// <summary>
  14299. /// Takes elements for the specified duration until the specified end time, using the specified scheduler to run timers.
  14300. /// </summary>
  14301. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14302. /// <param name="source">Source sequence to take elements from.</param>
  14303. /// <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>
  14304. /// <param name="scheduler">Scheduler to run the timer on.</param>
  14305. /// <returns>An observable sequence with the elements taken until the specified end time.</returns>
  14306. /// <exception cref="T:System.ArgumentNullException">
  14307. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14308. public static IQbservable<TSource> TakeUntil<TSource>(this IQbservable<TSource> source, DateTimeOffset endTime, IScheduler scheduler)
  14309. {
  14310. if (source == null)
  14311. throw new ArgumentNullException("source");
  14312. if (scheduler == null)
  14313. throw new ArgumentNullException("scheduler");
  14314. return source.Provider.CreateQuery<TSource>(
  14315. Expression.Call(
  14316. null,
  14317. #if CRIPPLED_REFLECTION
  14318. InfoOf(() => Qbservable.TakeUntil<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IScheduler))),
  14319. #else
  14320. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14321. #endif
  14322. source.Expression,
  14323. Expression.Constant(endTime, typeof(DateTimeOffset)),
  14324. Expression.Constant(scheduler, typeof(IScheduler))
  14325. )
  14326. );
  14327. }
  14328. /// <summary>
  14329. /// Returns the elements from the source observable sequence until the other observable sequence produces an element.
  14330. /// </summary>
  14331. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14332. /// <typeparam name="TOther">The type of the elements in the other sequence that indicates the end of take behavior.</typeparam>
  14333. /// <param name="source">Source sequence to propagate elements for.</param>
  14334. /// <param name="other">Observable sequence that terminates propagation of elements of the source sequence.</param>
  14335. /// <returns>An observable sequence containing the elements of the source sequence up to the point the other sequence interrupted further propagation.</returns>
  14336. /// <exception cref="T:System.ArgumentNullException">
  14337. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  14338. public static IQbservable<TSource> TakeUntil<TSource, TOther>(this IQbservable<TSource> source, IObservable<TOther> other)
  14339. {
  14340. if (source == null)
  14341. throw new ArgumentNullException("source");
  14342. if (other == null)
  14343. throw new ArgumentNullException("other");
  14344. return source.Provider.CreateQuery<TSource>(
  14345. Expression.Call(
  14346. null,
  14347. #if CRIPPLED_REFLECTION
  14348. InfoOf(() => Qbservable.TakeUntil<TSource, TOther>(default(IQbservable<TSource>), default(IObservable<TOther>))),
  14349. #else
  14350. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)),
  14351. #endif
  14352. source.Expression,
  14353. GetSourceExpression(other)
  14354. )
  14355. );
  14356. }
  14357. /// <summary>
  14358. /// Returns elements from an observable sequence as long as a specified condition is true.
  14359. /// </summary>
  14360. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14361. /// <param name="source">A sequence to return elements from.</param>
  14362. /// <param name="predicate">A function to test each element for a condition.</param>
  14363. /// <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>
  14364. /// <exception cref="T:System.ArgumentNullException">
  14365. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  14366. public static IQbservable<TSource> TakeWhile<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  14367. {
  14368. if (source == null)
  14369. throw new ArgumentNullException("source");
  14370. if (predicate == null)
  14371. throw new ArgumentNullException("predicate");
  14372. return source.Provider.CreateQuery<TSource>(
  14373. Expression.Call(
  14374. null,
  14375. #if CRIPPLED_REFLECTION
  14376. InfoOf(() => Qbservable.TakeWhile<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  14377. #else
  14378. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14379. #endif
  14380. source.Expression,
  14381. predicate
  14382. )
  14383. );
  14384. }
  14385. /// <summary>
  14386. /// Returns elements from an observable sequence as long as a specified condition is true.
  14387. /// The element's index is used in the logic of the predicate function.
  14388. /// </summary>
  14389. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14390. /// <param name="source">A sequence to return elements from.</param>
  14391. /// <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>
  14392. /// <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>
  14393. /// <exception cref="T:System.ArgumentNullException">
  14394. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  14395. public static IQbservable<TSource> TakeWhile<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int, bool>> predicate)
  14396. {
  14397. if (source == null)
  14398. throw new ArgumentNullException("source");
  14399. if (predicate == null)
  14400. throw new ArgumentNullException("predicate");
  14401. return source.Provider.CreateQuery<TSource>(
  14402. Expression.Call(
  14403. null,
  14404. #if CRIPPLED_REFLECTION
  14405. InfoOf(() => Qbservable.TakeWhile<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, bool>>))),
  14406. #else
  14407. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14408. #endif
  14409. source.Expression,
  14410. predicate
  14411. )
  14412. );
  14413. }
  14414. /// <summary>
  14415. /// Performs a subsequent ordering of the elements in a sequence in ascending order according to a key.
  14416. /// </summary>
  14417. /// <typeparam name="TSource">The type of the elements in the <paramref name="source" /> sequence.</typeparam>
  14418. /// <typeparam name="TKey">The type of the sorting key computed for each element in the source sequence.</typeparam>
  14419. /// <param name="source">An observable sequence of values to order.</param>
  14420. /// <param name="keySelector">A function to extract the key for each element.</param>
  14421. /// <returns>An <see cref="T:System.Reactive.Linq.IOrderedObservable`1" /> whose elements are sorted according to a key.</returns>
  14422. /// <exception cref="T:System.ArgumentNullException">
  14423. /// <paramref name="source" /> or <paramref name="keySelector" /> is <see langword="null" />.</exception>
  14424. public static IOrderedQbservable<TSource> ThenBy<TSource, TKey>(this IOrderedQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  14425. {
  14426. if (source == null)
  14427. throw new ArgumentNullException("source");
  14428. if (keySelector == null)
  14429. throw new ArgumentNullException("keySelector");
  14430. return (IOrderedQbservable<TSource>)source.Provider.CreateQuery<TSource>(
  14431. Expression.Call(
  14432. null,
  14433. #if CRIPPLED_REFLECTION
  14434. InfoOf(() => Qbservable.ThenBy<TSource, TKey>(default(IOrderedQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  14435. #else
  14436. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  14437. #endif
  14438. source.Expression,
  14439. keySelector
  14440. )
  14441. );
  14442. }
  14443. /// <summary>
  14444. /// Performs a subsequent ordering of the elements in a sequence in ascending order by using a specified comparer.
  14445. /// </summary>
  14446. /// <typeparam name="TSource">The type of the elements in the <paramref name="source" /> sequence.</typeparam>
  14447. /// <typeparam name="TKey">The type of the sorting key computed for each element in the source sequence.</typeparam>
  14448. /// <param name="source">An observable sequence of values to order.</param>
  14449. /// <param name="keySelector">A function to extract the key for each element.</param>
  14450. /// <param name="comparer">An <see cref="T:System.Collections.Generic.IComparer`1" /> to compare keys.</param>
  14451. /// <returns>An <see cref="T:System.Reactive.Linq.IOrderedObservable`1" /> whose elements are sorted according to a key.</returns>
  14452. /// <exception cref="T:System.ArgumentNullException">
  14453. /// <paramref name="source" />, <paramref name="keySelector" /> or <paramref name="comparer" /> is <see langword="null" />.</exception>
  14454. public static IOrderedQbservable<TSource> ThenBy<TSource, TKey>(this IOrderedQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer)
  14455. {
  14456. if (source == null)
  14457. throw new ArgumentNullException("source");
  14458. if (keySelector == null)
  14459. throw new ArgumentNullException("keySelector");
  14460. if (comparer == null)
  14461. throw new ArgumentNullException("comparer");
  14462. return (IOrderedQbservable<TSource>)source.Provider.CreateQuery<TSource>(
  14463. Expression.Call(
  14464. null,
  14465. #if CRIPPLED_REFLECTION
  14466. InfoOf(() => Qbservable.ThenBy<TSource, TKey>(default(IOrderedQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IComparer<TKey>))),
  14467. #else
  14468. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  14469. #endif
  14470. source.Expression,
  14471. keySelector,
  14472. Expression.Constant(comparer, typeof(IComparer<TKey>))
  14473. )
  14474. );
  14475. }
  14476. /// <summary>
  14477. /// Performs a subsequent ordering of the elements in a sequence in ascending order according to the times at which corresponding observable sequences produce their first notification or complete.
  14478. /// </summary>
  14479. /// <typeparam name="TSource">The type of the elements in the <paramref name="source" /> sequence.</typeparam>
  14480. /// <typeparam name="TOther">The type of the elements in the observable returned by <paramref name="timeSelector" />.</typeparam>
  14481. /// <param name="source">An observable sequence of values to order.</param>
  14482. /// <param name="timeSelector">A function that returns an observable for an element in the <paramref name="source" /> sequence indicating the time at which that element should appear in the ordering.</param>
  14483. /// <returns>An <see cref="T:System.Reactive.Linq.IOrderedObservable`1" /> whose elements are sorted according to the times at which corresponding observable sequences produce their first notification or complete.</returns>
  14484. /// <exception cref="T:System.ArgumentNullException">
  14485. /// <paramref name="source" /> or <paramref name="timeSelector" /> is <see langword="null" />.</exception>
  14486. /// <remarks>
  14487. /// <para>
  14488. /// This overload of ThenBy is similar to a particular usage of SelectMany where the elements in the <paramref name="source" /> sequence are returned based on the times
  14489. /// at which their corresponding inner sequences produce their first notification or complete. Any elements in the inner sequences are discarded.
  14490. /// </para>
  14491. /// <alert type="info">
  14492. /// Unlike the other overload of ThenBy, this overload does not buffer any elements and it does not wait for the <paramref name="source" /> sequence to complete before it
  14493. /// pushes notifications. This overload is entirely reactive.
  14494. /// </alert>
  14495. /// <para>
  14496. /// This overload supports using the orderby LINQ query comprehension syntax in C# and Visual Basic by passing an observable sequence as a subsequent key.
  14497. /// </para>
  14498. /// </remarks>
  14499. public static IOrderedQbservable<TSource> ThenBy<TSource, TOther>(this IOrderedQbservable<TSource> source, Expression<Func<TSource, IObservable<TOther>>> timeSelector)
  14500. {
  14501. if (source == null)
  14502. throw new ArgumentNullException("source");
  14503. if (timeSelector == null)
  14504. throw new ArgumentNullException("timeSelector");
  14505. return (IOrderedQbservable<TSource>)source.Provider.CreateQuery<TSource>(
  14506. Expression.Call(
  14507. null,
  14508. #if CRIPPLED_REFLECTION
  14509. InfoOf(() => Qbservable.ThenBy<TSource, TOther>(default(IOrderedQbservable<TSource>), default(Expression<Func<TSource, IObservable<TOther>>>))),
  14510. #else
  14511. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)),
  14512. #endif
  14513. source.Expression,
  14514. timeSelector
  14515. )
  14516. );
  14517. }
  14518. /// <summary>
  14519. /// Performs a subsequent ordering of the elements in a sequence in descending order according to a key.
  14520. /// </summary>
  14521. /// <typeparam name="TSource">The type of the elements in the <paramref name="source" /> sequence.</typeparam>
  14522. /// <typeparam name="TKey">The type of the sorting key computed for each element in the source sequence.</typeparam>
  14523. /// <param name="source">An observable sequence of values to order.</param>
  14524. /// <param name="keySelector">A function to extract the key for each element.</param>
  14525. /// <returns>An <see cref="T:System.Reactive.Linq.IOrderedObservable`1" /> whose elements are sorted in descending order according to a key.</returns>
  14526. /// <exception cref="T:System.ArgumentNullException">
  14527. /// <paramref name="source" /> or <paramref name="keySelector" /> is <see langword="null" />.</exception>
  14528. public static IOrderedQbservable<TSource> ThenByDescending<TSource, TKey>(this IOrderedQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  14529. {
  14530. if (source == null)
  14531. throw new ArgumentNullException("source");
  14532. if (keySelector == null)
  14533. throw new ArgumentNullException("keySelector");
  14534. return (IOrderedQbservable<TSource>)source.Provider.CreateQuery<TSource>(
  14535. Expression.Call(
  14536. null,
  14537. #if CRIPPLED_REFLECTION
  14538. InfoOf(() => Qbservable.ThenByDescending<TSource, TKey>(default(IOrderedQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  14539. #else
  14540. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  14541. #endif
  14542. source.Expression,
  14543. keySelector
  14544. )
  14545. );
  14546. }
  14547. /// <summary>
  14548. /// Performs a subsequent ordering of the elements in a sequence in descending order by using a specified comparer.
  14549. /// </summary>
  14550. /// <typeparam name="TSource">The type of the elements in the <paramref name="source" /> sequence.</typeparam>
  14551. /// <typeparam name="TKey">The type of the sorting key computed for each element in the source sequence.</typeparam>
  14552. /// <param name="source">An observable sequence of values to order.</param>
  14553. /// <param name="keySelector">A function to extract the key for each element.</param>
  14554. /// <param name="comparer">An <see cref="T:System.Collections.Generic.IComparer`1" /> to compare keys.</param>
  14555. /// <returns>An <see cref="T:System.Reactive.Linq.IOrderedObservable`1" /> whose elements are sorted in descending order according to a key.</returns>
  14556. /// <exception cref="T:System.ArgumentNullException">
  14557. /// <paramref name="source" />, <paramref name="keySelector" /> or <paramref name="comparer" /> is <see langword="null" />.</exception>
  14558. public static IOrderedQbservable<TSource> ThenByDescending<TSource, TKey>(this IOrderedQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer)
  14559. {
  14560. if (source == null)
  14561. throw new ArgumentNullException("source");
  14562. if (keySelector == null)
  14563. throw new ArgumentNullException("keySelector");
  14564. if (comparer == null)
  14565. throw new ArgumentNullException("comparer");
  14566. return (IOrderedQbservable<TSource>)source.Provider.CreateQuery<TSource>(
  14567. Expression.Call(
  14568. null,
  14569. #if CRIPPLED_REFLECTION
  14570. InfoOf(() => Qbservable.ThenByDescending<TSource, TKey>(default(IOrderedQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IComparer<TKey>))),
  14571. #else
  14572. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  14573. #endif
  14574. source.Expression,
  14575. keySelector,
  14576. Expression.Constant(comparer, typeof(IComparer<TKey>))
  14577. )
  14578. );
  14579. }
  14580. /// <summary>
  14581. /// Performs a subsequent ordering of the elements in a sequence in descending order according to the times at which corresponding observable sequences produce their first notification or complete.
  14582. /// </summary>
  14583. /// <typeparam name="TSource">The type of the elements in the <paramref name="source" /> sequence.</typeparam>
  14584. /// <typeparam name="TOther">The type of the elements in the observable returned by <paramref name="timeSelector" />.</typeparam>
  14585. /// <param name="source">An observable sequence of values to order.</param>
  14586. /// <param name="timeSelector">A function that returns an observable for an element in the <paramref name="source" /> sequence indicating the time at which that element should appear in the ordering.</param>
  14587. /// <returns>An <see cref="T:System.Reactive.Linq.IOrderedObservable`1" /> whose elements are sorted in descending order according to the times at which corresponding observable sequences produce their first notification or complete.</returns>
  14588. /// <exception cref="T:System.ArgumentNullException">
  14589. /// <paramref name="source" /> or <paramref name="timeSelector" /> is <see langword="null" />.</exception>
  14590. /// <remarks>
  14591. /// <para>
  14592. /// Ordering descending by time requires all of the elements in the <paramref name="source" /> sequence to be observed before it can complete,
  14593. /// which means that all of the elements must be buffered. Ordering an observable sequence descending by time is similar to performing an aggregation
  14594. /// such as <see cref="M:System.Reactive.Linq.Observable.ToList``1(System.IObservable{``0})" /> because timing from the <paramref name="source" /> sequence is lost and notifications are only generated when
  14595. /// the <paramref name="source" /> sequence calls OnCompleted.
  14596. /// </para>
  14597. /// <alert type="warn">
  14598. /// Do not attempt to order an observable sequence that never calls OnCompleted. There will be no notifications generated, and it
  14599. /// may result in an <see cref="T:System.OutOfMemoryException" /> being thrown.
  14600. /// </alert>
  14601. /// <para>
  14602. /// This overload of ThenByDescending is similar to a particular usage of SelectMany where the elements in the <paramref name="source" /> sequence are returned based on the times
  14603. /// at which their corresponding inner sequences produce their first notification or complete. Any elements in the inner sequences are discarded.
  14604. /// </para>
  14605. /// <para>
  14606. /// This overload supports using the orderby LINQ query comprehension syntax in C# and Visual Basic by passing an observable sequence as a subsequent key.
  14607. /// </para>
  14608. /// </remarks>
  14609. public static IOrderedQbservable<TSource> ThenByDescending<TSource, TOther>(this IOrderedQbservable<TSource> source, Expression<Func<TSource, IObservable<TOther>>> timeSelector)
  14610. {
  14611. if (source == null)
  14612. throw new ArgumentNullException("source");
  14613. if (timeSelector == null)
  14614. throw new ArgumentNullException("timeSelector");
  14615. return (IOrderedQbservable<TSource>)source.Provider.CreateQuery<TSource>(
  14616. Expression.Call(
  14617. null,
  14618. #if CRIPPLED_REFLECTION
  14619. InfoOf(() => Qbservable.ThenByDescending<TSource, TOther>(default(IOrderedQbservable<TSource>), default(Expression<Func<TSource, IObservable<TOther>>>))),
  14620. #else
  14621. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)),
  14622. #endif
  14623. source.Expression,
  14624. timeSelector
  14625. )
  14626. );
  14627. }
  14628. /// <summary>
  14629. /// Ignores elements from an observable sequence which are followed by another element within a specified relative time duration.
  14630. /// </summary>
  14631. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14632. /// <param name="source">Source sequence to throttle.</param>
  14633. /// <param name="dueTime">Throttling duration for each element.</param>
  14634. /// <returns>The throttled sequence.</returns>
  14635. /// <exception cref="T:System.ArgumentNullException">
  14636. /// <paramref name="source" /> is null.</exception>
  14637. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14638. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14639. /// <remarks>
  14640. /// <para>
  14641. /// This operator throttles the source sequence by holding on to each element for the duration specified in <paramref name="dueTime" />. If another
  14642. /// element is produced within this time window, the element is dropped and a new timer is started for the current element, repeating this whole
  14643. /// process. For streams that never have gaps larger than or equal to <paramref name="dueTime" /> between elements, the resulting stream won't
  14644. /// produce any elements. In order to reduce the volume of a stream whilst guaranteeing the periodic production of elements, consider using the
  14645. /// Observable.Sample set of operators.
  14646. /// </para>
  14647. /// <para>
  14648. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing throttling timers to be scheduled
  14649. /// 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
  14650. /// asynchrony introduced by the scheduler, where the action to forward the current element may not execute immediately, despite the TimeSpan.Zero
  14651. /// due time. In such cases, the next element may arrive before the scheduler gets a chance to run the throttling action.
  14652. /// </para>
  14653. /// </remarks>
  14654. public static IQbservable<TSource> Throttle<TSource>(this IQbservable<TSource> source, TimeSpan dueTime)
  14655. {
  14656. if (source == null)
  14657. throw new ArgumentNullException("source");
  14658. return source.Provider.CreateQuery<TSource>(
  14659. Expression.Call(
  14660. null,
  14661. #if CRIPPLED_REFLECTION
  14662. InfoOf(() => Qbservable.Throttle<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  14663. #else
  14664. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14665. #endif
  14666. source.Expression,
  14667. Expression.Constant(dueTime, typeof(TimeSpan))
  14668. )
  14669. );
  14670. }
  14671. /// <summary>
  14672. /// 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.
  14673. /// </summary>
  14674. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14675. /// <param name="source">Source sequence to throttle.</param>
  14676. /// <param name="dueTime">Throttling duration for each element.</param>
  14677. /// <param name="scheduler">Scheduler to run the throttle timers on.</param>
  14678. /// <returns>The throttled sequence.</returns>
  14679. /// <exception cref="T:System.ArgumentNullException">
  14680. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14681. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14682. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14683. /// <remarks>
  14684. /// <para>
  14685. /// This operator throttles the source sequence by holding on to each element for the duration specified in <paramref name="dueTime" />. If another
  14686. /// element is produced within this time window, the element is dropped and a new timer is started for the current element, repeating this whole
  14687. /// process. For streams that never have gaps larger than or equal to <paramref name="dueTime" /> between elements, the resulting stream won't
  14688. /// produce any elements. In order to reduce the volume of a stream whilst guaranteeing the periodic production of elements, consider using the
  14689. /// Observable.Sample set of operators.
  14690. /// </para>
  14691. /// <para>
  14692. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing throttling timers to be scheduled
  14693. /// 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
  14694. /// asynchrony introduced by the scheduler, where the action to forward the current element may not execute immediately, despite the TimeSpan.Zero
  14695. /// due time. In such cases, the next element may arrive before the scheduler gets a chance to run the throttling action.
  14696. /// </para>
  14697. /// </remarks>
  14698. public static IQbservable<TSource> Throttle<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IScheduler scheduler)
  14699. {
  14700. if (source == null)
  14701. throw new ArgumentNullException("source");
  14702. if (scheduler == null)
  14703. throw new ArgumentNullException("scheduler");
  14704. return source.Provider.CreateQuery<TSource>(
  14705. Expression.Call(
  14706. null,
  14707. #if CRIPPLED_REFLECTION
  14708. InfoOf(() => Qbservable.Throttle<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  14709. #else
  14710. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14711. #endif
  14712. source.Expression,
  14713. Expression.Constant(dueTime, typeof(TimeSpan)),
  14714. Expression.Constant(scheduler, typeof(IScheduler))
  14715. )
  14716. );
  14717. }
  14718. /// <summary>
  14719. /// Ignores elements from an observable sequence which are followed by another value within a computed throttle duration.
  14720. /// </summary>
  14721. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14722. /// <typeparam name="TThrottle">The type of the elements in the throttle sequences selected for each element in the source sequence.</typeparam>
  14723. /// <param name="source">Source sequence to throttle.</param>
  14724. /// <param name="throttleDurationSelector">Selector function to retrieve a sequence indicating the throttle duration for each given element.</param>
  14725. /// <returns>The throttled sequence.</returns>
  14726. /// <exception cref="T:System.ArgumentNullException">
  14727. /// <paramref name="source" /> or <paramref name="throttleDurationSelector" /> is null.</exception>
  14728. /// <remarks>
  14729. /// This operator throttles the source sequence by holding on to each element for the duration denoted by <paramref name="throttleDurationSelector" />.
  14730. /// 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
  14731. /// whole process. For streams where the duration computed by applying the <paramref name="throttleDurationSelector" /> to each element overlaps with
  14732. /// the occurrence of the successor element, the resulting stream won't produce any elements. In order to reduce the volume of a stream whilst
  14733. /// guaranteeing the periodic production of elements, consider using the Observable.Sample set of operators.
  14734. /// </remarks>
  14735. public static IQbservable<TSource> Throttle<TSource, TThrottle>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TThrottle>>> throttleDurationSelector)
  14736. {
  14737. if (source == null)
  14738. throw new ArgumentNullException("source");
  14739. if (throttleDurationSelector == null)
  14740. throw new ArgumentNullException("throttleDurationSelector");
  14741. return source.Provider.CreateQuery<TSource>(
  14742. Expression.Call(
  14743. null,
  14744. #if CRIPPLED_REFLECTION
  14745. InfoOf(() => Qbservable.Throttle<TSource, TThrottle>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TThrottle>>>))),
  14746. #else
  14747. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TThrottle)),
  14748. #endif
  14749. source.Expression,
  14750. throttleDurationSelector
  14751. )
  14752. );
  14753. }
  14754. /// <summary>
  14755. /// Returns an observable sequence that terminates with an exception.
  14756. /// </summary>
  14757. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  14758. /// <typeparam name="TResult">The type used for the IObservable&lt;T&gt; type parameter of the resulting sequence.</typeparam>
  14759. /// <param name="exception">Exception object used for the sequence's termination.</param>
  14760. /// <returns>The observable sequence that terminates exceptionally with the specified exception object.</returns>
  14761. /// <exception cref="T:System.ArgumentNullException">
  14762. /// <paramref name="exception" /> is null.</exception>
  14763. public static IQbservable<TResult> Throw<TResult>(this IQbservableProvider provider, Exception exception)
  14764. {
  14765. if (provider == null)
  14766. throw new ArgumentNullException("provider");
  14767. if (exception == null)
  14768. throw new ArgumentNullException("exception");
  14769. return provider.CreateQuery<TResult>(
  14770. Expression.Call(
  14771. null,
  14772. #if CRIPPLED_REFLECTION
  14773. InfoOf(() => Qbservable.Throw<TResult>(default(IQbservableProvider), default(Exception))),
  14774. #else
  14775. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  14776. #endif
  14777. Expression.Constant(provider, typeof(IQbservableProvider)),
  14778. Expression.Constant(exception, typeof(Exception))
  14779. )
  14780. );
  14781. }
  14782. /// <summary>
  14783. /// Returns an observable sequence that terminates with an exception, using the specified scheduler to send out the single OnError message.
  14784. /// </summary>
  14785. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  14786. /// <typeparam name="TResult">The type used for the IObservable&lt;T&gt; type parameter of the resulting sequence.</typeparam>
  14787. /// <param name="exception">Exception object used for the sequence's termination.</param>
  14788. /// <param name="scheduler">Scheduler to send the exceptional termination call on.</param>
  14789. /// <returns>The observable sequence that terminates exceptionally with the specified exception object.</returns>
  14790. /// <exception cref="T:System.ArgumentNullException">
  14791. /// <paramref name="exception" /> or <paramref name="scheduler" /> is null.</exception>
  14792. public static IQbservable<TResult> Throw<TResult>(this IQbservableProvider provider, Exception exception, IScheduler scheduler)
  14793. {
  14794. if (provider == null)
  14795. throw new ArgumentNullException("provider");
  14796. if (exception == null)
  14797. throw new ArgumentNullException("exception");
  14798. if (scheduler == null)
  14799. throw new ArgumentNullException("scheduler");
  14800. return provider.CreateQuery<TResult>(
  14801. Expression.Call(
  14802. null,
  14803. #if CRIPPLED_REFLECTION
  14804. InfoOf(() => Qbservable.Throw<TResult>(default(IQbservableProvider), default(Exception), default(IScheduler))),
  14805. #else
  14806. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  14807. #endif
  14808. Expression.Constant(provider, typeof(IQbservableProvider)),
  14809. Expression.Constant(exception, typeof(Exception)),
  14810. Expression.Constant(scheduler, typeof(IScheduler))
  14811. )
  14812. );
  14813. }
  14814. /// <summary>
  14815. /// Returns an observable sequence that terminates with an exception, using the specified scheduler to send out the single OnError message.
  14816. /// </summary>
  14817. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  14818. /// <typeparam name="TResult">The type used for the IObservable&lt;T&gt; type parameter of the resulting sequence.</typeparam>
  14819. /// <param name="exception">Exception object used for the sequence's termination.</param>
  14820. /// <param name="scheduler">Scheduler to send the exceptional termination call on.</param>
  14821. /// <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>
  14822. /// <returns>The observable sequence that terminates exceptionally with the specified exception object.</returns>
  14823. /// <exception cref="T:System.ArgumentNullException">
  14824. /// <paramref name="exception" /> or <paramref name="scheduler" /> is null.</exception>
  14825. public static IQbservable<TResult> Throw<TResult>(this IQbservableProvider provider, Exception exception, IScheduler scheduler, TResult witness)
  14826. {
  14827. if (provider == null)
  14828. throw new ArgumentNullException("provider");
  14829. if (exception == null)
  14830. throw new ArgumentNullException("exception");
  14831. if (scheduler == null)
  14832. throw new ArgumentNullException("scheduler");
  14833. return provider.CreateQuery<TResult>(
  14834. Expression.Call(
  14835. null,
  14836. #if CRIPPLED_REFLECTION
  14837. InfoOf(() => Qbservable.Throw<TResult>(default(IQbservableProvider), default(Exception), default(IScheduler), default(TResult))),
  14838. #else
  14839. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  14840. #endif
  14841. Expression.Constant(provider, typeof(IQbservableProvider)),
  14842. Expression.Constant(exception, typeof(Exception)),
  14843. Expression.Constant(scheduler, typeof(IScheduler)),
  14844. Expression.Constant(witness, typeof(TResult))
  14845. )
  14846. );
  14847. }
  14848. /// <summary>
  14849. /// Returns an observable sequence that terminates with an exception.
  14850. /// </summary>
  14851. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  14852. /// <typeparam name="TResult">The type used for the IObservable&lt;T&gt; type parameter of the resulting sequence.</typeparam>
  14853. /// <param name="exception">Exception object used for the sequence's termination.</param>
  14854. /// <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>
  14855. /// <returns>The observable sequence that terminates exceptionally with the specified exception object.</returns>
  14856. /// <exception cref="T:System.ArgumentNullException">
  14857. /// <paramref name="exception" /> is null.</exception>
  14858. public static IQbservable<TResult> Throw<TResult>(this IQbservableProvider provider, Exception exception, TResult witness)
  14859. {
  14860. if (provider == null)
  14861. throw new ArgumentNullException("provider");
  14862. if (exception == null)
  14863. throw new ArgumentNullException("exception");
  14864. return provider.CreateQuery<TResult>(
  14865. Expression.Call(
  14866. null,
  14867. #if CRIPPLED_REFLECTION
  14868. InfoOf(() => Qbservable.Throw<TResult>(default(IQbservableProvider), default(Exception), default(TResult))),
  14869. #else
  14870. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  14871. #endif
  14872. Expression.Constant(provider, typeof(IQbservableProvider)),
  14873. Expression.Constant(exception, typeof(Exception)),
  14874. Expression.Constant(witness, typeof(TResult))
  14875. )
  14876. );
  14877. }
  14878. /// <summary>
  14879. /// Records the time interval between consecutive elements in an observable sequence.
  14880. /// </summary>
  14881. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14882. /// <param name="source">Source sequence to record time intervals for.</param>
  14883. /// <returns>An observable sequence with time interval information on elements.</returns>
  14884. /// <exception cref="T:System.ArgumentNullException">
  14885. /// <paramref name="source" /> is null.</exception>
  14886. public static IQbservable<TimeInterval<TSource>> TimeInterval<TSource>(this IQbservable<TSource> source)
  14887. {
  14888. if (source == null)
  14889. throw new ArgumentNullException("source");
  14890. return source.Provider.CreateQuery<TimeInterval<TSource>>(
  14891. Expression.Call(
  14892. null,
  14893. #if CRIPPLED_REFLECTION
  14894. InfoOf(() => Qbservable.TimeInterval<TSource>(default(IQbservable<TSource>))),
  14895. #else
  14896. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14897. #endif
  14898. source.Expression
  14899. )
  14900. );
  14901. }
  14902. /// <summary>
  14903. /// Records the time interval between consecutive elements in an observable sequence, using the specified scheduler to compute time intervals.
  14904. /// </summary>
  14905. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14906. /// <param name="source">Source sequence to record time intervals for.</param>
  14907. /// <param name="scheduler">Scheduler used to compute time intervals.</param>
  14908. /// <returns>An observable sequence with time interval information on elements.</returns>
  14909. /// <exception cref="T:System.ArgumentNullException">
  14910. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14911. public static IQbservable<TimeInterval<TSource>> TimeInterval<TSource>(this IQbservable<TSource> source, IScheduler scheduler)
  14912. {
  14913. if (source == null)
  14914. throw new ArgumentNullException("source");
  14915. if (scheduler == null)
  14916. throw new ArgumentNullException("scheduler");
  14917. return source.Provider.CreateQuery<TimeInterval<TSource>>(
  14918. Expression.Call(
  14919. null,
  14920. #if CRIPPLED_REFLECTION
  14921. InfoOf(() => Qbservable.TimeInterval<TSource>(default(IQbservable<TSource>), default(IScheduler))),
  14922. #else
  14923. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14924. #endif
  14925. source.Expression,
  14926. Expression.Constant(scheduler, typeof(IScheduler))
  14927. )
  14928. );
  14929. }
  14930. /// <summary>
  14931. /// Applies a timeout policy to the observable sequence based on an absolute time.
  14932. /// If the sequence doesn't terminate before the specified absolute due time, a TimeoutException is propagated to the observer.
  14933. /// </summary>
  14934. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14935. /// <param name="source">Source sequence to perform a timeout for.</param>
  14936. /// <param name="dueTime">Time when a timeout occurs. If this value is less than or equal to DateTimeOffset.UtcNow, the timeout occurs immediately.</param>
  14937. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  14938. /// <exception cref="T:System.ArgumentNullException">
  14939. /// <paramref name="source" /> is null.</exception>
  14940. /// <exception cref="T:System.TimeoutException">(Asynchronous) If the sequence hasn't terminated before <paramref name="dueTime" />.</exception>
  14941. /// <remarks>
  14942. /// 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})" />
  14943. /// 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
  14944. /// 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.
  14945. /// </remarks>
  14946. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime)
  14947. {
  14948. if (source == null)
  14949. throw new ArgumentNullException("source");
  14950. return source.Provider.CreateQuery<TSource>(
  14951. Expression.Call(
  14952. null,
  14953. #if CRIPPLED_REFLECTION
  14954. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(DateTimeOffset))),
  14955. #else
  14956. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14957. #endif
  14958. source.Expression,
  14959. Expression.Constant(dueTime, typeof(DateTimeOffset))
  14960. )
  14961. );
  14962. }
  14963. /// <summary>
  14964. /// Applies a timeout policy to the observable sequence based on an absolute time.
  14965. /// 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.
  14966. /// </summary>
  14967. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  14968. /// <param name="source">Source sequence to perform a timeout for.</param>
  14969. /// <param name="dueTime">Time when a timeout occurs. If this value is less than or equal to DateTimeOffset.UtcNow, the timeout occurs immediately.</param>
  14970. /// <param name="other">Sequence to return in case of a timeout.</param>
  14971. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  14972. /// <exception cref="T:System.ArgumentNullException">
  14973. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  14974. /// <remarks>
  14975. /// 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})" />
  14976. /// 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
  14977. /// 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.
  14978. /// </remarks>
  14979. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime, IObservable<TSource> other)
  14980. {
  14981. if (source == null)
  14982. throw new ArgumentNullException("source");
  14983. if (other == null)
  14984. throw new ArgumentNullException("other");
  14985. return source.Provider.CreateQuery<TSource>(
  14986. Expression.Call(
  14987. null,
  14988. #if CRIPPLED_REFLECTION
  14989. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IObservable<TSource>))),
  14990. #else
  14991. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14992. #endif
  14993. source.Expression,
  14994. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  14995. GetSourceExpression(other)
  14996. )
  14997. );
  14998. }
  14999. /// <summary>
  15000. /// Applies a timeout policy to the observable sequence based on an absolute time, using the specified scheduler to run timeout timers.
  15001. /// 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.
  15002. /// </summary>
  15003. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  15004. /// <param name="source">Source sequence to perform a timeout for.</param>
  15005. /// <param name="dueTime">Time when a timeout occurs. If this value is less than or equal to DateTimeOffset.UtcNow, the timeout occurs immediately.</param>
  15006. /// <param name="other">Sequence to return in case of a timeout.</param>
  15007. /// <param name="scheduler">Scheduler to run the timeout timers on.</param>
  15008. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  15009. /// <exception cref="T:System.ArgumentNullException">
  15010. /// <paramref name="source" /> or <paramref name="other" /> or <paramref name="scheduler" /> is null.</exception>
  15011. /// <remarks>
  15012. /// 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})" />
  15013. /// 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
  15014. /// 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.
  15015. /// </remarks>
  15016. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime, IObservable<TSource> other, IScheduler scheduler)
  15017. {
  15018. if (source == null)
  15019. throw new ArgumentNullException("source");
  15020. if (other == null)
  15021. throw new ArgumentNullException("other");
  15022. if (scheduler == null)
  15023. throw new ArgumentNullException("scheduler");
  15024. return source.Provider.CreateQuery<TSource>(
  15025. Expression.Call(
  15026. null,
  15027. #if CRIPPLED_REFLECTION
  15028. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IObservable<TSource>), default(IScheduler))),
  15029. #else
  15030. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15031. #endif
  15032. source.Expression,
  15033. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  15034. GetSourceExpression(other),
  15035. Expression.Constant(scheduler, typeof(IScheduler))
  15036. )
  15037. );
  15038. }
  15039. /// <summary>
  15040. /// Applies a timeout policy to the observable sequence based on an absolute time, using the specified scheduler to run timeout timers.
  15041. /// If the sequence doesn't terminate before the specified absolute due time, a TimeoutException is propagated to the observer.
  15042. /// </summary>
  15043. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15044. /// <param name="source">Source sequence to perform a timeout for.</param>
  15045. /// <param name="dueTime">Time when a timeout occurs. If this value is less than or equal to DateTimeOffset.UtcNow, the timeout occurs immediately.</param>
  15046. /// <param name="scheduler">Scheduler to run the timeout timers on.</param>
  15047. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  15048. /// <exception cref="T:System.ArgumentNullException">
  15049. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  15050. /// <exception cref="T:System.TimeoutException">(Asynchronous) If the sequence hasn't terminated before <paramref name="dueTime" />.</exception>
  15051. /// <remarks>
  15052. /// 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})" />
  15053. /// 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
  15054. /// 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.
  15055. /// </remarks>
  15056. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime, IScheduler scheduler)
  15057. {
  15058. if (source == null)
  15059. throw new ArgumentNullException("source");
  15060. if (scheduler == null)
  15061. throw new ArgumentNullException("scheduler");
  15062. return source.Provider.CreateQuery<TSource>(
  15063. Expression.Call(
  15064. null,
  15065. #if CRIPPLED_REFLECTION
  15066. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IScheduler))),
  15067. #else
  15068. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15069. #endif
  15070. source.Expression,
  15071. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  15072. Expression.Constant(scheduler, typeof(IScheduler))
  15073. )
  15074. );
  15075. }
  15076. /// <summary>
  15077. /// Applies a timeout policy for each element in the observable sequence.
  15078. /// If the next element isn't received within the specified timeout duration starting from its predecessor, a TimeoutException is propagated to the observer.
  15079. /// </summary>
  15080. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15081. /// <param name="source">Source sequence to perform a timeout for.</param>
  15082. /// <param name="dueTime">Maximum duration between values before a timeout occurs.</param>
  15083. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  15084. /// <exception cref="T:System.ArgumentNullException">
  15085. /// <paramref name="source" /> is null.</exception>
  15086. /// <exception cref="T:System.ArgumentOutOfRangeException">
  15087. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  15088. /// <exception cref="T:System.TimeoutException">(Asynchronous) If no element is produced within <paramref name="dueTime" /> from the previous element.</exception>
  15089. /// <remarks>
  15090. /// <para>
  15091. /// 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})" />
  15092. /// 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
  15093. /// 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.
  15094. /// </para>
  15095. /// <para>
  15096. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing timeout timers to be scheduled that are due
  15097. /// 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
  15098. /// 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
  15099. /// arrive before the scheduler gets a chance to run the timeout action.
  15100. /// </para>
  15101. /// </remarks>
  15102. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, TimeSpan dueTime)
  15103. {
  15104. if (source == null)
  15105. throw new ArgumentNullException("source");
  15106. return source.Provider.CreateQuery<TSource>(
  15107. Expression.Call(
  15108. null,
  15109. #if CRIPPLED_REFLECTION
  15110. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  15111. #else
  15112. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15113. #endif
  15114. source.Expression,
  15115. Expression.Constant(dueTime, typeof(TimeSpan))
  15116. )
  15117. );
  15118. }
  15119. /// <summary>
  15120. /// Applies a timeout policy for each element in the observable sequence.
  15121. /// 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.
  15122. /// </summary>
  15123. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  15124. /// <param name="source">Source sequence to perform a timeout for.</param>
  15125. /// <param name="dueTime">Maximum duration between values before a timeout occurs.</param>
  15126. /// <param name="other">Sequence to return in case of a timeout.</param>
  15127. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  15128. /// <exception cref="T:System.ArgumentNullException">
  15129. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  15130. /// <exception cref="T:System.ArgumentOutOfRangeException">
  15131. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  15132. /// <remarks>
  15133. /// <para>
  15134. /// 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})" />
  15135. /// 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
  15136. /// 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.
  15137. /// </para>
  15138. /// <para>
  15139. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing timeout timers to be scheduled that are due
  15140. /// 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
  15141. /// 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
  15142. /// arrive before the scheduler gets a chance to run the timeout action.
  15143. /// </para>
  15144. /// </remarks>
  15145. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IObservable<TSource> other)
  15146. {
  15147. if (source == null)
  15148. throw new ArgumentNullException("source");
  15149. if (other == null)
  15150. throw new ArgumentNullException("other");
  15151. return source.Provider.CreateQuery<TSource>(
  15152. Expression.Call(
  15153. null,
  15154. #if CRIPPLED_REFLECTION
  15155. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IObservable<TSource>))),
  15156. #else
  15157. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15158. #endif
  15159. source.Expression,
  15160. Expression.Constant(dueTime, typeof(TimeSpan)),
  15161. GetSourceExpression(other)
  15162. )
  15163. );
  15164. }
  15165. /// <summary>
  15166. /// Applies a timeout policy for each element in the observable sequence, using the specified scheduler to run timeout timers.
  15167. /// 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.
  15168. /// </summary>
  15169. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  15170. /// <param name="source">Source sequence to perform a timeout for.</param>
  15171. /// <param name="dueTime">Maximum duration between values before a timeout occurs.</param>
  15172. /// <param name="other">Sequence to return in case of a timeout.</param>
  15173. /// <param name="scheduler">Scheduler to run the timeout timers on.</param>
  15174. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  15175. /// <exception cref="T:System.ArgumentNullException">
  15176. /// <paramref name="source" /> or <paramref name="other" /> or <paramref name="scheduler" /> is null.</exception>
  15177. /// <exception cref="T:System.ArgumentOutOfRangeException">
  15178. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  15179. /// <remarks>
  15180. /// <para>
  15181. /// 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})" />
  15182. /// 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
  15183. /// 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.
  15184. /// </para>
  15185. /// <para>
  15186. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing timeout timers to be scheduled that are due
  15187. /// 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
  15188. /// 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
  15189. /// arrive before the scheduler gets a chance to run the timeout action.
  15190. /// </para>
  15191. /// </remarks>
  15192. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IObservable<TSource> other, IScheduler scheduler)
  15193. {
  15194. if (source == null)
  15195. throw new ArgumentNullException("source");
  15196. if (other == null)
  15197. throw new ArgumentNullException("other");
  15198. if (scheduler == null)
  15199. throw new ArgumentNullException("scheduler");
  15200. return source.Provider.CreateQuery<TSource>(
  15201. Expression.Call(
  15202. null,
  15203. #if CRIPPLED_REFLECTION
  15204. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IObservable<TSource>), default(IScheduler))),
  15205. #else
  15206. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15207. #endif
  15208. source.Expression,
  15209. Expression.Constant(dueTime, typeof(TimeSpan)),
  15210. GetSourceExpression(other),
  15211. Expression.Constant(scheduler, typeof(IScheduler))
  15212. )
  15213. );
  15214. }
  15215. /// <summary>
  15216. /// Applies a timeout policy for each element in the observable sequence, using the specified scheduler to run timeout timers.
  15217. /// If the next element isn't received within the specified timeout duration starting from its predecessor, a TimeoutException is propagated to the observer.
  15218. /// </summary>
  15219. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15220. /// <param name="source">Source sequence to perform a timeout for.</param>
  15221. /// <param name="dueTime">Maximum duration between values before a timeout occurs.</param>
  15222. /// <param name="scheduler">Scheduler to run the timeout timers on.</param>
  15223. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  15224. /// <exception cref="T:System.ArgumentNullException">
  15225. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  15226. /// <exception cref="T:System.ArgumentOutOfRangeException">
  15227. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  15228. /// <exception cref="T:System.TimeoutException">(Asynchronous) If no element is produced within <paramref name="dueTime" /> from the previous element.</exception>
  15229. /// <remarks>
  15230. /// <para>
  15231. /// 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})" />
  15232. /// 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
  15233. /// 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.
  15234. /// </para>
  15235. /// <para>
  15236. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing timeout timers to be scheduled that are due
  15237. /// 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
  15238. /// 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
  15239. /// arrive before the scheduler gets a chance to run the timeout action.
  15240. /// </para>
  15241. /// </remarks>
  15242. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IScheduler scheduler)
  15243. {
  15244. if (source == null)
  15245. throw new ArgumentNullException("source");
  15246. if (scheduler == null)
  15247. throw new ArgumentNullException("scheduler");
  15248. return source.Provider.CreateQuery<TSource>(
  15249. Expression.Call(
  15250. null,
  15251. #if CRIPPLED_REFLECTION
  15252. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  15253. #else
  15254. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15255. #endif
  15256. source.Expression,
  15257. Expression.Constant(dueTime, typeof(TimeSpan)),
  15258. Expression.Constant(scheduler, typeof(IScheduler))
  15259. )
  15260. );
  15261. }
  15262. /// <summary>
  15263. /// 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.
  15264. /// If the next element isn't received within the computed duration starting from its predecessor, a TimeoutException is propagated to the observer.
  15265. /// </summary>
  15266. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15267. /// <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>
  15268. /// <param name="source">Source sequence to perform a timeout for.</param>
  15269. /// <param name="firstTimeout">Observable sequence that represents the timeout for the first element.</param>
  15270. /// <param name="timeoutDurationSelector">Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.</param>
  15271. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  15272. /// <exception cref="T:System.ArgumentNullException">
  15273. /// <paramref name="source" /> or <paramref name="firstTimeout" /> or <paramref name="timeoutDurationSelector" /> is null.</exception>
  15274. public static IQbservable<TSource> Timeout<TSource, TTimeout>(this IQbservable<TSource> source, IObservable<TTimeout> firstTimeout, Expression<Func<TSource, IObservable<TTimeout>>> timeoutDurationSelector)
  15275. {
  15276. if (source == null)
  15277. throw new ArgumentNullException("source");
  15278. if (firstTimeout == null)
  15279. throw new ArgumentNullException("firstTimeout");
  15280. if (timeoutDurationSelector == null)
  15281. throw new ArgumentNullException("timeoutDurationSelector");
  15282. return source.Provider.CreateQuery<TSource>(
  15283. Expression.Call(
  15284. null,
  15285. #if CRIPPLED_REFLECTION
  15286. InfoOf(() => Qbservable.Timeout<TSource, TTimeout>(default(IQbservable<TSource>), default(IObservable<TTimeout>), default(Expression<Func<TSource, IObservable<TTimeout>>>))),
  15287. #else
  15288. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTimeout)),
  15289. #endif
  15290. source.Expression,
  15291. GetSourceExpression(firstTimeout),
  15292. timeoutDurationSelector
  15293. )
  15294. );
  15295. }
  15296. /// <summary>
  15297. /// 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.
  15298. /// 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.
  15299. /// </summary>
  15300. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  15301. /// <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>
  15302. /// <param name="source">Source sequence to perform a timeout for.</param>
  15303. /// <param name="firstTimeout">Observable sequence that represents the timeout for the first element.</param>
  15304. /// <param name="timeoutDurationSelector">Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.</param>
  15305. /// <param name="other">Sequence to return in case of a timeout.</param>
  15306. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  15307. /// <exception cref="T:System.ArgumentNullException">
  15308. /// <paramref name="source" /> or <paramref name="firstTimeout" /> or <paramref name="timeoutDurationSelector" /> or <paramref name="other" /> is null.</exception>
  15309. public static IQbservable<TSource> Timeout<TSource, TTimeout>(this IQbservable<TSource> source, IObservable<TTimeout> firstTimeout, Expression<Func<TSource, IObservable<TTimeout>>> timeoutDurationSelector, IObservable<TSource> other)
  15310. {
  15311. if (source == null)
  15312. throw new ArgumentNullException("source");
  15313. if (firstTimeout == null)
  15314. throw new ArgumentNullException("firstTimeout");
  15315. if (timeoutDurationSelector == null)
  15316. throw new ArgumentNullException("timeoutDurationSelector");
  15317. if (other == null)
  15318. throw new ArgumentNullException("other");
  15319. return source.Provider.CreateQuery<TSource>(
  15320. Expression.Call(
  15321. null,
  15322. #if CRIPPLED_REFLECTION
  15323. InfoOf(() => Qbservable.Timeout<TSource, TTimeout>(default(IQbservable<TSource>), default(IObservable<TTimeout>), default(Expression<Func<TSource, IObservable<TTimeout>>>), default(IObservable<TSource>))),
  15324. #else
  15325. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTimeout)),
  15326. #endif
  15327. source.Expression,
  15328. GetSourceExpression(firstTimeout),
  15329. timeoutDurationSelector,
  15330. GetSourceExpression(other)
  15331. )
  15332. );
  15333. }
  15334. /// <summary>
  15335. /// Applies a timeout policy to the observable sequence based on a timeout duration computed for each element.
  15336. /// If the next element isn't received within the computed duration starting from its predecessor, a TimeoutException is propagated to the observer.
  15337. /// </summary>
  15338. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15339. /// <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>
  15340. /// <param name="source">Source sequence to perform a timeout for.</param>
  15341. /// <param name="timeoutDurationSelector">Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.</param>
  15342. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  15343. /// <exception cref="T:System.ArgumentNullException">
  15344. /// <paramref name="source" /> or <paramref name="timeoutDurationSelector" /> is null.</exception>
  15345. public static IQbservable<TSource> Timeout<TSource, TTimeout>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TTimeout>>> timeoutDurationSelector)
  15346. {
  15347. if (source == null)
  15348. throw new ArgumentNullException("source");
  15349. if (timeoutDurationSelector == null)
  15350. throw new ArgumentNullException("timeoutDurationSelector");
  15351. return source.Provider.CreateQuery<TSource>(
  15352. Expression.Call(
  15353. null,
  15354. #if CRIPPLED_REFLECTION
  15355. InfoOf(() => Qbservable.Timeout<TSource, TTimeout>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TTimeout>>>))),
  15356. #else
  15357. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTimeout)),
  15358. #endif
  15359. source.Expression,
  15360. timeoutDurationSelector
  15361. )
  15362. );
  15363. }
  15364. /// <summary>
  15365. /// Applies a timeout policy to the observable sequence based on a timeout duration computed for each element.
  15366. /// 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.
  15367. /// </summary>
  15368. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  15369. /// <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>
  15370. /// <param name="source">Source sequence to perform a timeout for.</param>
  15371. /// <param name="timeoutDurationSelector">Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.</param>
  15372. /// <param name="other">Sequence to return in case of a timeout.</param>
  15373. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  15374. /// <exception cref="T:System.ArgumentNullException">
  15375. /// <paramref name="source" /> or <paramref name="timeoutDurationSelector" /> or <paramref name="other" /> is null.</exception>
  15376. public static IQbservable<TSource> Timeout<TSource, TTimeout>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TTimeout>>> timeoutDurationSelector, IObservable<TSource> other)
  15377. {
  15378. if (source == null)
  15379. throw new ArgumentNullException("source");
  15380. if (timeoutDurationSelector == null)
  15381. throw new ArgumentNullException("timeoutDurationSelector");
  15382. if (other == null)
  15383. throw new ArgumentNullException("other");
  15384. return source.Provider.CreateQuery<TSource>(
  15385. Expression.Call(
  15386. null,
  15387. #if CRIPPLED_REFLECTION
  15388. InfoOf(() => Qbservable.Timeout<TSource, TTimeout>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TTimeout>>>), default(IObservable<TSource>))),
  15389. #else
  15390. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTimeout)),
  15391. #endif
  15392. source.Expression,
  15393. timeoutDurationSelector,
  15394. GetSourceExpression(other)
  15395. )
  15396. );
  15397. }
  15398. /// <summary>
  15399. /// Returns an observable sequence that produces a single value at the specified absolute due time.
  15400. /// </summary>
  15401. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  15402. /// <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>
  15403. /// <returns>An observable sequence that produces a value at due time.</returns>
  15404. public static IQbservable<long> Timer(this IQbservableProvider provider, DateTimeOffset dueTime)
  15405. {
  15406. if (provider == null)
  15407. throw new ArgumentNullException("provider");
  15408. return provider.CreateQuery<long>(
  15409. Expression.Call(
  15410. null,
  15411. #if CRIPPLED_REFLECTION
  15412. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(DateTimeOffset))),
  15413. #else
  15414. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15415. #endif
  15416. Expression.Constant(provider, typeof(IQbservableProvider)),
  15417. Expression.Constant(dueTime, typeof(DateTimeOffset))
  15418. )
  15419. );
  15420. }
  15421. /// <summary>
  15422. /// Returns an observable sequence that periodically produces a value starting at the specified initial absolute due time.
  15423. /// </summary>
  15424. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  15425. /// <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>
  15426. /// <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>
  15427. /// <returns>An observable sequence that produces a value at due time and then after each period.</returns>
  15428. /// <exception cref="T:System.ArgumentOutOfRangeException">
  15429. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  15430. public static IQbservable<long> Timer(this IQbservableProvider provider, DateTimeOffset dueTime, TimeSpan period)
  15431. {
  15432. if (provider == null)
  15433. throw new ArgumentNullException("provider");
  15434. return provider.CreateQuery<long>(
  15435. Expression.Call(
  15436. null,
  15437. #if CRIPPLED_REFLECTION
  15438. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(DateTimeOffset), default(TimeSpan))),
  15439. #else
  15440. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15441. #endif
  15442. Expression.Constant(provider, typeof(IQbservableProvider)),
  15443. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  15444. Expression.Constant(period, typeof(TimeSpan))
  15445. )
  15446. );
  15447. }
  15448. /// <summary>
  15449. /// Returns an observable sequence that periodically produces a value starting at the specified initial absolute due time, using the specified scheduler to run timers.
  15450. /// </summary>
  15451. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  15452. /// <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>
  15453. /// <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>
  15454. /// <param name="scheduler">Scheduler to run timers on.</param>
  15455. /// <returns>An observable sequence that produces a value at due time and then after each period.</returns>
  15456. /// <exception cref="T:System.ArgumentOutOfRangeException">
  15457. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  15458. /// <exception cref="T:System.ArgumentNullException">
  15459. /// <paramref name="scheduler" /> is null.</exception>
  15460. public static IQbservable<long> Timer(this IQbservableProvider provider, DateTimeOffset dueTime, TimeSpan period, IScheduler scheduler)
  15461. {
  15462. if (provider == null)
  15463. throw new ArgumentNullException("provider");
  15464. if (scheduler == null)
  15465. throw new ArgumentNullException("scheduler");
  15466. return provider.CreateQuery<long>(
  15467. Expression.Call(
  15468. null,
  15469. #if CRIPPLED_REFLECTION
  15470. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(DateTimeOffset), default(TimeSpan), default(IScheduler))),
  15471. #else
  15472. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15473. #endif
  15474. Expression.Constant(provider, typeof(IQbservableProvider)),
  15475. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  15476. Expression.Constant(period, typeof(TimeSpan)),
  15477. Expression.Constant(scheduler, typeof(IScheduler))
  15478. )
  15479. );
  15480. }
  15481. /// <summary>
  15482. /// Returns an observable sequence that produces a single value at the specified absolute due time, using the specified scheduler to run the timer.
  15483. /// </summary>
  15484. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  15485. /// <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>
  15486. /// <param name="scheduler">Scheduler to run the timer on.</param>
  15487. /// <returns>An observable sequence that produces a value at due time.</returns>
  15488. /// <exception cref="T:System.ArgumentNullException">
  15489. /// <paramref name="scheduler" /> is null.</exception>
  15490. public static IQbservable<long> Timer(this IQbservableProvider provider, DateTimeOffset dueTime, IScheduler scheduler)
  15491. {
  15492. if (provider == null)
  15493. throw new ArgumentNullException("provider");
  15494. if (scheduler == null)
  15495. throw new ArgumentNullException("scheduler");
  15496. return provider.CreateQuery<long>(
  15497. Expression.Call(
  15498. null,
  15499. #if CRIPPLED_REFLECTION
  15500. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(DateTimeOffset), default(IScheduler))),
  15501. #else
  15502. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15503. #endif
  15504. Expression.Constant(provider, typeof(IQbservableProvider)),
  15505. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  15506. Expression.Constant(scheduler, typeof(IScheduler))
  15507. )
  15508. );
  15509. }
  15510. /// <summary>
  15511. /// Returns an observable sequence that produces a single value after the specified relative due time has elapsed.
  15512. /// </summary>
  15513. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  15514. /// <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>
  15515. /// <returns>An observable sequence that produces a value after the due time has elapsed.</returns>
  15516. public static IQbservable<long> Timer(this IQbservableProvider provider, TimeSpan dueTime)
  15517. {
  15518. if (provider == null)
  15519. throw new ArgumentNullException("provider");
  15520. return provider.CreateQuery<long>(
  15521. Expression.Call(
  15522. null,
  15523. #if CRIPPLED_REFLECTION
  15524. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(TimeSpan))),
  15525. #else
  15526. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15527. #endif
  15528. Expression.Constant(provider, typeof(IQbservableProvider)),
  15529. Expression.Constant(dueTime, typeof(TimeSpan))
  15530. )
  15531. );
  15532. }
  15533. /// <summary>
  15534. /// Returns an observable sequence that periodically produces a value after the specified initial relative due time has elapsed.
  15535. /// </summary>
  15536. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  15537. /// <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>
  15538. /// <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>
  15539. /// <returns>An observable sequence that produces a value after due time has elapsed and then after each period.</returns>
  15540. /// <exception cref="T:System.ArgumentOutOfRangeException">
  15541. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  15542. public static IQbservable<long> Timer(this IQbservableProvider provider, TimeSpan dueTime, TimeSpan period)
  15543. {
  15544. if (provider == null)
  15545. throw new ArgumentNullException("provider");
  15546. return provider.CreateQuery<long>(
  15547. Expression.Call(
  15548. null,
  15549. #if CRIPPLED_REFLECTION
  15550. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(TimeSpan), default(TimeSpan))),
  15551. #else
  15552. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15553. #endif
  15554. Expression.Constant(provider, typeof(IQbservableProvider)),
  15555. Expression.Constant(dueTime, typeof(TimeSpan)),
  15556. Expression.Constant(period, typeof(TimeSpan))
  15557. )
  15558. );
  15559. }
  15560. /// <summary>
  15561. /// 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.
  15562. /// </summary>
  15563. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  15564. /// <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>
  15565. /// <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>
  15566. /// <param name="scheduler">Scheduler to run timers on.</param>
  15567. /// <returns>An observable sequence that produces a value after due time has elapsed and then each period.</returns>
  15568. /// <exception cref="T:System.ArgumentOutOfRangeException">
  15569. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  15570. /// <exception cref="T:System.ArgumentNullException">
  15571. /// <paramref name="scheduler" /> is null.</exception>
  15572. public static IQbservable<long> Timer(this IQbservableProvider provider, TimeSpan dueTime, TimeSpan period, IScheduler scheduler)
  15573. {
  15574. if (provider == null)
  15575. throw new ArgumentNullException("provider");
  15576. if (scheduler == null)
  15577. throw new ArgumentNullException("scheduler");
  15578. return provider.CreateQuery<long>(
  15579. Expression.Call(
  15580. null,
  15581. #if CRIPPLED_REFLECTION
  15582. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(TimeSpan), default(TimeSpan), default(IScheduler))),
  15583. #else
  15584. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15585. #endif
  15586. Expression.Constant(provider, typeof(IQbservableProvider)),
  15587. Expression.Constant(dueTime, typeof(TimeSpan)),
  15588. Expression.Constant(period, typeof(TimeSpan)),
  15589. Expression.Constant(scheduler, typeof(IScheduler))
  15590. )
  15591. );
  15592. }
  15593. /// <summary>
  15594. /// 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.
  15595. /// </summary>
  15596. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  15597. /// <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>
  15598. /// <param name="scheduler">Scheduler to run the timer on.</param>
  15599. /// <returns>An observable sequence that produces a value after the due time has elapsed.</returns>
  15600. /// <exception cref="T:System.ArgumentNullException">
  15601. /// <paramref name="scheduler" /> is null.</exception>
  15602. public static IQbservable<long> Timer(this IQbservableProvider provider, TimeSpan dueTime, IScheduler scheduler)
  15603. {
  15604. if (provider == null)
  15605. throw new ArgumentNullException("provider");
  15606. if (scheduler == null)
  15607. throw new ArgumentNullException("scheduler");
  15608. return provider.CreateQuery<long>(
  15609. Expression.Call(
  15610. null,
  15611. #if CRIPPLED_REFLECTION
  15612. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(TimeSpan), default(IScheduler))),
  15613. #else
  15614. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15615. #endif
  15616. Expression.Constant(provider, typeof(IQbservableProvider)),
  15617. Expression.Constant(dueTime, typeof(TimeSpan)),
  15618. Expression.Constant(scheduler, typeof(IScheduler))
  15619. )
  15620. );
  15621. }
  15622. /// <summary>
  15623. /// Timestamps each element in an observable sequence using the local system clock.
  15624. /// </summary>
  15625. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15626. /// <param name="source">Source sequence to timestamp elements for.</param>
  15627. /// <returns>An observable sequence with timestamp information on elements.</returns>
  15628. /// <exception cref="T:System.ArgumentNullException">
  15629. /// <paramref name="source" /> is null.</exception>
  15630. public static IQbservable<Timestamped<TSource>> Timestamp<TSource>(this IQbservable<TSource> source)
  15631. {
  15632. if (source == null)
  15633. throw new ArgumentNullException("source");
  15634. return source.Provider.CreateQuery<Timestamped<TSource>>(
  15635. Expression.Call(
  15636. null,
  15637. #if CRIPPLED_REFLECTION
  15638. InfoOf(() => Qbservable.Timestamp<TSource>(default(IQbservable<TSource>))),
  15639. #else
  15640. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15641. #endif
  15642. source.Expression
  15643. )
  15644. );
  15645. }
  15646. /// <summary>
  15647. /// Timestamp each element in an observable sequence using the clock of the specified scheduler.
  15648. /// </summary>
  15649. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15650. /// <param name="source">Source sequence to timestamp elements for.</param>
  15651. /// <param name="scheduler">Scheduler used to compute timestamps.</param>
  15652. /// <returns>An observable sequence with timestamp information on elements.</returns>
  15653. /// <exception cref="T:System.ArgumentNullException">
  15654. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  15655. public static IQbservable<Timestamped<TSource>> Timestamp<TSource>(this IQbservable<TSource> source, IScheduler scheduler)
  15656. {
  15657. if (source == null)
  15658. throw new ArgumentNullException("source");
  15659. if (scheduler == null)
  15660. throw new ArgumentNullException("scheduler");
  15661. return source.Provider.CreateQuery<Timestamped<TSource>>(
  15662. Expression.Call(
  15663. null,
  15664. #if CRIPPLED_REFLECTION
  15665. InfoOf(() => Qbservable.Timestamp<TSource>(default(IQbservable<TSource>), default(IScheduler))),
  15666. #else
  15667. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15668. #endif
  15669. source.Expression,
  15670. Expression.Constant(scheduler, typeof(IScheduler))
  15671. )
  15672. );
  15673. }
  15674. /// <summary>
  15675. /// Creates an array from an observable sequence.
  15676. /// </summary>
  15677. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15678. /// <param name="source">The source observable sequence to get an array of elements for.</param>
  15679. /// <returns>An observable sequence containing a single element with an array containing all the elements of the source sequence.</returns>
  15680. /// <exception cref="T:System.ArgumentNullException">
  15681. /// <paramref name="source" /> is null.</exception>
  15682. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15683. public static IQbservable<TSource[]> ToArray<TSource>(this IQbservable<TSource> source)
  15684. {
  15685. if (source == null)
  15686. throw new ArgumentNullException("source");
  15687. return source.Provider.CreateQuery<TSource[]>(
  15688. Expression.Call(
  15689. null,
  15690. #if CRIPPLED_REFLECTION
  15691. InfoOf(() => Qbservable.ToArray<TSource>(default(IQbservable<TSource>))),
  15692. #else
  15693. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15694. #endif
  15695. source.Expression
  15696. )
  15697. );
  15698. }
  15699. /// <summary>
  15700. /// Creates a dictionary from an observable sequence according to a specified key selector function.
  15701. /// </summary>
  15702. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15703. /// <typeparam name="TKey">The type of the dictionary key computed for each element in the source sequence.</typeparam>
  15704. /// <param name="source">An observable sequence to create a dictionary for.</param>
  15705. /// <param name="keySelector">A function to extract a key from each element.</param>
  15706. /// <returns>An observable sequence containing a single element with a dictionary mapping unique key values onto the corresponding source sequence's element.</returns>
  15707. /// <exception cref="T:System.ArgumentNullException">
  15708. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  15709. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15710. public static IQbservable<IDictionary<TKey, TSource>> ToDictionary<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  15711. {
  15712. if (source == null)
  15713. throw new ArgumentNullException("source");
  15714. if (keySelector == null)
  15715. throw new ArgumentNullException("keySelector");
  15716. return source.Provider.CreateQuery<IDictionary<TKey, TSource>>(
  15717. Expression.Call(
  15718. null,
  15719. #if CRIPPLED_REFLECTION
  15720. InfoOf(() => Qbservable.ToDictionary<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  15721. #else
  15722. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  15723. #endif
  15724. source.Expression,
  15725. keySelector
  15726. )
  15727. );
  15728. }
  15729. /// <summary>
  15730. /// Creates a dictionary from an observable sequence according to a specified key selector function, and a comparer.
  15731. /// </summary>
  15732. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15733. /// <typeparam name="TKey">The type of the dictionary key computed for each element in the source sequence.</typeparam>
  15734. /// <param name="source">An observable sequence to create a dictionary for.</param>
  15735. /// <param name="keySelector">A function to extract a key from each element.</param>
  15736. /// <param name="comparer">An equality comparer to compare keys.</param>
  15737. /// <returns>An observable sequence containing a single element with a dictionary mapping unique key values onto the corresponding source sequence's element.</returns>
  15738. /// <exception cref="T:System.ArgumentNullException">
  15739. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  15740. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15741. public static IQbservable<IDictionary<TKey, TSource>> ToDictionary<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  15742. {
  15743. if (source == null)
  15744. throw new ArgumentNullException("source");
  15745. if (keySelector == null)
  15746. throw new ArgumentNullException("keySelector");
  15747. if (comparer == null)
  15748. throw new ArgumentNullException("comparer");
  15749. return source.Provider.CreateQuery<IDictionary<TKey, TSource>>(
  15750. Expression.Call(
  15751. null,
  15752. #if CRIPPLED_REFLECTION
  15753. InfoOf(() => Qbservable.ToDictionary<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IEqualityComparer<TKey>))),
  15754. #else
  15755. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  15756. #endif
  15757. source.Expression,
  15758. keySelector,
  15759. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  15760. )
  15761. );
  15762. }
  15763. /// <summary>
  15764. /// Creates a dictionary from an observable sequence according to a specified key selector function, and an element selector function.
  15765. /// </summary>
  15766. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15767. /// <typeparam name="TKey">The type of the dictionary key computed for each element in the source sequence.</typeparam>
  15768. /// <typeparam name="TElement">The type of the dictionary value computed for each element in the source sequence.</typeparam>
  15769. /// <param name="source">An observable sequence to create a dictionary for.</param>
  15770. /// <param name="keySelector">A function to extract a key from each element.</param>
  15771. /// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
  15772. /// <returns>An observable sequence containing a single element with a dictionary mapping unique key values onto the corresponding source sequence's element.</returns>
  15773. /// <exception cref="T:System.ArgumentNullException">
  15774. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> is null.</exception>
  15775. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15776. public static IQbservable<IDictionary<TKey, TElement>> ToDictionary<TSource, TKey, TElement>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector)
  15777. {
  15778. if (source == null)
  15779. throw new ArgumentNullException("source");
  15780. if (keySelector == null)
  15781. throw new ArgumentNullException("keySelector");
  15782. if (elementSelector == null)
  15783. throw new ArgumentNullException("elementSelector");
  15784. return source.Provider.CreateQuery<IDictionary<TKey, TElement>>(
  15785. Expression.Call(
  15786. null,
  15787. #if CRIPPLED_REFLECTION
  15788. InfoOf(() => Qbservable.ToDictionary<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>))),
  15789. #else
  15790. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  15791. #endif
  15792. source.Expression,
  15793. keySelector,
  15794. elementSelector
  15795. )
  15796. );
  15797. }
  15798. /// <summary>
  15799. /// Creates a dictionary from an observable sequence according to a specified key selector function, a comparer, and an element selector function.
  15800. /// </summary>
  15801. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15802. /// <typeparam name="TKey">The type of the dictionary key computed for each element in the source sequence.</typeparam>
  15803. /// <typeparam name="TElement">The type of the dictionary value computed for each element in the source sequence.</typeparam>
  15804. /// <param name="source">An observable sequence to create a dictionary for.</param>
  15805. /// <param name="keySelector">A function to extract a key from each element.</param>
  15806. /// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
  15807. /// <param name="comparer">An equality comparer to compare keys.</param>
  15808. /// <returns>An observable sequence containing a single element with a dictionary mapping unique key values onto the corresponding source sequence's element.</returns>
  15809. /// <exception cref="T:System.ArgumentNullException">
  15810. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="comparer" /> is null.</exception>
  15811. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15812. 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)
  15813. {
  15814. if (source == null)
  15815. throw new ArgumentNullException("source");
  15816. if (keySelector == null)
  15817. throw new ArgumentNullException("keySelector");
  15818. if (elementSelector == null)
  15819. throw new ArgumentNullException("elementSelector");
  15820. if (comparer == null)
  15821. throw new ArgumentNullException("comparer");
  15822. return source.Provider.CreateQuery<IDictionary<TKey, TElement>>(
  15823. Expression.Call(
  15824. null,
  15825. #if CRIPPLED_REFLECTION
  15826. InfoOf(() => Qbservable.ToDictionary<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(IEqualityComparer<TKey>))),
  15827. #else
  15828. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  15829. #endif
  15830. source.Expression,
  15831. keySelector,
  15832. elementSelector,
  15833. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  15834. )
  15835. );
  15836. }
  15837. /// <summary>
  15838. /// Converts an observable sequence to an enumerable sequence.
  15839. /// </summary>
  15840. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15841. /// <param name="source">An observable sequence to convert to an enumerable sequence.</param>
  15842. /// <returns>The enumerable sequence containing the elements in the observable sequence.</returns>
  15843. /// <exception cref="T:System.ArgumentNullException">
  15844. /// <paramref name="source" /> is null.</exception>
  15845. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  15846. public static IQueryable<TSource> ToQueryable<TSource>(this IQbservable<TSource> source)
  15847. {
  15848. if (source == null)
  15849. throw new ArgumentNullException("source");
  15850. return ((IQueryProvider)source.Provider).CreateQuery<TSource>(
  15851. Expression.Call(
  15852. null,
  15853. #if CRIPPLED_REFLECTION
  15854. InfoOf(() => Qbservable.ToQueryable<TSource>(default(IQbservable<TSource>))),
  15855. #else
  15856. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15857. #endif
  15858. source.Expression
  15859. )
  15860. );
  15861. }
  15862. /// <summary>
  15863. /// Creates a list from an observable sequence.
  15864. /// </summary>
  15865. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15866. /// <param name="source">The source observable sequence to get a list of elements for.</param>
  15867. /// <returns>An observable sequence containing a single element with a list containing all the elements of the source sequence.</returns>
  15868. /// <exception cref="T:System.ArgumentNullException">
  15869. /// <paramref name="source" /> is null.</exception>
  15870. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15871. public static IQbservable<IList<TSource>> ToList<TSource>(this IQbservable<TSource> source)
  15872. {
  15873. if (source == null)
  15874. throw new ArgumentNullException("source");
  15875. return source.Provider.CreateQuery<IList<TSource>>(
  15876. Expression.Call(
  15877. null,
  15878. #if CRIPPLED_REFLECTION
  15879. InfoOf(() => Qbservable.ToList<TSource>(default(IQbservable<TSource>))),
  15880. #else
  15881. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15882. #endif
  15883. source.Expression
  15884. )
  15885. );
  15886. }
  15887. /// <summary>
  15888. /// Creates a lookup from an observable sequence according to a specified key selector function.
  15889. /// </summary>
  15890. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15891. /// <typeparam name="TKey">The type of the lookup key computed for each element in the source sequence.</typeparam>
  15892. /// <param name="source">An observable sequence to create a lookup for.</param>
  15893. /// <param name="keySelector">A function to extract a key from each element.</param>
  15894. /// <returns>An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.</returns>
  15895. /// <exception cref="T:System.ArgumentNullException">
  15896. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  15897. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15898. public static IQbservable<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  15899. {
  15900. if (source == null)
  15901. throw new ArgumentNullException("source");
  15902. if (keySelector == null)
  15903. throw new ArgumentNullException("keySelector");
  15904. return source.Provider.CreateQuery<ILookup<TKey, TSource>>(
  15905. Expression.Call(
  15906. null,
  15907. #if CRIPPLED_REFLECTION
  15908. InfoOf(() => Qbservable.ToLookup<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  15909. #else
  15910. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  15911. #endif
  15912. source.Expression,
  15913. keySelector
  15914. )
  15915. );
  15916. }
  15917. /// <summary>
  15918. /// Creates a lookup from an observable sequence according to a specified key selector function, and a comparer.
  15919. /// </summary>
  15920. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15921. /// <typeparam name="TKey">The type of the lookup key computed for each element in the source sequence.</typeparam>
  15922. /// <param name="source">An observable sequence to create a lookup for.</param>
  15923. /// <param name="keySelector">A function to extract a key from each element.</param>
  15924. /// <param name="comparer">An equality comparer to compare keys.</param>
  15925. /// <returns>An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.</returns>
  15926. /// <exception cref="T:System.ArgumentNullException">
  15927. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  15928. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15929. public static IQbservable<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  15930. {
  15931. if (source == null)
  15932. throw new ArgumentNullException("source");
  15933. if (keySelector == null)
  15934. throw new ArgumentNullException("keySelector");
  15935. if (comparer == null)
  15936. throw new ArgumentNullException("comparer");
  15937. return source.Provider.CreateQuery<ILookup<TKey, TSource>>(
  15938. Expression.Call(
  15939. null,
  15940. #if CRIPPLED_REFLECTION
  15941. InfoOf(() => Qbservable.ToLookup<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IEqualityComparer<TKey>))),
  15942. #else
  15943. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  15944. #endif
  15945. source.Expression,
  15946. keySelector,
  15947. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  15948. )
  15949. );
  15950. }
  15951. /// <summary>
  15952. /// Creates a lookup from an observable sequence according to a specified key selector function, and an element selector function.
  15953. /// </summary>
  15954. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15955. /// <typeparam name="TKey">The type of the lookup key computed for each element in the source sequence.</typeparam>
  15956. /// <typeparam name="TElement">The type of the lookup value computed for each element in the source sequence.</typeparam>
  15957. /// <param name="source">An observable sequence to create a lookup for.</param>
  15958. /// <param name="keySelector">A function to extract a key from each element.</param>
  15959. /// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
  15960. /// <returns>An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.</returns>
  15961. /// <exception cref="T:System.ArgumentNullException">
  15962. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> is null.</exception>
  15963. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15964. public static IQbservable<ILookup<TKey, TElement>> ToLookup<TSource, TKey, TElement>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector)
  15965. {
  15966. if (source == null)
  15967. throw new ArgumentNullException("source");
  15968. if (keySelector == null)
  15969. throw new ArgumentNullException("keySelector");
  15970. if (elementSelector == null)
  15971. throw new ArgumentNullException("elementSelector");
  15972. return source.Provider.CreateQuery<ILookup<TKey, TElement>>(
  15973. Expression.Call(
  15974. null,
  15975. #if CRIPPLED_REFLECTION
  15976. InfoOf(() => Qbservable.ToLookup<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>))),
  15977. #else
  15978. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  15979. #endif
  15980. source.Expression,
  15981. keySelector,
  15982. elementSelector
  15983. )
  15984. );
  15985. }
  15986. /// <summary>
  15987. /// Creates a lookup from an observable sequence according to a specified key selector function, a comparer, and an element selector function.
  15988. /// </summary>
  15989. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15990. /// <typeparam name="TKey">The type of the lookup key computed for each element in the source sequence.</typeparam>
  15991. /// <typeparam name="TElement">The type of the lookup value computed for each element in the source sequence.</typeparam>
  15992. /// <param name="source">An observable sequence to create a lookup for.</param>
  15993. /// <param name="keySelector">A function to extract a key from each element.</param>
  15994. /// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
  15995. /// <param name="comparer">An equality comparer to compare keys.</param>
  15996. /// <returns>An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.</returns>
  15997. /// <exception cref="T:System.ArgumentNullException">
  15998. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="comparer" /> is null.</exception>
  15999. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  16000. 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)
  16001. {
  16002. if (source == null)
  16003. throw new ArgumentNullException("source");
  16004. if (keySelector == null)
  16005. throw new ArgumentNullException("keySelector");
  16006. if (elementSelector == null)
  16007. throw new ArgumentNullException("elementSelector");
  16008. if (comparer == null)
  16009. throw new ArgumentNullException("comparer");
  16010. return source.Provider.CreateQuery<ILookup<TKey, TElement>>(
  16011. Expression.Call(
  16012. null,
  16013. #if CRIPPLED_REFLECTION
  16014. InfoOf(() => Qbservable.ToLookup<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(IEqualityComparer<TKey>))),
  16015. #else
  16016. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  16017. #endif
  16018. source.Expression,
  16019. keySelector,
  16020. elementSelector,
  16021. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  16022. )
  16023. );
  16024. }
  16025. /// <summary>
  16026. /// Converts an enumerable sequence to an observable sequence.
  16027. /// </summary>
  16028. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  16029. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  16030. /// <param name="source">Enumerable sequence to convert to an observable sequence.</param>
  16031. /// <returns>The observable sequence whose elements are pulled from the given enumerable sequence.</returns>
  16032. /// <exception cref="T:System.ArgumentNullException">
  16033. /// <paramref name="source" /> is null.</exception>
  16034. public static IQbservable<TSource> ToObservable<TSource>(this IQbservableProvider provider, IEnumerable<TSource> source)
  16035. {
  16036. if (provider == null)
  16037. throw new ArgumentNullException("provider");
  16038. if (source == null)
  16039. throw new ArgumentNullException("source");
  16040. return provider.CreateQuery<TSource>(
  16041. Expression.Call(
  16042. null,
  16043. #if CRIPPLED_REFLECTION
  16044. InfoOf(() => Qbservable.ToObservable<TSource>(default(IQbservableProvider), default(IEnumerable<TSource>))),
  16045. #else
  16046. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16047. #endif
  16048. Expression.Constant(provider, typeof(IQbservableProvider)),
  16049. GetSourceExpression(source)
  16050. )
  16051. );
  16052. }
  16053. /// <summary>
  16054. /// Converts an enumerable sequence to an observable sequence, using the specified scheduler to run the enumeration loop.
  16055. /// </summary>
  16056. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  16057. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  16058. /// <param name="source">Enumerable sequence to convert to an observable sequence.</param>
  16059. /// <param name="scheduler">Scheduler to run the enumeration of the input sequence on.</param>
  16060. /// <returns>The observable sequence whose elements are pulled from the given enumerable sequence.</returns>
  16061. /// <exception cref="T:System.ArgumentNullException">
  16062. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  16063. public static IQbservable<TSource> ToObservable<TSource>(this IQbservableProvider provider, IEnumerable<TSource> source, IScheduler scheduler)
  16064. {
  16065. if (provider == null)
  16066. throw new ArgumentNullException("provider");
  16067. if (source == null)
  16068. throw new ArgumentNullException("source");
  16069. if (scheduler == null)
  16070. throw new ArgumentNullException("scheduler");
  16071. return provider.CreateQuery<TSource>(
  16072. Expression.Call(
  16073. null,
  16074. #if CRIPPLED_REFLECTION
  16075. InfoOf(() => Qbservable.ToObservable<TSource>(default(IQbservableProvider), default(IEnumerable<TSource>), default(IScheduler))),
  16076. #else
  16077. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16078. #endif
  16079. Expression.Constant(provider, typeof(IQbservableProvider)),
  16080. GetSourceExpression(source),
  16081. Expression.Constant(scheduler, typeof(IScheduler))
  16082. )
  16083. );
  16084. }
  16085. /// <summary>
  16086. /// Constructs an observable sequence that depends on a resource object, whose lifetime is tied to the resulting observable sequence's lifetime.
  16087. /// </summary>
  16088. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  16089. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  16090. /// <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>
  16091. /// <param name="resourceFactory">Factory function to obtain a resource object.</param>
  16092. /// <param name="observableFactory">Factory function to obtain an observable sequence that depends on the obtained resource.</param>
  16093. /// <returns>An observable sequence whose lifetime controls the lifetime of the dependent resource object.</returns>
  16094. /// <exception cref="T:System.ArgumentNullException">
  16095. /// <paramref name="resourceFactory" /> or <paramref name="observableFactory" /> is null.</exception>
  16096. public static IQbservable<TResult> Using<TResult, TResource>(this IQbservableProvider provider, Expression<Func<TResource>> resourceFactory, Expression<Func<TResource, IObservable<TResult>>> observableFactory)
  16097. where TResource : IDisposable
  16098. {
  16099. if (provider == null)
  16100. throw new ArgumentNullException("provider");
  16101. if (resourceFactory == null)
  16102. throw new ArgumentNullException("resourceFactory");
  16103. if (observableFactory == null)
  16104. throw new ArgumentNullException("observableFactory");
  16105. return provider.CreateQuery<TResult>(
  16106. Expression.Call(
  16107. null,
  16108. #if CRIPPLED_REFLECTION
  16109. InfoOf(() => Qbservable.Using<TResult, TResource>(default(IQbservableProvider), default(Expression<Func<TResource>>), default(Expression<Func<TResource, IObservable<TResult>>>))),
  16110. #else
  16111. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult), typeof(TResource)),
  16112. #endif
  16113. Expression.Constant(provider, typeof(IQbservableProvider)),
  16114. resourceFactory,
  16115. observableFactory
  16116. )
  16117. );
  16118. }
  16119. #if !NO_TPL
  16120. /// <summary>
  16121. /// 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.
  16122. /// 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.
  16123. /// </summary>
  16124. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  16125. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  16126. /// <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>
  16127. /// <param name="resourceFactoryAsync">Asynchronous factory function to obtain a resource object.</param>
  16128. /// <param name="observableFactoryAsync">Asynchronous factory function to obtain an observable sequence that depends on the obtained resource.</param>
  16129. /// <returns>An observable sequence whose lifetime controls the lifetime of the dependent resource object.</returns>
  16130. /// <exception cref="T:System.ArgumentNullException">
  16131. /// <paramref name="resourceFactoryAsync" /> or <paramref name="observableFactoryAsync" /> is null.</exception>
  16132. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  16133. /// <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>
  16134. public static IQbservable<TResult> Using<TResult, TResource>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<TResource>>> resourceFactoryAsync, Expression<Func<TResource, CancellationToken, Task<IObservable<TResult>>>> observableFactoryAsync)
  16135. where TResource : IDisposable
  16136. {
  16137. if (provider == null)
  16138. throw new ArgumentNullException("provider");
  16139. if (resourceFactoryAsync == null)
  16140. throw new ArgumentNullException("resourceFactoryAsync");
  16141. if (observableFactoryAsync == null)
  16142. throw new ArgumentNullException("observableFactoryAsync");
  16143. return provider.CreateQuery<TResult>(
  16144. Expression.Call(
  16145. null,
  16146. #if CRIPPLED_REFLECTION
  16147. InfoOf(() => Qbservable.Using<TResult, TResource>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<TResource>>>), default(Expression<Func<TResource, CancellationToken, Task<IObservable<TResult>>>>))),
  16148. #else
  16149. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult), typeof(TResource)),
  16150. #endif
  16151. Expression.Constant(provider, typeof(IQbservableProvider)),
  16152. resourceFactoryAsync,
  16153. observableFactoryAsync
  16154. )
  16155. );
  16156. }
  16157. #endif
  16158. /// <summary>
  16159. /// Filters the elements of an observable sequence based on a predicate.
  16160. /// </summary>
  16161. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  16162. /// <param name="source">An observable sequence whose elements to filter.</param>
  16163. /// <param name="predicate">A function to test each source element for a condition.</param>
  16164. /// <returns>An observable sequence that contains elements from the input sequence that satisfy the condition.</returns>
  16165. /// <exception cref="T:System.ArgumentNullException">
  16166. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  16167. public static IQbservable<TSource> Where<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  16168. {
  16169. if (source == null)
  16170. throw new ArgumentNullException("source");
  16171. if (predicate == null)
  16172. throw new ArgumentNullException("predicate");
  16173. return source.Provider.CreateQuery<TSource>(
  16174. Expression.Call(
  16175. null,
  16176. #if CRIPPLED_REFLECTION
  16177. InfoOf(() => Qbservable.Where<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  16178. #else
  16179. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16180. #endif
  16181. source.Expression,
  16182. predicate
  16183. )
  16184. );
  16185. }
  16186. /// <summary>
  16187. /// Filters the elements of an observable sequence based on a predicate by incorporating the element's index.
  16188. /// </summary>
  16189. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  16190. /// <param name="source">An observable sequence whose elements to filter.</param>
  16191. /// <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>
  16192. /// <returns>An observable sequence that contains elements from the input sequence that satisfy the condition.</returns>
  16193. /// <exception cref="T:System.ArgumentNullException">
  16194. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  16195. public static IQbservable<TSource> Where<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int, bool>> predicate)
  16196. {
  16197. if (source == null)
  16198. throw new ArgumentNullException("source");
  16199. if (predicate == null)
  16200. throw new ArgumentNullException("predicate");
  16201. return source.Provider.CreateQuery<TSource>(
  16202. Expression.Call(
  16203. null,
  16204. #if CRIPPLED_REFLECTION
  16205. InfoOf(() => Qbservable.Where<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, bool>>))),
  16206. #else
  16207. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16208. #endif
  16209. source.Expression,
  16210. predicate
  16211. )
  16212. );
  16213. }
  16214. /// <summary>
  16215. /// 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.
  16216. /// </summary>
  16217. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  16218. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  16219. /// <param name="source">Source to repeat as long as the <paramref name="condition" /> function evaluates to true.</param>
  16220. /// <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>
  16221. /// <returns>The observable sequence obtained by concatenating the <paramref name="source" /> sequence as long as the <paramref name="condition" /> holds.</returns>
  16222. /// <exception cref="T:System.ArgumentNullException">
  16223. /// <paramref name="condition" /> or <paramref name="source" /> is null.</exception>
  16224. public static IQbservable<TSource> While<TSource>(this IQbservableProvider provider, Expression<Func<bool>> condition, IObservable<TSource> source)
  16225. {
  16226. if (provider == null)
  16227. throw new ArgumentNullException("provider");
  16228. if (condition == null)
  16229. throw new ArgumentNullException("condition");
  16230. if (source == null)
  16231. throw new ArgumentNullException("source");
  16232. return provider.CreateQuery<TSource>(
  16233. Expression.Call(
  16234. null,
  16235. #if CRIPPLED_REFLECTION
  16236. InfoOf(() => Qbservable.While<TSource>(default(IQbservableProvider), default(Expression<Func<bool>>), default(IObservable<TSource>))),
  16237. #else
  16238. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16239. #endif
  16240. Expression.Constant(provider, typeof(IQbservableProvider)),
  16241. condition,
  16242. GetSourceExpression(source)
  16243. )
  16244. );
  16245. }
  16246. /// <summary>
  16247. /// Projects each element of an observable sequence into consecutive non-overlapping windows which are produced based on element count information.
  16248. /// </summary>
  16249. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16250. /// <param name="source">Source sequence to produce windows over.</param>
  16251. /// <param name="count">Length of each window.</param>
  16252. /// <returns>An observable sequence of windows.</returns>
  16253. /// <exception cref="T:System.ArgumentNullException">
  16254. /// <paramref name="source" /> is null.</exception>
  16255. /// <exception cref="T:System.ArgumentOutOfRangeException">
  16256. /// <paramref name="count" /> is less than or equal to zero.</exception>
  16257. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, int count)
  16258. {
  16259. if (source == null)
  16260. throw new ArgumentNullException("source");
  16261. return source.Provider.CreateQuery<IObservable<TSource>>(
  16262. Expression.Call(
  16263. null,
  16264. #if CRIPPLED_REFLECTION
  16265. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(int))),
  16266. #else
  16267. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16268. #endif
  16269. source.Expression,
  16270. Expression.Constant(count, typeof(int))
  16271. )
  16272. );
  16273. }
  16274. /// <summary>
  16275. /// Projects each element of an observable sequence into zero or more windows which are produced based on element count information.
  16276. /// </summary>
  16277. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16278. /// <param name="source">Source sequence to produce windows over.</param>
  16279. /// <param name="count">Length of each window.</param>
  16280. /// <param name="skip">Number of elements to skip between creation of consecutive windows.</param>
  16281. /// <returns>An observable sequence of windows.</returns>
  16282. /// <exception cref="T:System.ArgumentNullException">
  16283. /// <paramref name="source" /> is null.</exception>
  16284. /// <exception cref="T:System.ArgumentOutOfRangeException">
  16285. /// <paramref name="count" /> or <paramref name="skip" /> is less than or equal to zero.</exception>
  16286. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, int count, int skip)
  16287. {
  16288. if (source == null)
  16289. throw new ArgumentNullException("source");
  16290. return source.Provider.CreateQuery<IObservable<TSource>>(
  16291. Expression.Call(
  16292. null,
  16293. #if CRIPPLED_REFLECTION
  16294. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(int), default(int))),
  16295. #else
  16296. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16297. #endif
  16298. source.Expression,
  16299. Expression.Constant(count, typeof(int)),
  16300. Expression.Constant(skip, typeof(int))
  16301. )
  16302. );
  16303. }
  16304. /// <summary>
  16305. /// Projects each element of an observable sequence into consecutive non-overlapping windows which are produced based on timing information.
  16306. /// </summary>
  16307. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16308. /// <param name="source">Source sequence to produce windows over.</param>
  16309. /// <param name="timeSpan">Length of each window.</param>
  16310. /// <returns>The sequence of windows.</returns>
  16311. /// <exception cref="T:System.ArgumentNullException">
  16312. /// <paramref name="source" /> is null.</exception>
  16313. /// <exception cref="T:System.ArgumentOutOfRangeException">
  16314. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  16315. /// <remarks>
  16316. /// 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.
  16317. /// 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
  16318. /// 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.
  16319. /// </remarks>
  16320. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan)
  16321. {
  16322. if (source == null)
  16323. throw new ArgumentNullException("source");
  16324. return source.Provider.CreateQuery<IObservable<TSource>>(
  16325. Expression.Call(
  16326. null,
  16327. #if CRIPPLED_REFLECTION
  16328. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  16329. #else
  16330. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16331. #endif
  16332. source.Expression,
  16333. Expression.Constant(timeSpan, typeof(TimeSpan))
  16334. )
  16335. );
  16336. }
  16337. /// <summary>
  16338. /// 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.
  16339. /// 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.
  16340. /// </summary>
  16341. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16342. /// <param name="source">Source sequence to produce windows over.</param>
  16343. /// <param name="timeSpan">Maximum time length of a window.</param>
  16344. /// <param name="count">Maximum element count of a window.</param>
  16345. /// <returns>An observable sequence of windows.</returns>
  16346. /// <exception cref="T:System.ArgumentNullException">
  16347. /// <paramref name="source" /> is null.</exception>
  16348. /// <exception cref="T:System.ArgumentOutOfRangeException">
  16349. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero. -or- <paramref name="count" /> is less than or equal to zero.</exception>
  16350. /// <remarks>
  16351. /// 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.
  16352. /// 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
  16353. /// 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.
  16354. /// </remarks>
  16355. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, int count)
  16356. {
  16357. if (source == null)
  16358. throw new ArgumentNullException("source");
  16359. return source.Provider.CreateQuery<IObservable<TSource>>(
  16360. Expression.Call(
  16361. null,
  16362. #if CRIPPLED_REFLECTION
  16363. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(int))),
  16364. #else
  16365. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16366. #endif
  16367. source.Expression,
  16368. Expression.Constant(timeSpan, typeof(TimeSpan)),
  16369. Expression.Constant(count, typeof(int))
  16370. )
  16371. );
  16372. }
  16373. /// <summary>
  16374. /// 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.
  16375. /// 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.
  16376. /// </summary>
  16377. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16378. /// <param name="source">Source sequence to produce windows over.</param>
  16379. /// <param name="timeSpan">Maximum time length of a window.</param>
  16380. /// <param name="count">Maximum element count of a window.</param>
  16381. /// <param name="scheduler">Scheduler to run windowing timers on.</param>
  16382. /// <returns>An observable sequence of windows.</returns>
  16383. /// <exception cref="T:System.ArgumentNullException">
  16384. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  16385. /// <exception cref="T:System.ArgumentOutOfRangeException">
  16386. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero. -or- <paramref name="count" /> is less than or equal to zero.</exception>
  16387. /// <remarks>
  16388. /// 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.
  16389. /// 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
  16390. /// 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.
  16391. /// </remarks>
  16392. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, int count, IScheduler scheduler)
  16393. {
  16394. if (source == null)
  16395. throw new ArgumentNullException("source");
  16396. if (scheduler == null)
  16397. throw new ArgumentNullException("scheduler");
  16398. return source.Provider.CreateQuery<IObservable<TSource>>(
  16399. Expression.Call(
  16400. null,
  16401. #if CRIPPLED_REFLECTION
  16402. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(int), default(IScheduler))),
  16403. #else
  16404. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16405. #endif
  16406. source.Expression,
  16407. Expression.Constant(timeSpan, typeof(TimeSpan)),
  16408. Expression.Constant(count, typeof(int)),
  16409. Expression.Constant(scheduler, typeof(IScheduler))
  16410. )
  16411. );
  16412. }
  16413. /// <summary>
  16414. /// 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.
  16415. /// </summary>
  16416. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16417. /// <param name="source">Source sequence to produce windows over.</param>
  16418. /// <param name="timeSpan">Length of each window.</param>
  16419. /// <param name="scheduler">Scheduler to run windowing timers on.</param>
  16420. /// <returns>An observable sequence of windows.</returns>
  16421. /// <exception cref="T:System.ArgumentNullException">
  16422. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  16423. /// <exception cref="T:System.ArgumentOutOfRangeException">
  16424. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  16425. /// <remarks>
  16426. /// 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.
  16427. /// 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
  16428. /// 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.
  16429. /// </remarks>
  16430. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, IScheduler scheduler)
  16431. {
  16432. if (source == null)
  16433. throw new ArgumentNullException("source");
  16434. if (scheduler == null)
  16435. throw new ArgumentNullException("scheduler");
  16436. return source.Provider.CreateQuery<IObservable<TSource>>(
  16437. Expression.Call(
  16438. null,
  16439. #if CRIPPLED_REFLECTION
  16440. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  16441. #else
  16442. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16443. #endif
  16444. source.Expression,
  16445. Expression.Constant(timeSpan, typeof(TimeSpan)),
  16446. Expression.Constant(scheduler, typeof(IScheduler))
  16447. )
  16448. );
  16449. }
  16450. /// <summary>
  16451. /// Projects each element of an observable sequence into zero or more windows which are produced based on timing information.
  16452. /// </summary>
  16453. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16454. /// <param name="source">Source sequence to produce windows over.</param>
  16455. /// <param name="timeSpan">Length of each window.</param>
  16456. /// <param name="timeShift">Interval between creation of consecutive windows.</param>
  16457. /// <returns>An observable sequence of windows.</returns>
  16458. /// <exception cref="T:System.ArgumentNullException">
  16459. /// <paramref name="source" /> is null.</exception>
  16460. /// <exception cref="T:System.ArgumentOutOfRangeException">
  16461. /// <paramref name="timeSpan" /> or <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  16462. /// <remarks>
  16463. /// <para>
  16464. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create windows with minimum duration
  16465. /// 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
  16466. /// current window may not execute immediately, despite the TimeSpan.Zero due time.
  16467. /// </para>
  16468. /// <para>
  16469. /// 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.
  16470. /// 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,
  16471. /// where the action to create a new window may not execute immediately, despite the TimeSpan.Zero due time.
  16472. /// </para>
  16473. /// </remarks>
  16474. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, TimeSpan timeShift)
  16475. {
  16476. if (source == null)
  16477. throw new ArgumentNullException("source");
  16478. return source.Provider.CreateQuery<IObservable<TSource>>(
  16479. Expression.Call(
  16480. null,
  16481. #if CRIPPLED_REFLECTION
  16482. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(TimeSpan))),
  16483. #else
  16484. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16485. #endif
  16486. source.Expression,
  16487. Expression.Constant(timeSpan, typeof(TimeSpan)),
  16488. Expression.Constant(timeShift, typeof(TimeSpan))
  16489. )
  16490. );
  16491. }
  16492. /// <summary>
  16493. /// 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.
  16494. /// </summary>
  16495. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16496. /// <param name="source">Source sequence to produce windows over.</param>
  16497. /// <param name="timeSpan">Length of each window.</param>
  16498. /// <param name="timeShift">Interval between creation of consecutive windows.</param>
  16499. /// <param name="scheduler">Scheduler to run windowing timers on.</param>
  16500. /// <returns>An observable sequence of windows.</returns>
  16501. /// <exception cref="T:System.ArgumentNullException">
  16502. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  16503. /// <exception cref="T:System.ArgumentOutOfRangeException">
  16504. /// <paramref name="timeSpan" /> or <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  16505. /// <remarks>
  16506. /// <para>
  16507. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create windows with minimum duration
  16508. /// 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
  16509. /// current window may not execute immediately, despite the TimeSpan.Zero due time.
  16510. /// </para>
  16511. /// <para>
  16512. /// 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.
  16513. /// 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,
  16514. /// where the action to create a new window may not execute immediately, despite the TimeSpan.Zero due time.
  16515. /// </para>
  16516. /// </remarks>
  16517. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, TimeSpan timeShift, IScheduler scheduler)
  16518. {
  16519. if (source == null)
  16520. throw new ArgumentNullException("source");
  16521. if (scheduler == null)
  16522. throw new ArgumentNullException("scheduler");
  16523. return source.Provider.CreateQuery<IObservable<TSource>>(
  16524. Expression.Call(
  16525. null,
  16526. #if CRIPPLED_REFLECTION
  16527. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(TimeSpan), default(IScheduler))),
  16528. #else
  16529. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16530. #endif
  16531. source.Expression,
  16532. Expression.Constant(timeSpan, typeof(TimeSpan)),
  16533. Expression.Constant(timeShift, typeof(TimeSpan)),
  16534. Expression.Constant(scheduler, typeof(IScheduler))
  16535. )
  16536. );
  16537. }
  16538. /// <summary>
  16539. /// Projects each element of an observable sequence into consecutive non-overlapping windows.
  16540. /// </summary>
  16541. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16542. /// <typeparam name="TWindowBoundary">The type of the elements in the sequences indicating window boundary events.</typeparam>
  16543. /// <param name="source">Source sequence to produce windows over.</param>
  16544. /// <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>
  16545. /// <returns>An observable sequence of windows.</returns>
  16546. /// <exception cref="T:System.ArgumentNullException">
  16547. /// <paramref name="source" /> or <paramref name="windowBoundaries" /> is null.</exception>
  16548. public static IQbservable<IObservable<TSource>> Window<TSource, TWindowBoundary>(this IQbservable<TSource> source, IObservable<TWindowBoundary> windowBoundaries)
  16549. {
  16550. if (source == null)
  16551. throw new ArgumentNullException("source");
  16552. if (windowBoundaries == null)
  16553. throw new ArgumentNullException("windowBoundaries");
  16554. return source.Provider.CreateQuery<IObservable<TSource>>(
  16555. Expression.Call(
  16556. null,
  16557. #if CRIPPLED_REFLECTION
  16558. InfoOf(() => Qbservable.Window<TSource, TWindowBoundary>(default(IQbservable<TSource>), default(IObservable<TWindowBoundary>))),
  16559. #else
  16560. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TWindowBoundary)),
  16561. #endif
  16562. source.Expression,
  16563. GetSourceExpression(windowBoundaries)
  16564. )
  16565. );
  16566. }
  16567. /// <summary>
  16568. /// Projects each element of an observable sequence into consecutive non-overlapping windows.
  16569. /// </summary>
  16570. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16571. /// <typeparam name="TWindowClosing">The type of the elements in the sequences indicating window closing events.</typeparam>
  16572. /// <param name="source">Source sequence to produce windows over.</param>
  16573. /// <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>
  16574. /// <returns>An observable sequence of windows.</returns>
  16575. /// <exception cref="T:System.ArgumentNullException">
  16576. /// <paramref name="source" /> or <paramref name="windowClosingSelector" /> is null.</exception>
  16577. public static IQbservable<IObservable<TSource>> Window<TSource, TWindowClosing>(this IQbservable<TSource> source, Expression<Func<IObservable<TWindowClosing>>> windowClosingSelector)
  16578. {
  16579. if (source == null)
  16580. throw new ArgumentNullException("source");
  16581. if (windowClosingSelector == null)
  16582. throw new ArgumentNullException("windowClosingSelector");
  16583. return source.Provider.CreateQuery<IObservable<TSource>>(
  16584. Expression.Call(
  16585. null,
  16586. #if CRIPPLED_REFLECTION
  16587. InfoOf(() => Qbservable.Window<TSource, TWindowClosing>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TWindowClosing>>>))),
  16588. #else
  16589. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TWindowClosing)),
  16590. #endif
  16591. source.Expression,
  16592. windowClosingSelector
  16593. )
  16594. );
  16595. }
  16596. /// <summary>
  16597. /// Projects each element of an observable sequence into zero or more windows.
  16598. /// </summary>
  16599. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16600. /// <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>
  16601. /// <typeparam name="TWindowClosing">The type of the elements in the sequences indicating window closing events.</typeparam>
  16602. /// <param name="source">Source sequence to produce windows over.</param>
  16603. /// <param name="windowOpenings">Observable sequence whose elements denote the creation of new windows.</param>
  16604. /// <param name="windowClosingSelector">A function invoked to define the closing of each produced window.</param>
  16605. /// <returns>An observable sequence of windows.</returns>
  16606. /// <exception cref="T:System.ArgumentNullException">
  16607. /// <paramref name="source" /> or <paramref name="windowOpenings" /> or <paramref name="windowClosingSelector" /> is null.</exception>
  16608. public static IQbservable<IObservable<TSource>> Window<TSource, TWindowOpening, TWindowClosing>(this IQbservable<TSource> source, IObservable<TWindowOpening> windowOpenings, Expression<Func<TWindowOpening, IObservable<TWindowClosing>>> windowClosingSelector)
  16609. {
  16610. if (source == null)
  16611. throw new ArgumentNullException("source");
  16612. if (windowOpenings == null)
  16613. throw new ArgumentNullException("windowOpenings");
  16614. if (windowClosingSelector == null)
  16615. throw new ArgumentNullException("windowClosingSelector");
  16616. return source.Provider.CreateQuery<IObservable<TSource>>(
  16617. Expression.Call(
  16618. null,
  16619. #if CRIPPLED_REFLECTION
  16620. InfoOf(() => Qbservable.Window<TSource, TWindowOpening, TWindowClosing>(default(IQbservable<TSource>), default(IObservable<TWindowOpening>), default(Expression<Func<TWindowOpening, IObservable<TWindowClosing>>>))),
  16621. #else
  16622. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TWindowOpening), typeof(TWindowClosing)),
  16623. #endif
  16624. source.Expression,
  16625. GetSourceExpression(windowOpenings),
  16626. windowClosingSelector
  16627. )
  16628. );
  16629. }
  16630. /// <summary>
  16631. /// Merges the specified observable sequences into one observable sequence by emitting a list with the elements of the observable sequences at corresponding indexes.
  16632. /// </summary>
  16633. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  16634. /// <typeparam name="TSource">The type of the elements in the source sequences, and in the lists in the result sequence.</typeparam>
  16635. /// <param name="sources">Observable sources.</param>
  16636. /// <returns>An observable sequence containing lists of elements at corresponding indexes.</returns>
  16637. /// <exception cref="T:System.ArgumentNullException">
  16638. /// <paramref name="sources" /> is null.</exception>
  16639. public static IQbservable<IList<TSource>> Zip<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  16640. {
  16641. if (provider == null)
  16642. throw new ArgumentNullException("provider");
  16643. if (sources == null)
  16644. throw new ArgumentNullException("sources");
  16645. return provider.CreateQuery<IList<TSource>>(
  16646. Expression.Call(
  16647. null,
  16648. #if CRIPPLED_REFLECTION
  16649. InfoOf(() => Qbservable.Zip<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  16650. #else
  16651. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16652. #endif
  16653. Expression.Constant(provider, typeof(IQbservableProvider)),
  16654. GetSourceExpression(sources)
  16655. )
  16656. );
  16657. }
  16658. /// <summary>
  16659. /// Merges the specified observable sequences into one observable sequence by emitting a list with the elements of the observable sequences at corresponding indexes.
  16660. /// </summary>
  16661. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  16662. /// <typeparam name="TSource">The type of the elements in the source sequences, and in the lists in the result sequence.</typeparam>
  16663. /// <param name="sources">Observable sources.</param>
  16664. /// <returns>An observable sequence containing lists of elements at corresponding indexes.</returns>
  16665. /// <exception cref="T:System.ArgumentNullException">
  16666. /// <paramref name="sources" /> is null.</exception>
  16667. public static IQbservable<IList<TSource>> Zip<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  16668. {
  16669. if (provider == null)
  16670. throw new ArgumentNullException("provider");
  16671. if (sources == null)
  16672. throw new ArgumentNullException("sources");
  16673. return provider.CreateQuery<IList<TSource>>(
  16674. Expression.Call(
  16675. null,
  16676. #if CRIPPLED_REFLECTION
  16677. InfoOf(() => Qbservable.Zip<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  16678. #else
  16679. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16680. #endif
  16681. Expression.Constant(provider, typeof(IQbservableProvider)),
  16682. GetSourceExpression(sources)
  16683. )
  16684. );
  16685. }
  16686. /// <summary>
  16687. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
  16688. /// </summary>
  16689. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  16690. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  16691. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16692. /// <param name="sources">Observable sources.</param>
  16693. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16694. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16695. /// <exception cref="T:System.ArgumentNullException">
  16696. /// <paramref name="sources" /> or <paramref name="resultSelector" /> is null.</exception>
  16697. public static IQbservable<TResult> Zip<TSource, TResult>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, Expression<Func<IList<TSource>, TResult>> resultSelector)
  16698. {
  16699. if (provider == null)
  16700. throw new ArgumentNullException("provider");
  16701. if (sources == null)
  16702. throw new ArgumentNullException("sources");
  16703. if (resultSelector == null)
  16704. throw new ArgumentNullException("resultSelector");
  16705. return provider.CreateQuery<TResult>(
  16706. Expression.Call(
  16707. null,
  16708. #if CRIPPLED_REFLECTION
  16709. InfoOf(() => Qbservable.Zip<TSource, TResult>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(Expression<Func<IList<TSource>, TResult>>))),
  16710. #else
  16711. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  16712. #endif
  16713. Expression.Constant(provider, typeof(IQbservableProvider)),
  16714. GetSourceExpression(sources),
  16715. resultSelector
  16716. )
  16717. );
  16718. }
  16719. /// <summary>
  16720. /// Merges an observable sequence and an enumerable sequence into one observable sequence by using the selector function.
  16721. /// </summary>
  16722. /// <typeparam name="TSource1">The type of the elements in the first observable source sequence.</typeparam>
  16723. /// <typeparam name="TSource2">The type of the elements in the second enumerable source sequence.</typeparam>
  16724. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16725. /// <param name="first">First observable source.</param>
  16726. /// <param name="second">Second enumerable source.</param>
  16727. /// <param name="resultSelector">Function to invoke for each consecutive pair of elements from the first and second source.</param>
  16728. /// <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>
  16729. /// <exception cref="T:System.ArgumentNullException">
  16730. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="resultSelector" /> is null.</exception>
  16731. public static IQbservable<TResult> Zip<TSource1, TSource2, TResult>(this IQbservable<TSource1> first, IEnumerable<TSource2> second, Expression<Func<TSource1, TSource2, TResult>> resultSelector)
  16732. {
  16733. if (first == null)
  16734. throw new ArgumentNullException("first");
  16735. if (second == null)
  16736. throw new ArgumentNullException("second");
  16737. if (resultSelector == null)
  16738. throw new ArgumentNullException("resultSelector");
  16739. return first.Provider.CreateQuery<TResult>(
  16740. Expression.Call(
  16741. null,
  16742. #if CRIPPLED_REFLECTION
  16743. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TResult>(default(IQbservable<TSource1>), default(IEnumerable<TSource2>), default(Expression<Func<TSource1, TSource2, TResult>>))),
  16744. #else
  16745. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TResult)),
  16746. #endif
  16747. first.Expression,
  16748. GetSourceExpression(second),
  16749. resultSelector
  16750. )
  16751. );
  16752. }
  16753. /// <summary>
  16754. /// Merges two observable sequences into one observable sequence by combining their elements in a pairwise fashion.
  16755. /// </summary>
  16756. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16757. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16758. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16759. /// <param name="first">First observable source.</param>
  16760. /// <param name="second">Second observable source.</param>
  16761. /// <param name="resultSelector">Function to invoke for each consecutive pair of elements from the first and second source.</param>
  16762. /// <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>
  16763. /// <exception cref="T:System.ArgumentNullException">
  16764. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="resultSelector" /> is null.</exception>
  16765. public static IQbservable<TResult> Zip<TSource1, TSource2, TResult>(this IQbservable<TSource1> first, IObservable<TSource2> second, Expression<Func<TSource1, TSource2, TResult>> resultSelector)
  16766. {
  16767. if (first == null)
  16768. throw new ArgumentNullException("first");
  16769. if (second == null)
  16770. throw new ArgumentNullException("second");
  16771. if (resultSelector == null)
  16772. throw new ArgumentNullException("resultSelector");
  16773. return first.Provider.CreateQuery<TResult>(
  16774. Expression.Call(
  16775. null,
  16776. #if CRIPPLED_REFLECTION
  16777. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(Expression<Func<TSource1, TSource2, TResult>>))),
  16778. #else
  16779. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TResult)),
  16780. #endif
  16781. first.Expression,
  16782. GetSourceExpression(second),
  16783. resultSelector
  16784. )
  16785. );
  16786. }
  16787. /// <summary>
  16788. /// 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.
  16789. /// </summary>
  16790. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16791. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16792. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16793. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16794. /// <param name="source1">First observable source.</param>
  16795. /// <param name="source2">Second observable source.</param>
  16796. /// <param name="source3">Third observable source.</param>
  16797. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16798. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16799. /// <exception cref="T:System.ArgumentNullException">
  16800. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="resultSelector" /> is null.</exception>
  16801. 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)
  16802. {
  16803. if (source1 == null)
  16804. throw new ArgumentNullException("source1");
  16805. if (source2 == null)
  16806. throw new ArgumentNullException("source2");
  16807. if (source3 == null)
  16808. throw new ArgumentNullException("source3");
  16809. if (resultSelector == null)
  16810. throw new ArgumentNullException("resultSelector");
  16811. return source1.Provider.CreateQuery<TResult>(
  16812. Expression.Call(
  16813. null,
  16814. #if CRIPPLED_REFLECTION
  16815. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TSource3, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(Expression<Func<TSource1, TSource2, TSource3, TResult>>))),
  16816. #else
  16817. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TResult)),
  16818. #endif
  16819. source1.Expression,
  16820. GetSourceExpression(source2),
  16821. GetSourceExpression(source3),
  16822. resultSelector
  16823. )
  16824. );
  16825. }
  16826. /// <summary>
  16827. /// 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.
  16828. /// </summary>
  16829. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16830. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16831. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16832. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16833. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16834. /// <param name="source1">First observable source.</param>
  16835. /// <param name="source2">Second observable source.</param>
  16836. /// <param name="source3">Third observable source.</param>
  16837. /// <param name="source4">Fourth observable source.</param>
  16838. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16839. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16840. /// <exception cref="T:System.ArgumentNullException">
  16841. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="resultSelector" /> is null.</exception>
  16842. 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)
  16843. {
  16844. if (source1 == null)
  16845. throw new ArgumentNullException("source1");
  16846. if (source2 == null)
  16847. throw new ArgumentNullException("source2");
  16848. if (source3 == null)
  16849. throw new ArgumentNullException("source3");
  16850. if (source4 == null)
  16851. throw new ArgumentNullException("source4");
  16852. if (resultSelector == null)
  16853. throw new ArgumentNullException("resultSelector");
  16854. return source1.Provider.CreateQuery<TResult>(
  16855. Expression.Call(
  16856. null,
  16857. #if CRIPPLED_REFLECTION
  16858. 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>>))),
  16859. #else
  16860. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TResult)),
  16861. #endif
  16862. source1.Expression,
  16863. GetSourceExpression(source2),
  16864. GetSourceExpression(source3),
  16865. GetSourceExpression(source4),
  16866. resultSelector
  16867. )
  16868. );
  16869. }
  16870. #if !NO_LARGEARITY
  16871. /// <summary>
  16872. /// 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.
  16873. /// </summary>
  16874. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16875. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16876. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16877. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16878. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16879. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16880. /// <param name="source1">First observable source.</param>
  16881. /// <param name="source2">Second observable source.</param>
  16882. /// <param name="source3">Third observable source.</param>
  16883. /// <param name="source4">Fourth observable source.</param>
  16884. /// <param name="source5">Fifth observable source.</param>
  16885. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16886. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16887. /// <exception cref="T:System.ArgumentNullException">
  16888. /// <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>
  16889. 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)
  16890. {
  16891. if (source1 == null)
  16892. throw new ArgumentNullException("source1");
  16893. if (source2 == null)
  16894. throw new ArgumentNullException("source2");
  16895. if (source3 == null)
  16896. throw new ArgumentNullException("source3");
  16897. if (source4 == null)
  16898. throw new ArgumentNullException("source4");
  16899. if (source5 == null)
  16900. throw new ArgumentNullException("source5");
  16901. if (resultSelector == null)
  16902. throw new ArgumentNullException("resultSelector");
  16903. return source1.Provider.CreateQuery<TResult>(
  16904. Expression.Call(
  16905. null,
  16906. #if CRIPPLED_REFLECTION
  16907. 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>>))),
  16908. #else
  16909. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TResult)),
  16910. #endif
  16911. source1.Expression,
  16912. GetSourceExpression(source2),
  16913. GetSourceExpression(source3),
  16914. GetSourceExpression(source4),
  16915. GetSourceExpression(source5),
  16916. resultSelector
  16917. )
  16918. );
  16919. }
  16920. #endif
  16921. #if !NO_LARGEARITY
  16922. /// <summary>
  16923. /// 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.
  16924. /// </summary>
  16925. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16926. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16927. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16928. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16929. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16930. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16931. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16932. /// <param name="source1">First observable source.</param>
  16933. /// <param name="source2">Second observable source.</param>
  16934. /// <param name="source3">Third observable source.</param>
  16935. /// <param name="source4">Fourth observable source.</param>
  16936. /// <param name="source5">Fifth observable source.</param>
  16937. /// <param name="source6">Sixth observable source.</param>
  16938. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16939. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16940. /// <exception cref="T:System.ArgumentNullException">
  16941. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="source6" /> or <paramref name="resultSelector" /> is null.</exception>
  16942. 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)
  16943. {
  16944. if (source1 == null)
  16945. throw new ArgumentNullException("source1");
  16946. if (source2 == null)
  16947. throw new ArgumentNullException("source2");
  16948. if (source3 == null)
  16949. throw new ArgumentNullException("source3");
  16950. if (source4 == null)
  16951. throw new ArgumentNullException("source4");
  16952. if (source5 == null)
  16953. throw new ArgumentNullException("source5");
  16954. if (source6 == null)
  16955. throw new ArgumentNullException("source6");
  16956. if (resultSelector == null)
  16957. throw new ArgumentNullException("resultSelector");
  16958. return source1.Provider.CreateQuery<TResult>(
  16959. Expression.Call(
  16960. null,
  16961. #if CRIPPLED_REFLECTION
  16962. 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>>))),
  16963. #else
  16964. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TResult)),
  16965. #endif
  16966. source1.Expression,
  16967. GetSourceExpression(source2),
  16968. GetSourceExpression(source3),
  16969. GetSourceExpression(source4),
  16970. GetSourceExpression(source5),
  16971. GetSourceExpression(source6),
  16972. resultSelector
  16973. )
  16974. );
  16975. }
  16976. #endif
  16977. #if !NO_LARGEARITY
  16978. /// <summary>
  16979. /// 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.
  16980. /// </summary>
  16981. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16982. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16983. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16984. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16985. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16986. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16987. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16988. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16989. /// <param name="source1">First observable source.</param>
  16990. /// <param name="source2">Second observable source.</param>
  16991. /// <param name="source3">Third observable source.</param>
  16992. /// <param name="source4">Fourth observable source.</param>
  16993. /// <param name="source5">Fifth observable source.</param>
  16994. /// <param name="source6">Sixth observable source.</param>
  16995. /// <param name="source7">Seventh observable source.</param>
  16996. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16997. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16998. /// <exception cref="T:System.ArgumentNullException">
  16999. /// <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>
  17000. 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)
  17001. {
  17002. if (source1 == null)
  17003. throw new ArgumentNullException("source1");
  17004. if (source2 == null)
  17005. throw new ArgumentNullException("source2");
  17006. if (source3 == null)
  17007. throw new ArgumentNullException("source3");
  17008. if (source4 == null)
  17009. throw new ArgumentNullException("source4");
  17010. if (source5 == null)
  17011. throw new ArgumentNullException("source5");
  17012. if (source6 == null)
  17013. throw new ArgumentNullException("source6");
  17014. if (source7 == null)
  17015. throw new ArgumentNullException("source7");
  17016. if (resultSelector == null)
  17017. throw new ArgumentNullException("resultSelector");
  17018. return source1.Provider.CreateQuery<TResult>(
  17019. Expression.Call(
  17020. null,
  17021. #if CRIPPLED_REFLECTION
  17022. 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>>))),
  17023. #else
  17024. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TResult)),
  17025. #endif
  17026. source1.Expression,
  17027. GetSourceExpression(source2),
  17028. GetSourceExpression(source3),
  17029. GetSourceExpression(source4),
  17030. GetSourceExpression(source5),
  17031. GetSourceExpression(source6),
  17032. GetSourceExpression(source7),
  17033. resultSelector
  17034. )
  17035. );
  17036. }
  17037. #endif
  17038. #if !NO_LARGEARITY
  17039. /// <summary>
  17040. /// 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.
  17041. /// </summary>
  17042. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  17043. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  17044. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  17045. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  17046. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  17047. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  17048. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  17049. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  17050. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  17051. /// <param name="source1">First observable source.</param>
  17052. /// <param name="source2">Second observable source.</param>
  17053. /// <param name="source3">Third observable source.</param>
  17054. /// <param name="source4">Fourth observable source.</param>
  17055. /// <param name="source5">Fifth observable source.</param>
  17056. /// <param name="source6">Sixth observable source.</param>
  17057. /// <param name="source7">Seventh observable source.</param>
  17058. /// <param name="source8">Eighth observable source.</param>
  17059. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  17060. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  17061. /// <exception cref="T:System.ArgumentNullException">
  17062. /// <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>
  17063. 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)
  17064. {
  17065. if (source1 == null)
  17066. throw new ArgumentNullException("source1");
  17067. if (source2 == null)
  17068. throw new ArgumentNullException("source2");
  17069. if (source3 == null)
  17070. throw new ArgumentNullException("source3");
  17071. if (source4 == null)
  17072. throw new ArgumentNullException("source4");
  17073. if (source5 == null)
  17074. throw new ArgumentNullException("source5");
  17075. if (source6 == null)
  17076. throw new ArgumentNullException("source6");
  17077. if (source7 == null)
  17078. throw new ArgumentNullException("source7");
  17079. if (source8 == null)
  17080. throw new ArgumentNullException("source8");
  17081. if (resultSelector == null)
  17082. throw new ArgumentNullException("resultSelector");
  17083. return source1.Provider.CreateQuery<TResult>(
  17084. Expression.Call(
  17085. null,
  17086. #if CRIPPLED_REFLECTION
  17087. 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>>))),
  17088. #else
  17089. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TResult)),
  17090. #endif
  17091. source1.Expression,
  17092. GetSourceExpression(source2),
  17093. GetSourceExpression(source3),
  17094. GetSourceExpression(source4),
  17095. GetSourceExpression(source5),
  17096. GetSourceExpression(source6),
  17097. GetSourceExpression(source7),
  17098. GetSourceExpression(source8),
  17099. resultSelector
  17100. )
  17101. );
  17102. }
  17103. #endif
  17104. #if !NO_LARGEARITY
  17105. /// <summary>
  17106. /// 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.
  17107. /// </summary>
  17108. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  17109. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  17110. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  17111. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  17112. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  17113. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  17114. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  17115. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  17116. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  17117. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  17118. /// <param name="source1">First observable source.</param>
  17119. /// <param name="source2">Second observable source.</param>
  17120. /// <param name="source3">Third observable source.</param>
  17121. /// <param name="source4">Fourth observable source.</param>
  17122. /// <param name="source5">Fifth observable source.</param>
  17123. /// <param name="source6">Sixth observable source.</param>
  17124. /// <param name="source7">Seventh observable source.</param>
  17125. /// <param name="source8">Eighth observable source.</param>
  17126. /// <param name="source9">Ninth observable source.</param>
  17127. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  17128. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  17129. /// <exception cref="T:System.ArgumentNullException">
  17130. /// <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>
  17131. 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)
  17132. {
  17133. if (source1 == null)
  17134. throw new ArgumentNullException("source1");
  17135. if (source2 == null)
  17136. throw new ArgumentNullException("source2");
  17137. if (source3 == null)
  17138. throw new ArgumentNullException("source3");
  17139. if (source4 == null)
  17140. throw new ArgumentNullException("source4");
  17141. if (source5 == null)
  17142. throw new ArgumentNullException("source5");
  17143. if (source6 == null)
  17144. throw new ArgumentNullException("source6");
  17145. if (source7 == null)
  17146. throw new ArgumentNullException("source7");
  17147. if (source8 == null)
  17148. throw new ArgumentNullException("source8");
  17149. if (source9 == null)
  17150. throw new ArgumentNullException("source9");
  17151. if (resultSelector == null)
  17152. throw new ArgumentNullException("resultSelector");
  17153. return source1.Provider.CreateQuery<TResult>(
  17154. Expression.Call(
  17155. null,
  17156. #if CRIPPLED_REFLECTION
  17157. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, 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>>))),
  17158. #else
  17159. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TSource9), typeof(TResult)),
  17160. #endif
  17161. source1.Expression,
  17162. GetSourceExpression(source2),
  17163. GetSourceExpression(source3),
  17164. GetSourceExpression(source4),
  17165. GetSourceExpression(source5),
  17166. GetSourceExpression(source6),
  17167. GetSourceExpression(source7),
  17168. GetSourceExpression(source8),
  17169. GetSourceExpression(source9),
  17170. resultSelector
  17171. )
  17172. );
  17173. }
  17174. #endif
  17175. #if !NO_LARGEARITY
  17176. /// <summary>
  17177. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
  17178. /// </summary>
  17179. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  17180. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  17181. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  17182. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  17183. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  17184. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  17185. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  17186. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  17187. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  17188. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  17189. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  17190. /// <param name="source1">First observable source.</param>
  17191. /// <param name="source2">Second observable source.</param>
  17192. /// <param name="source3">Third observable source.</param>
  17193. /// <param name="source4">Fourth observable source.</param>
  17194. /// <param name="source5">Fifth observable source.</param>
  17195. /// <param name="source6">Sixth observable source.</param>
  17196. /// <param name="source7">Seventh observable source.</param>
  17197. /// <param name="source8">Eighth observable source.</param>
  17198. /// <param name="source9">Ninth observable source.</param>
  17199. /// <param name="source10">Tenth observable source.</param>
  17200. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  17201. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  17202. /// <exception cref="T:System.ArgumentNullException">
  17203. /// <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>
  17204. 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)
  17205. {
  17206. if (source1 == null)
  17207. throw new ArgumentNullException("source1");
  17208. if (source2 == null)
  17209. throw new ArgumentNullException("source2");
  17210. if (source3 == null)
  17211. throw new ArgumentNullException("source3");
  17212. if (source4 == null)
  17213. throw new ArgumentNullException("source4");
  17214. if (source5 == null)
  17215. throw new ArgumentNullException("source5");
  17216. if (source6 == null)
  17217. throw new ArgumentNullException("source6");
  17218. if (source7 == null)
  17219. throw new ArgumentNullException("source7");
  17220. if (source8 == null)
  17221. throw new ArgumentNullException("source8");
  17222. if (source9 == null)
  17223. throw new ArgumentNullException("source9");
  17224. if (source10 == null)
  17225. throw new ArgumentNullException("source10");
  17226. if (resultSelector == null)
  17227. throw new ArgumentNullException("resultSelector");
  17228. return source1.Provider.CreateQuery<TResult>(
  17229. Expression.Call(
  17230. null,
  17231. #if CRIPPLED_REFLECTION
  17232. 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>>))),
  17233. #else
  17234. ((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)),
  17235. #endif
  17236. source1.Expression,
  17237. GetSourceExpression(source2),
  17238. GetSourceExpression(source3),
  17239. GetSourceExpression(source4),
  17240. GetSourceExpression(source5),
  17241. GetSourceExpression(source6),
  17242. GetSourceExpression(source7),
  17243. GetSourceExpression(source8),
  17244. GetSourceExpression(source9),
  17245. GetSourceExpression(source10),
  17246. resultSelector
  17247. )
  17248. );
  17249. }
  17250. #endif
  17251. #if !NO_LARGEARITY
  17252. /// <summary>
  17253. /// 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.
  17254. /// </summary>
  17255. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  17256. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  17257. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  17258. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  17259. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  17260. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  17261. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  17262. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  17263. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  17264. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  17265. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  17266. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  17267. /// <param name="source1">First observable source.</param>
  17268. /// <param name="source2">Second observable source.</param>
  17269. /// <param name="source3">Third observable source.</param>
  17270. /// <param name="source4">Fourth observable source.</param>
  17271. /// <param name="source5">Fifth observable source.</param>
  17272. /// <param name="source6">Sixth observable source.</param>
  17273. /// <param name="source7">Seventh observable source.</param>
  17274. /// <param name="source8">Eighth observable source.</param>
  17275. /// <param name="source9">Ninth observable source.</param>
  17276. /// <param name="source10">Tenth observable source.</param>
  17277. /// <param name="source11">Eleventh observable source.</param>
  17278. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  17279. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  17280. /// <exception cref="T:System.ArgumentNullException">
  17281. /// <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>
  17282. 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)
  17283. {
  17284. if (source1 == null)
  17285. throw new ArgumentNullException("source1");
  17286. if (source2 == null)
  17287. throw new ArgumentNullException("source2");
  17288. if (source3 == null)
  17289. throw new ArgumentNullException("source3");
  17290. if (source4 == null)
  17291. throw new ArgumentNullException("source4");
  17292. if (source5 == null)
  17293. throw new ArgumentNullException("source5");
  17294. if (source6 == null)
  17295. throw new ArgumentNullException("source6");
  17296. if (source7 == null)
  17297. throw new ArgumentNullException("source7");
  17298. if (source8 == null)
  17299. throw new ArgumentNullException("source8");
  17300. if (source9 == null)
  17301. throw new ArgumentNullException("source9");
  17302. if (source10 == null)
  17303. throw new ArgumentNullException("source10");
  17304. if (source11 == null)
  17305. throw new ArgumentNullException("source11");
  17306. if (resultSelector == null)
  17307. throw new ArgumentNullException("resultSelector");
  17308. return source1.Provider.CreateQuery<TResult>(
  17309. Expression.Call(
  17310. null,
  17311. #if CRIPPLED_REFLECTION
  17312. 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>>))),
  17313. #else
  17314. ((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)),
  17315. #endif
  17316. source1.Expression,
  17317. GetSourceExpression(source2),
  17318. GetSourceExpression(source3),
  17319. GetSourceExpression(source4),
  17320. GetSourceExpression(source5),
  17321. GetSourceExpression(source6),
  17322. GetSourceExpression(source7),
  17323. GetSourceExpression(source8),
  17324. GetSourceExpression(source9),
  17325. GetSourceExpression(source10),
  17326. GetSourceExpression(source11),
  17327. resultSelector
  17328. )
  17329. );
  17330. }
  17331. #endif
  17332. #if !NO_LARGEARITY
  17333. /// <summary>
  17334. /// 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.
  17335. /// </summary>
  17336. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  17337. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  17338. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  17339. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  17340. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  17341. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  17342. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  17343. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  17344. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  17345. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  17346. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  17347. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  17348. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  17349. /// <param name="source1">First observable source.</param>
  17350. /// <param name="source2">Second observable source.</param>
  17351. /// <param name="source3">Third observable source.</param>
  17352. /// <param name="source4">Fourth observable source.</param>
  17353. /// <param name="source5">Fifth observable source.</param>
  17354. /// <param name="source6">Sixth observable source.</param>
  17355. /// <param name="source7">Seventh observable source.</param>
  17356. /// <param name="source8">Eighth observable source.</param>
  17357. /// <param name="source9">Ninth observable source.</param>
  17358. /// <param name="source10">Tenth observable source.</param>
  17359. /// <param name="source11">Eleventh observable source.</param>
  17360. /// <param name="source12">Twelfth observable source.</param>
  17361. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  17362. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  17363. /// <exception cref="T:System.ArgumentNullException">
  17364. /// <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>
  17365. 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)
  17366. {
  17367. if (source1 == null)
  17368. throw new ArgumentNullException("source1");
  17369. if (source2 == null)
  17370. throw new ArgumentNullException("source2");
  17371. if (source3 == null)
  17372. throw new ArgumentNullException("source3");
  17373. if (source4 == null)
  17374. throw new ArgumentNullException("source4");
  17375. if (source5 == null)
  17376. throw new ArgumentNullException("source5");
  17377. if (source6 == null)
  17378. throw new ArgumentNullException("source6");
  17379. if (source7 == null)
  17380. throw new ArgumentNullException("source7");
  17381. if (source8 == null)
  17382. throw new ArgumentNullException("source8");
  17383. if (source9 == null)
  17384. throw new ArgumentNullException("source9");
  17385. if (source10 == null)
  17386. throw new ArgumentNullException("source10");
  17387. if (source11 == null)
  17388. throw new ArgumentNullException("source11");
  17389. if (source12 == null)
  17390. throw new ArgumentNullException("source12");
  17391. if (resultSelector == null)
  17392. throw new ArgumentNullException("resultSelector");
  17393. return source1.Provider.CreateQuery<TResult>(
  17394. Expression.Call(
  17395. null,
  17396. #if CRIPPLED_REFLECTION
  17397. 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>>))),
  17398. #else
  17399. ((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)),
  17400. #endif
  17401. source1.Expression,
  17402. GetSourceExpression(source2),
  17403. GetSourceExpression(source3),
  17404. GetSourceExpression(source4),
  17405. GetSourceExpression(source5),
  17406. GetSourceExpression(source6),
  17407. GetSourceExpression(source7),
  17408. GetSourceExpression(source8),
  17409. GetSourceExpression(source9),
  17410. GetSourceExpression(source10),
  17411. GetSourceExpression(source11),
  17412. GetSourceExpression(source12),
  17413. resultSelector
  17414. )
  17415. );
  17416. }
  17417. #endif
  17418. #if !NO_LARGEARITY
  17419. /// <summary>
  17420. /// 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.
  17421. /// </summary>
  17422. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  17423. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  17424. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  17425. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  17426. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  17427. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  17428. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  17429. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  17430. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  17431. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  17432. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  17433. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  17434. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  17435. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  17436. /// <param name="source1">First observable source.</param>
  17437. /// <param name="source2">Second observable source.</param>
  17438. /// <param name="source3">Third observable source.</param>
  17439. /// <param name="source4">Fourth observable source.</param>
  17440. /// <param name="source5">Fifth observable source.</param>
  17441. /// <param name="source6">Sixth observable source.</param>
  17442. /// <param name="source7">Seventh observable source.</param>
  17443. /// <param name="source8">Eighth observable source.</param>
  17444. /// <param name="source9">Ninth observable source.</param>
  17445. /// <param name="source10">Tenth observable source.</param>
  17446. /// <param name="source11">Eleventh observable source.</param>
  17447. /// <param name="source12">Twelfth observable source.</param>
  17448. /// <param name="source13">Thirteenth observable source.</param>
  17449. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  17450. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  17451. /// <exception cref="T:System.ArgumentNullException">
  17452. /// <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>
  17453. 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)
  17454. {
  17455. if (source1 == null)
  17456. throw new ArgumentNullException("source1");
  17457. if (source2 == null)
  17458. throw new ArgumentNullException("source2");
  17459. if (source3 == null)
  17460. throw new ArgumentNullException("source3");
  17461. if (source4 == null)
  17462. throw new ArgumentNullException("source4");
  17463. if (source5 == null)
  17464. throw new ArgumentNullException("source5");
  17465. if (source6 == null)
  17466. throw new ArgumentNullException("source6");
  17467. if (source7 == null)
  17468. throw new ArgumentNullException("source7");
  17469. if (source8 == null)
  17470. throw new ArgumentNullException("source8");
  17471. if (source9 == null)
  17472. throw new ArgumentNullException("source9");
  17473. if (source10 == null)
  17474. throw new ArgumentNullException("source10");
  17475. if (source11 == null)
  17476. throw new ArgumentNullException("source11");
  17477. if (source12 == null)
  17478. throw new ArgumentNullException("source12");
  17479. if (source13 == null)
  17480. throw new ArgumentNullException("source13");
  17481. if (resultSelector == null)
  17482. throw new ArgumentNullException("resultSelector");
  17483. return source1.Provider.CreateQuery<TResult>(
  17484. Expression.Call(
  17485. null,
  17486. #if CRIPPLED_REFLECTION
  17487. 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>>))),
  17488. #else
  17489. ((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)),
  17490. #endif
  17491. source1.Expression,
  17492. GetSourceExpression(source2),
  17493. GetSourceExpression(source3),
  17494. GetSourceExpression(source4),
  17495. GetSourceExpression(source5),
  17496. GetSourceExpression(source6),
  17497. GetSourceExpression(source7),
  17498. GetSourceExpression(source8),
  17499. GetSourceExpression(source9),
  17500. GetSourceExpression(source10),
  17501. GetSourceExpression(source11),
  17502. GetSourceExpression(source12),
  17503. GetSourceExpression(source13),
  17504. resultSelector
  17505. )
  17506. );
  17507. }
  17508. #endif
  17509. #if !NO_LARGEARITY
  17510. /// <summary>
  17511. /// 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.
  17512. /// </summary>
  17513. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  17514. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  17515. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  17516. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  17517. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  17518. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  17519. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  17520. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  17521. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  17522. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  17523. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  17524. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  17525. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  17526. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  17527. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  17528. /// <param name="source1">First observable source.</param>
  17529. /// <param name="source2">Second observable source.</param>
  17530. /// <param name="source3">Third observable source.</param>
  17531. /// <param name="source4">Fourth observable source.</param>
  17532. /// <param name="source5">Fifth observable source.</param>
  17533. /// <param name="source6">Sixth observable source.</param>
  17534. /// <param name="source7">Seventh observable source.</param>
  17535. /// <param name="source8">Eighth observable source.</param>
  17536. /// <param name="source9">Ninth observable source.</param>
  17537. /// <param name="source10">Tenth observable source.</param>
  17538. /// <param name="source11">Eleventh observable source.</param>
  17539. /// <param name="source12">Twelfth observable source.</param>
  17540. /// <param name="source13">Thirteenth observable source.</param>
  17541. /// <param name="source14">Fourteenth observable source.</param>
  17542. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  17543. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  17544. /// <exception cref="T:System.ArgumentNullException">
  17545. /// <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>
  17546. 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)
  17547. {
  17548. if (source1 == null)
  17549. throw new ArgumentNullException("source1");
  17550. if (source2 == null)
  17551. throw new ArgumentNullException("source2");
  17552. if (source3 == null)
  17553. throw new ArgumentNullException("source3");
  17554. if (source4 == null)
  17555. throw new ArgumentNullException("source4");
  17556. if (source5 == null)
  17557. throw new ArgumentNullException("source5");
  17558. if (source6 == null)
  17559. throw new ArgumentNullException("source6");
  17560. if (source7 == null)
  17561. throw new ArgumentNullException("source7");
  17562. if (source8 == null)
  17563. throw new ArgumentNullException("source8");
  17564. if (source9 == null)
  17565. throw new ArgumentNullException("source9");
  17566. if (source10 == null)
  17567. throw new ArgumentNullException("source10");
  17568. if (source11 == null)
  17569. throw new ArgumentNullException("source11");
  17570. if (source12 == null)
  17571. throw new ArgumentNullException("source12");
  17572. if (source13 == null)
  17573. throw new ArgumentNullException("source13");
  17574. if (source14 == null)
  17575. throw new ArgumentNullException("source14");
  17576. if (resultSelector == null)
  17577. throw new ArgumentNullException("resultSelector");
  17578. return source1.Provider.CreateQuery<TResult>(
  17579. Expression.Call(
  17580. null,
  17581. #if CRIPPLED_REFLECTION
  17582. 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>>))),
  17583. #else
  17584. ((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)),
  17585. #endif
  17586. source1.Expression,
  17587. GetSourceExpression(source2),
  17588. GetSourceExpression(source3),
  17589. GetSourceExpression(source4),
  17590. GetSourceExpression(source5),
  17591. GetSourceExpression(source6),
  17592. GetSourceExpression(source7),
  17593. GetSourceExpression(source8),
  17594. GetSourceExpression(source9),
  17595. GetSourceExpression(source10),
  17596. GetSourceExpression(source11),
  17597. GetSourceExpression(source12),
  17598. GetSourceExpression(source13),
  17599. GetSourceExpression(source14),
  17600. resultSelector
  17601. )
  17602. );
  17603. }
  17604. #endif
  17605. #if !NO_LARGEARITY
  17606. /// <summary>
  17607. /// 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.
  17608. /// </summary>
  17609. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  17610. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  17611. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  17612. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  17613. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  17614. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  17615. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  17616. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  17617. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  17618. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  17619. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  17620. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  17621. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  17622. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  17623. /// <typeparam name="TSource15">The type of the elements in the fifteenth source sequence.</typeparam>
  17624. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  17625. /// <param name="source1">First observable source.</param>
  17626. /// <param name="source2">Second observable source.</param>
  17627. /// <param name="source3">Third observable source.</param>
  17628. /// <param name="source4">Fourth observable source.</param>
  17629. /// <param name="source5">Fifth observable source.</param>
  17630. /// <param name="source6">Sixth observable source.</param>
  17631. /// <param name="source7">Seventh observable source.</param>
  17632. /// <param name="source8">Eighth observable source.</param>
  17633. /// <param name="source9">Ninth observable source.</param>
  17634. /// <param name="source10">Tenth observable source.</param>
  17635. /// <param name="source11">Eleventh observable source.</param>
  17636. /// <param name="source12">Twelfth observable source.</param>
  17637. /// <param name="source13">Thirteenth observable source.</param>
  17638. /// <param name="source14">Fourteenth observable source.</param>
  17639. /// <param name="source15">Fifteenth observable source.</param>
  17640. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  17641. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  17642. /// <exception cref="T:System.ArgumentNullException">
  17643. /// <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>
  17644. 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)
  17645. {
  17646. if (source1 == null)
  17647. throw new ArgumentNullException("source1");
  17648. if (source2 == null)
  17649. throw new ArgumentNullException("source2");
  17650. if (source3 == null)
  17651. throw new ArgumentNullException("source3");
  17652. if (source4 == null)
  17653. throw new ArgumentNullException("source4");
  17654. if (source5 == null)
  17655. throw new ArgumentNullException("source5");
  17656. if (source6 == null)
  17657. throw new ArgumentNullException("source6");
  17658. if (source7 == null)
  17659. throw new ArgumentNullException("source7");
  17660. if (source8 == null)
  17661. throw new ArgumentNullException("source8");
  17662. if (source9 == null)
  17663. throw new ArgumentNullException("source9");
  17664. if (source10 == null)
  17665. throw new ArgumentNullException("source10");
  17666. if (source11 == null)
  17667. throw new ArgumentNullException("source11");
  17668. if (source12 == null)
  17669. throw new ArgumentNullException("source12");
  17670. if (source13 == null)
  17671. throw new ArgumentNullException("source13");
  17672. if (source14 == null)
  17673. throw new ArgumentNullException("source14");
  17674. if (source15 == null)
  17675. throw new ArgumentNullException("source15");
  17676. if (resultSelector == null)
  17677. throw new ArgumentNullException("resultSelector");
  17678. return source1.Provider.CreateQuery<TResult>(
  17679. Expression.Call(
  17680. null,
  17681. #if CRIPPLED_REFLECTION
  17682. 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>>))),
  17683. #else
  17684. ((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)),
  17685. #endif
  17686. source1.Expression,
  17687. GetSourceExpression(source2),
  17688. GetSourceExpression(source3),
  17689. GetSourceExpression(source4),
  17690. GetSourceExpression(source5),
  17691. GetSourceExpression(source6),
  17692. GetSourceExpression(source7),
  17693. GetSourceExpression(source8),
  17694. GetSourceExpression(source9),
  17695. GetSourceExpression(source10),
  17696. GetSourceExpression(source11),
  17697. GetSourceExpression(source12),
  17698. GetSourceExpression(source13),
  17699. GetSourceExpression(source14),
  17700. GetSourceExpression(source15),
  17701. resultSelector
  17702. )
  17703. );
  17704. }
  17705. #endif
  17706. #if !NO_LARGEARITY
  17707. /// <summary>
  17708. /// 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.
  17709. /// </summary>
  17710. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  17711. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  17712. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  17713. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  17714. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  17715. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  17716. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  17717. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  17718. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  17719. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  17720. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  17721. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  17722. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  17723. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  17724. /// <typeparam name="TSource15">The type of the elements in the fifteenth source sequence.</typeparam>
  17725. /// <typeparam name="TSource16">The type of the elements in the sixteenth source sequence.</typeparam>
  17726. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  17727. /// <param name="source1">First observable source.</param>
  17728. /// <param name="source2">Second observable source.</param>
  17729. /// <param name="source3">Third observable source.</param>
  17730. /// <param name="source4">Fourth observable source.</param>
  17731. /// <param name="source5">Fifth observable source.</param>
  17732. /// <param name="source6">Sixth observable source.</param>
  17733. /// <param name="source7">Seventh observable source.</param>
  17734. /// <param name="source8">Eighth observable source.</param>
  17735. /// <param name="source9">Ninth observable source.</param>
  17736. /// <param name="source10">Tenth observable source.</param>
  17737. /// <param name="source11">Eleventh observable source.</param>
  17738. /// <param name="source12">Twelfth observable source.</param>
  17739. /// <param name="source13">Thirteenth observable source.</param>
  17740. /// <param name="source14">Fourteenth observable source.</param>
  17741. /// <param name="source15">Fifteenth observable source.</param>
  17742. /// <param name="source16">Sixteenth observable source.</param>
  17743. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  17744. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  17745. /// <exception cref="T:System.ArgumentNullException">
  17746. /// <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>
  17747. 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)
  17748. {
  17749. if (source1 == null)
  17750. throw new ArgumentNullException("source1");
  17751. if (source2 == null)
  17752. throw new ArgumentNullException("source2");
  17753. if (source3 == null)
  17754. throw new ArgumentNullException("source3");
  17755. if (source4 == null)
  17756. throw new ArgumentNullException("source4");
  17757. if (source5 == null)
  17758. throw new ArgumentNullException("source5");
  17759. if (source6 == null)
  17760. throw new ArgumentNullException("source6");
  17761. if (source7 == null)
  17762. throw new ArgumentNullException("source7");
  17763. if (source8 == null)
  17764. throw new ArgumentNullException("source8");
  17765. if (source9 == null)
  17766. throw new ArgumentNullException("source9");
  17767. if (source10 == null)
  17768. throw new ArgumentNullException("source10");
  17769. if (source11 == null)
  17770. throw new ArgumentNullException("source11");
  17771. if (source12 == null)
  17772. throw new ArgumentNullException("source12");
  17773. if (source13 == null)
  17774. throw new ArgumentNullException("source13");
  17775. if (source14 == null)
  17776. throw new ArgumentNullException("source14");
  17777. if (source15 == null)
  17778. throw new ArgumentNullException("source15");
  17779. if (source16 == null)
  17780. throw new ArgumentNullException("source16");
  17781. if (resultSelector == null)
  17782. throw new ArgumentNullException("resultSelector");
  17783. return source1.Provider.CreateQuery<TResult>(
  17784. Expression.Call(
  17785. null,
  17786. #if CRIPPLED_REFLECTION
  17787. 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>>))),
  17788. #else
  17789. ((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)),
  17790. #endif
  17791. source1.Expression,
  17792. GetSourceExpression(source2),
  17793. GetSourceExpression(source3),
  17794. GetSourceExpression(source4),
  17795. GetSourceExpression(source5),
  17796. GetSourceExpression(source6),
  17797. GetSourceExpression(source7),
  17798. GetSourceExpression(source8),
  17799. GetSourceExpression(source9),
  17800. GetSourceExpression(source10),
  17801. GetSourceExpression(source11),
  17802. GetSourceExpression(source12),
  17803. GetSourceExpression(source13),
  17804. GetSourceExpression(source14),
  17805. GetSourceExpression(source15),
  17806. GetSourceExpression(source16),
  17807. resultSelector
  17808. )
  17809. );
  17810. }
  17811. #endif
  17812. /// <summary>
  17813. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  17814. /// </summary>
  17815. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17816. /// <param name="action">Action to convert to an asynchronous action.</param>
  17817. /// <returns>Asynchronous action.</returns>
  17818. /// <exception cref="T:System.ArgumentNullException">
  17819. /// <paramref name="action" /> is null.</exception>
  17820. public static Func<IQbservable<Unit>> ToAsync(this IQbservableProvider provider, Expression<Action> action)
  17821. {
  17822. if (provider == null)
  17823. throw new ArgumentNullException("provider");
  17824. if (action == null)
  17825. throw new ArgumentNullException("action");
  17826. #if CRIPPLED_REFLECTION
  17827. var m = InfoOf(() => Qbservable.ToAsync(default(IQbservableProvider), default(Expression<Action>)));
  17828. #else
  17829. var m = (MethodInfo)MethodInfo.GetCurrentMethod();
  17830. #endif
  17831. return () => provider.CreateQuery<Unit>(
  17832. Expression.Invoke(
  17833. Expression.Call(
  17834. null,
  17835. m,
  17836. Expression.Constant(provider, typeof(IQbservableProvider)),
  17837. action
  17838. )
  17839. )
  17840. );
  17841. }
  17842. /// <summary>
  17843. /// 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.
  17844. /// </summary>
  17845. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17846. /// <param name="action">Action to convert to an asynchronous action.</param>
  17847. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17848. /// <returns>Asynchronous action.</returns>
  17849. /// <exception cref="T:System.ArgumentNullException">
  17850. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17851. public static Func<IQbservable<Unit>> ToAsync(this IQbservableProvider provider, Expression<Action> action, IScheduler scheduler)
  17852. {
  17853. if (provider == null)
  17854. throw new ArgumentNullException("provider");
  17855. if (action == null)
  17856. throw new ArgumentNullException("action");
  17857. if (scheduler == null)
  17858. throw new ArgumentNullException("scheduler");
  17859. #if CRIPPLED_REFLECTION
  17860. var m = InfoOf(() => Qbservable.ToAsync(default(IQbservableProvider), default(Expression<Action>), default(IScheduler)));
  17861. #else
  17862. var m = (MethodInfo)MethodInfo.GetCurrentMethod();
  17863. #endif
  17864. return () => provider.CreateQuery<Unit>(
  17865. Expression.Invoke(
  17866. Expression.Call(
  17867. null,
  17868. m,
  17869. Expression.Constant(provider, typeof(IQbservableProvider)),
  17870. action,
  17871. Expression.Constant(scheduler, typeof(IScheduler))
  17872. )
  17873. )
  17874. );
  17875. }
  17876. /// <summary>
  17877. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  17878. /// </summary>
  17879. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17880. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17881. /// <param name="action">Action to convert to an asynchronous action.</param>
  17882. /// <returns>Asynchronous action.</returns>
  17883. /// <exception cref="T:System.ArgumentNullException">
  17884. /// <paramref name="action" /> is null.</exception>
  17885. public static Func<TArg1, IQbservable<Unit>> ToAsync<TArg1>(this IQbservableProvider provider, Expression<Action<TArg1>> action)
  17886. {
  17887. if (provider == null)
  17888. throw new ArgumentNullException("provider");
  17889. if (action == null)
  17890. throw new ArgumentNullException("action");
  17891. #if CRIPPLED_REFLECTION
  17892. var m = InfoOf(() => Qbservable.ToAsync<TArg1>(default(IQbservableProvider), default(Expression<Action<TArg1>>)));
  17893. #else
  17894. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1));
  17895. #endif
  17896. return (t1) => provider.CreateQuery<Unit>(
  17897. Expression.Invoke(
  17898. Expression.Call(
  17899. null,
  17900. m,
  17901. Expression.Constant(provider, typeof(IQbservableProvider)),
  17902. action
  17903. ),
  17904. Expression.Constant(t1, typeof(TArg1))
  17905. )
  17906. );
  17907. }
  17908. /// <summary>
  17909. /// 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.
  17910. /// </summary>
  17911. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17912. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17913. /// <param name="action">Action to convert to an asynchronous action.</param>
  17914. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17915. /// <returns>Asynchronous action.</returns>
  17916. /// <exception cref="T:System.ArgumentNullException">
  17917. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17918. public static Func<TArg1, IQbservable<Unit>> ToAsync<TArg1>(this IQbservableProvider provider, Expression<Action<TArg1>> action, IScheduler scheduler)
  17919. {
  17920. if (provider == null)
  17921. throw new ArgumentNullException("provider");
  17922. if (action == null)
  17923. throw new ArgumentNullException("action");
  17924. if (scheduler == null)
  17925. throw new ArgumentNullException("scheduler");
  17926. #if CRIPPLED_REFLECTION
  17927. var m = InfoOf(() => Qbservable.ToAsync<TArg1>(default(IQbservableProvider), default(Expression<Action<TArg1>>), default(IScheduler)));
  17928. #else
  17929. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1));
  17930. #endif
  17931. return (t1) => provider.CreateQuery<Unit>(
  17932. Expression.Invoke(
  17933. Expression.Call(
  17934. null,
  17935. m,
  17936. Expression.Constant(provider, typeof(IQbservableProvider)),
  17937. action,
  17938. Expression.Constant(scheduler, typeof(IScheduler))
  17939. ),
  17940. Expression.Constant(t1, typeof(TArg1))
  17941. )
  17942. );
  17943. }
  17944. /// <summary>
  17945. /// 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.
  17946. /// </summary>
  17947. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17948. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17949. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17950. /// <param name="action">Action to convert to an asynchronous action.</param>
  17951. /// <returns>Asynchronous action.</returns>
  17952. /// <exception cref="T:System.ArgumentNullException">
  17953. /// <paramref name="action" /> is null.</exception>
  17954. public static Func<TArg1, TArg2, IQbservable<Unit>> ToAsync<TArg1, TArg2>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2>> action)
  17955. {
  17956. if (provider == null)
  17957. throw new ArgumentNullException("provider");
  17958. if (action == null)
  17959. throw new ArgumentNullException("action");
  17960. #if CRIPPLED_REFLECTION
  17961. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2>>)));
  17962. #else
  17963. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2));
  17964. #endif
  17965. return (t1, t2) => provider.CreateQuery<Unit>(
  17966. Expression.Invoke(
  17967. Expression.Call(
  17968. null,
  17969. m,
  17970. Expression.Constant(provider, typeof(IQbservableProvider)),
  17971. action
  17972. ),
  17973. Expression.Constant(t1, typeof(TArg1)),
  17974. Expression.Constant(t2, typeof(TArg2))
  17975. )
  17976. );
  17977. }
  17978. /// <summary>
  17979. /// 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.
  17980. /// </summary>
  17981. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17982. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17983. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17984. /// <param name="action">Action to convert to an asynchronous action.</param>
  17985. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17986. /// <returns>Asynchronous action.</returns>
  17987. /// <exception cref="T:System.ArgumentNullException">
  17988. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17989. public static Func<TArg1, TArg2, IQbservable<Unit>> ToAsync<TArg1, TArg2>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2>> action, IScheduler scheduler)
  17990. {
  17991. if (provider == null)
  17992. throw new ArgumentNullException("provider");
  17993. if (action == null)
  17994. throw new ArgumentNullException("action");
  17995. if (scheduler == null)
  17996. throw new ArgumentNullException("scheduler");
  17997. #if CRIPPLED_REFLECTION
  17998. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2>>), default(IScheduler)));
  17999. #else
  18000. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2));
  18001. #endif
  18002. return (t1, t2) => provider.CreateQuery<Unit>(
  18003. Expression.Invoke(
  18004. Expression.Call(
  18005. null,
  18006. m,
  18007. Expression.Constant(provider, typeof(IQbservableProvider)),
  18008. action,
  18009. Expression.Constant(scheduler, typeof(IScheduler))
  18010. ),
  18011. Expression.Constant(t1, typeof(TArg1)),
  18012. Expression.Constant(t2, typeof(TArg2))
  18013. )
  18014. );
  18015. }
  18016. /// <summary>
  18017. /// 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.
  18018. /// </summary>
  18019. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18020. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18021. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18022. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18023. /// <param name="action">Action to convert to an asynchronous action.</param>
  18024. /// <returns>Asynchronous action.</returns>
  18025. /// <exception cref="T:System.ArgumentNullException">
  18026. /// <paramref name="action" /> is null.</exception>
  18027. public static Func<TArg1, TArg2, TArg3, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3>> action)
  18028. {
  18029. if (provider == null)
  18030. throw new ArgumentNullException("provider");
  18031. if (action == null)
  18032. throw new ArgumentNullException("action");
  18033. #if CRIPPLED_REFLECTION
  18034. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3>>)));
  18035. #else
  18036. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3));
  18037. #endif
  18038. return (t1, t2, t3) => provider.CreateQuery<Unit>(
  18039. Expression.Invoke(
  18040. Expression.Call(
  18041. null,
  18042. m,
  18043. Expression.Constant(provider, typeof(IQbservableProvider)),
  18044. action
  18045. ),
  18046. Expression.Constant(t1, typeof(TArg1)),
  18047. Expression.Constant(t2, typeof(TArg2)),
  18048. Expression.Constant(t3, typeof(TArg3))
  18049. )
  18050. );
  18051. }
  18052. /// <summary>
  18053. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  18054. /// </summary>
  18055. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18056. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18057. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18058. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18059. /// <param name="action">Action to convert to an asynchronous action.</param>
  18060. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18061. /// <returns>Asynchronous action.</returns>
  18062. /// <exception cref="T:System.ArgumentNullException">
  18063. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18064. public static Func<TArg1, TArg2, TArg3, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3>> action, IScheduler scheduler)
  18065. {
  18066. if (provider == null)
  18067. throw new ArgumentNullException("provider");
  18068. if (action == null)
  18069. throw new ArgumentNullException("action");
  18070. if (scheduler == null)
  18071. throw new ArgumentNullException("scheduler");
  18072. #if CRIPPLED_REFLECTION
  18073. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3>>), default(IScheduler)));
  18074. #else
  18075. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3));
  18076. #endif
  18077. return (t1, t2, t3) => provider.CreateQuery<Unit>(
  18078. Expression.Invoke(
  18079. Expression.Call(
  18080. null,
  18081. m,
  18082. Expression.Constant(provider, typeof(IQbservableProvider)),
  18083. action,
  18084. Expression.Constant(scheduler, typeof(IScheduler))
  18085. ),
  18086. Expression.Constant(t1, typeof(TArg1)),
  18087. Expression.Constant(t2, typeof(TArg2)),
  18088. Expression.Constant(t3, typeof(TArg3))
  18089. )
  18090. );
  18091. }
  18092. /// <summary>
  18093. /// 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.
  18094. /// </summary>
  18095. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18096. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18097. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18098. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18099. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18100. /// <param name="action">Action to convert to an asynchronous action.</param>
  18101. /// <returns>Asynchronous action.</returns>
  18102. /// <exception cref="T:System.ArgumentNullException">
  18103. /// <paramref name="action" /> is null.</exception>
  18104. public static Func<TArg1, TArg2, TArg3, TArg4, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3, TArg4>> action)
  18105. {
  18106. if (provider == null)
  18107. throw new ArgumentNullException("provider");
  18108. if (action == null)
  18109. throw new ArgumentNullException("action");
  18110. #if CRIPPLED_REFLECTION
  18111. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4>>)));
  18112. #else
  18113. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4));
  18114. #endif
  18115. return (t1, t2, t3, t4) => provider.CreateQuery<Unit>(
  18116. Expression.Invoke(
  18117. Expression.Call(
  18118. null,
  18119. m,
  18120. Expression.Constant(provider, typeof(IQbservableProvider)),
  18121. action
  18122. ),
  18123. Expression.Constant(t1, typeof(TArg1)),
  18124. Expression.Constant(t2, typeof(TArg2)),
  18125. Expression.Constant(t3, typeof(TArg3)),
  18126. Expression.Constant(t4, typeof(TArg4))
  18127. )
  18128. );
  18129. }
  18130. /// <summary>
  18131. /// 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.
  18132. /// </summary>
  18133. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18134. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18135. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18136. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18137. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18138. /// <param name="action">Action to convert to an asynchronous action.</param>
  18139. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18140. /// <returns>Asynchronous action.</returns>
  18141. /// <exception cref="T:System.ArgumentNullException">
  18142. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18143. 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)
  18144. {
  18145. if (provider == null)
  18146. throw new ArgumentNullException("provider");
  18147. if (action == null)
  18148. throw new ArgumentNullException("action");
  18149. if (scheduler == null)
  18150. throw new ArgumentNullException("scheduler");
  18151. #if CRIPPLED_REFLECTION
  18152. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4>>), default(IScheduler)));
  18153. #else
  18154. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4));
  18155. #endif
  18156. return (t1, t2, t3, t4) => provider.CreateQuery<Unit>(
  18157. Expression.Invoke(
  18158. Expression.Call(
  18159. null,
  18160. m,
  18161. Expression.Constant(provider, typeof(IQbservableProvider)),
  18162. action,
  18163. Expression.Constant(scheduler, typeof(IScheduler))
  18164. ),
  18165. Expression.Constant(t1, typeof(TArg1)),
  18166. Expression.Constant(t2, typeof(TArg2)),
  18167. Expression.Constant(t3, typeof(TArg3)),
  18168. Expression.Constant(t4, typeof(TArg4))
  18169. )
  18170. );
  18171. }
  18172. #if !NO_LARGEARITY
  18173. /// <summary>
  18174. /// 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.
  18175. /// </summary>
  18176. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18177. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18178. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18179. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18180. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18181. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18182. /// <param name="action">Action to convert to an asynchronous action.</param>
  18183. /// <returns>Asynchronous action.</returns>
  18184. /// <exception cref="T:System.ArgumentNullException">
  18185. /// <paramref name="action" /> is null.</exception>
  18186. 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)
  18187. {
  18188. if (provider == null)
  18189. throw new ArgumentNullException("provider");
  18190. if (action == null)
  18191. throw new ArgumentNullException("action");
  18192. #if CRIPPLED_REFLECTION
  18193. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5>>)));
  18194. #else
  18195. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5));
  18196. #endif
  18197. return (t1, t2, t3, t4, t5) => provider.CreateQuery<Unit>(
  18198. Expression.Invoke(
  18199. Expression.Call(
  18200. null,
  18201. m,
  18202. Expression.Constant(provider, typeof(IQbservableProvider)),
  18203. action
  18204. ),
  18205. Expression.Constant(t1, typeof(TArg1)),
  18206. Expression.Constant(t2, typeof(TArg2)),
  18207. Expression.Constant(t3, typeof(TArg3)),
  18208. Expression.Constant(t4, typeof(TArg4)),
  18209. Expression.Constant(t5, typeof(TArg5))
  18210. )
  18211. );
  18212. }
  18213. /// <summary>
  18214. /// 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.
  18215. /// </summary>
  18216. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18217. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18218. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18219. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18220. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18221. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18222. /// <param name="action">Action to convert to an asynchronous action.</param>
  18223. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18224. /// <returns>Asynchronous action.</returns>
  18225. /// <exception cref="T:System.ArgumentNullException">
  18226. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18227. 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)
  18228. {
  18229. if (provider == null)
  18230. throw new ArgumentNullException("provider");
  18231. if (action == null)
  18232. throw new ArgumentNullException("action");
  18233. if (scheduler == null)
  18234. throw new ArgumentNullException("scheduler");
  18235. #if CRIPPLED_REFLECTION
  18236. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5>>), default(IScheduler)));
  18237. #else
  18238. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5));
  18239. #endif
  18240. return (t1, t2, t3, t4, t5) => provider.CreateQuery<Unit>(
  18241. Expression.Invoke(
  18242. Expression.Call(
  18243. null,
  18244. m,
  18245. Expression.Constant(provider, typeof(IQbservableProvider)),
  18246. action,
  18247. Expression.Constant(scheduler, typeof(IScheduler))
  18248. ),
  18249. Expression.Constant(t1, typeof(TArg1)),
  18250. Expression.Constant(t2, typeof(TArg2)),
  18251. Expression.Constant(t3, typeof(TArg3)),
  18252. Expression.Constant(t4, typeof(TArg4)),
  18253. Expression.Constant(t5, typeof(TArg5))
  18254. )
  18255. );
  18256. }
  18257. /// <summary>
  18258. /// 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.
  18259. /// </summary>
  18260. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18261. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18262. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18263. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18264. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18265. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18266. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18267. /// <param name="action">Action to convert to an asynchronous action.</param>
  18268. /// <returns>Asynchronous action.</returns>
  18269. /// <exception cref="T:System.ArgumentNullException">
  18270. /// <paramref name="action" /> is null.</exception>
  18271. 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)
  18272. {
  18273. if (provider == null)
  18274. throw new ArgumentNullException("provider");
  18275. if (action == null)
  18276. throw new ArgumentNullException("action");
  18277. #if CRIPPLED_REFLECTION
  18278. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>>)));
  18279. #else
  18280. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6));
  18281. #endif
  18282. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<Unit>(
  18283. Expression.Invoke(
  18284. Expression.Call(
  18285. null,
  18286. m,
  18287. Expression.Constant(provider, typeof(IQbservableProvider)),
  18288. action
  18289. ),
  18290. Expression.Constant(t1, typeof(TArg1)),
  18291. Expression.Constant(t2, typeof(TArg2)),
  18292. Expression.Constant(t3, typeof(TArg3)),
  18293. Expression.Constant(t4, typeof(TArg4)),
  18294. Expression.Constant(t5, typeof(TArg5)),
  18295. Expression.Constant(t6, typeof(TArg6))
  18296. )
  18297. );
  18298. }
  18299. /// <summary>
  18300. /// 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.
  18301. /// </summary>
  18302. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18303. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18304. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18305. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18306. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18307. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18308. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18309. /// <param name="action">Action to convert to an asynchronous action.</param>
  18310. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18311. /// <returns>Asynchronous action.</returns>
  18312. /// <exception cref="T:System.ArgumentNullException">
  18313. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18314. 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)
  18315. {
  18316. if (provider == null)
  18317. throw new ArgumentNullException("provider");
  18318. if (action == null)
  18319. throw new ArgumentNullException("action");
  18320. if (scheduler == null)
  18321. throw new ArgumentNullException("scheduler");
  18322. #if CRIPPLED_REFLECTION
  18323. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>>), default(IScheduler)));
  18324. #else
  18325. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6));
  18326. #endif
  18327. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<Unit>(
  18328. Expression.Invoke(
  18329. Expression.Call(
  18330. null,
  18331. m,
  18332. Expression.Constant(provider, typeof(IQbservableProvider)),
  18333. action,
  18334. Expression.Constant(scheduler, typeof(IScheduler))
  18335. ),
  18336. Expression.Constant(t1, typeof(TArg1)),
  18337. Expression.Constant(t2, typeof(TArg2)),
  18338. Expression.Constant(t3, typeof(TArg3)),
  18339. Expression.Constant(t4, typeof(TArg4)),
  18340. Expression.Constant(t5, typeof(TArg5)),
  18341. Expression.Constant(t6, typeof(TArg6))
  18342. )
  18343. );
  18344. }
  18345. /// <summary>
  18346. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  18347. /// </summary>
  18348. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18349. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18350. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18351. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18352. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18353. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18354. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18355. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18356. /// <param name="action">Action to convert to an asynchronous action.</param>
  18357. /// <returns>Asynchronous action.</returns>
  18358. /// <exception cref="T:System.ArgumentNullException">
  18359. /// <paramref name="action" /> is null.</exception>
  18360. 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)
  18361. {
  18362. if (provider == null)
  18363. throw new ArgumentNullException("provider");
  18364. if (action == null)
  18365. throw new ArgumentNullException("action");
  18366. #if CRIPPLED_REFLECTION
  18367. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7>>)));
  18368. #else
  18369. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7));
  18370. #endif
  18371. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<Unit>(
  18372. Expression.Invoke(
  18373. Expression.Call(
  18374. null,
  18375. m,
  18376. Expression.Constant(provider, typeof(IQbservableProvider)),
  18377. action
  18378. ),
  18379. Expression.Constant(t1, typeof(TArg1)),
  18380. Expression.Constant(t2, typeof(TArg2)),
  18381. Expression.Constant(t3, typeof(TArg3)),
  18382. Expression.Constant(t4, typeof(TArg4)),
  18383. Expression.Constant(t5, typeof(TArg5)),
  18384. Expression.Constant(t6, typeof(TArg6)),
  18385. Expression.Constant(t7, typeof(TArg7))
  18386. )
  18387. );
  18388. }
  18389. /// <summary>
  18390. /// 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.
  18391. /// </summary>
  18392. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18393. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18394. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18395. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18396. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18397. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18398. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18399. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18400. /// <param name="action">Action to convert to an asynchronous action.</param>
  18401. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18402. /// <returns>Asynchronous action.</returns>
  18403. /// <exception cref="T:System.ArgumentNullException">
  18404. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18405. 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)
  18406. {
  18407. if (provider == null)
  18408. throw new ArgumentNullException("provider");
  18409. if (action == null)
  18410. throw new ArgumentNullException("action");
  18411. if (scheduler == null)
  18412. throw new ArgumentNullException("scheduler");
  18413. #if CRIPPLED_REFLECTION
  18414. 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)));
  18415. #else
  18416. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7));
  18417. #endif
  18418. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<Unit>(
  18419. Expression.Invoke(
  18420. Expression.Call(
  18421. null,
  18422. m,
  18423. Expression.Constant(provider, typeof(IQbservableProvider)),
  18424. action,
  18425. Expression.Constant(scheduler, typeof(IScheduler))
  18426. ),
  18427. Expression.Constant(t1, typeof(TArg1)),
  18428. Expression.Constant(t2, typeof(TArg2)),
  18429. Expression.Constant(t3, typeof(TArg3)),
  18430. Expression.Constant(t4, typeof(TArg4)),
  18431. Expression.Constant(t5, typeof(TArg5)),
  18432. Expression.Constant(t6, typeof(TArg6)),
  18433. Expression.Constant(t7, typeof(TArg7))
  18434. )
  18435. );
  18436. }
  18437. /// <summary>
  18438. /// 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.
  18439. /// </summary>
  18440. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18441. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18442. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18443. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18444. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18445. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18446. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18447. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18448. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18449. /// <param name="action">Action to convert to an asynchronous action.</param>
  18450. /// <returns>Asynchronous action.</returns>
  18451. /// <exception cref="T:System.ArgumentNullException">
  18452. /// <paramref name="action" /> is null.</exception>
  18453. 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)
  18454. {
  18455. if (provider == null)
  18456. throw new ArgumentNullException("provider");
  18457. if (action == null)
  18458. throw new ArgumentNullException("action");
  18459. #if CRIPPLED_REFLECTION
  18460. 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>>)));
  18461. #else
  18462. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8));
  18463. #endif
  18464. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<Unit>(
  18465. Expression.Invoke(
  18466. Expression.Call(
  18467. null,
  18468. m,
  18469. Expression.Constant(provider, typeof(IQbservableProvider)),
  18470. action
  18471. ),
  18472. Expression.Constant(t1, typeof(TArg1)),
  18473. Expression.Constant(t2, typeof(TArg2)),
  18474. Expression.Constant(t3, typeof(TArg3)),
  18475. Expression.Constant(t4, typeof(TArg4)),
  18476. Expression.Constant(t5, typeof(TArg5)),
  18477. Expression.Constant(t6, typeof(TArg6)),
  18478. Expression.Constant(t7, typeof(TArg7)),
  18479. Expression.Constant(t8, typeof(TArg8))
  18480. )
  18481. );
  18482. }
  18483. /// <summary>
  18484. /// 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.
  18485. /// </summary>
  18486. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18487. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18488. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18489. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18490. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18491. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18492. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18493. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18494. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18495. /// <param name="action">Action to convert to an asynchronous action.</param>
  18496. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18497. /// <returns>Asynchronous action.</returns>
  18498. /// <exception cref="T:System.ArgumentNullException">
  18499. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18500. 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)
  18501. {
  18502. if (provider == null)
  18503. throw new ArgumentNullException("provider");
  18504. if (action == null)
  18505. throw new ArgumentNullException("action");
  18506. if (scheduler == null)
  18507. throw new ArgumentNullException("scheduler");
  18508. #if CRIPPLED_REFLECTION
  18509. 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)));
  18510. #else
  18511. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8));
  18512. #endif
  18513. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<Unit>(
  18514. Expression.Invoke(
  18515. Expression.Call(
  18516. null,
  18517. m,
  18518. Expression.Constant(provider, typeof(IQbservableProvider)),
  18519. action,
  18520. Expression.Constant(scheduler, typeof(IScheduler))
  18521. ),
  18522. Expression.Constant(t1, typeof(TArg1)),
  18523. Expression.Constant(t2, typeof(TArg2)),
  18524. Expression.Constant(t3, typeof(TArg3)),
  18525. Expression.Constant(t4, typeof(TArg4)),
  18526. Expression.Constant(t5, typeof(TArg5)),
  18527. Expression.Constant(t6, typeof(TArg6)),
  18528. Expression.Constant(t7, typeof(TArg7)),
  18529. Expression.Constant(t8, typeof(TArg8))
  18530. )
  18531. );
  18532. }
  18533. /// <summary>
  18534. /// 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.
  18535. /// </summary>
  18536. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18537. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18538. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18539. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18540. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18541. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18542. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18543. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18544. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18545. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18546. /// <param name="action">Action to convert to an asynchronous action.</param>
  18547. /// <returns>Asynchronous action.</returns>
  18548. /// <exception cref="T:System.ArgumentNullException">
  18549. /// <paramref name="action" /> is null.</exception>
  18550. 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)
  18551. {
  18552. if (provider == null)
  18553. throw new ArgumentNullException("provider");
  18554. if (action == null)
  18555. throw new ArgumentNullException("action");
  18556. #if CRIPPLED_REFLECTION
  18557. 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>>)));
  18558. #else
  18559. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9));
  18560. #endif
  18561. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<Unit>(
  18562. Expression.Invoke(
  18563. Expression.Call(
  18564. null,
  18565. m,
  18566. Expression.Constant(provider, typeof(IQbservableProvider)),
  18567. action
  18568. ),
  18569. Expression.Constant(t1, typeof(TArg1)),
  18570. Expression.Constant(t2, typeof(TArg2)),
  18571. Expression.Constant(t3, typeof(TArg3)),
  18572. Expression.Constant(t4, typeof(TArg4)),
  18573. Expression.Constant(t5, typeof(TArg5)),
  18574. Expression.Constant(t6, typeof(TArg6)),
  18575. Expression.Constant(t7, typeof(TArg7)),
  18576. Expression.Constant(t8, typeof(TArg8)),
  18577. Expression.Constant(t9, typeof(TArg9))
  18578. )
  18579. );
  18580. }
  18581. /// <summary>
  18582. /// 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.
  18583. /// </summary>
  18584. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18585. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18586. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18587. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18588. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18589. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18590. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18591. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18592. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18593. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18594. /// <param name="action">Action to convert to an asynchronous action.</param>
  18595. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18596. /// <returns>Asynchronous action.</returns>
  18597. /// <exception cref="T:System.ArgumentNullException">
  18598. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18599. 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)
  18600. {
  18601. if (provider == null)
  18602. throw new ArgumentNullException("provider");
  18603. if (action == null)
  18604. throw new ArgumentNullException("action");
  18605. if (scheduler == null)
  18606. throw new ArgumentNullException("scheduler");
  18607. #if CRIPPLED_REFLECTION
  18608. 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)));
  18609. #else
  18610. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9));
  18611. #endif
  18612. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<Unit>(
  18613. Expression.Invoke(
  18614. Expression.Call(
  18615. null,
  18616. m,
  18617. Expression.Constant(provider, typeof(IQbservableProvider)),
  18618. action,
  18619. Expression.Constant(scheduler, typeof(IScheduler))
  18620. ),
  18621. Expression.Constant(t1, typeof(TArg1)),
  18622. Expression.Constant(t2, typeof(TArg2)),
  18623. Expression.Constant(t3, typeof(TArg3)),
  18624. Expression.Constant(t4, typeof(TArg4)),
  18625. Expression.Constant(t5, typeof(TArg5)),
  18626. Expression.Constant(t6, typeof(TArg6)),
  18627. Expression.Constant(t7, typeof(TArg7)),
  18628. Expression.Constant(t8, typeof(TArg8)),
  18629. Expression.Constant(t9, typeof(TArg9))
  18630. )
  18631. );
  18632. }
  18633. /// <summary>
  18634. /// 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.
  18635. /// </summary>
  18636. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18637. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18638. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18639. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18640. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18641. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18642. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18643. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18644. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18645. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18646. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18647. /// <param name="action">Action to convert to an asynchronous action.</param>
  18648. /// <returns>Asynchronous action.</returns>
  18649. /// <exception cref="T:System.ArgumentNullException">
  18650. /// <paramref name="action" /> is null.</exception>
  18651. 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)
  18652. {
  18653. if (provider == null)
  18654. throw new ArgumentNullException("provider");
  18655. if (action == null)
  18656. throw new ArgumentNullException("action");
  18657. #if CRIPPLED_REFLECTION
  18658. 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>>)));
  18659. #else
  18660. 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));
  18661. #endif
  18662. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<Unit>(
  18663. Expression.Invoke(
  18664. Expression.Call(
  18665. null,
  18666. m,
  18667. Expression.Constant(provider, typeof(IQbservableProvider)),
  18668. action
  18669. ),
  18670. Expression.Constant(t1, typeof(TArg1)),
  18671. Expression.Constant(t2, typeof(TArg2)),
  18672. Expression.Constant(t3, typeof(TArg3)),
  18673. Expression.Constant(t4, typeof(TArg4)),
  18674. Expression.Constant(t5, typeof(TArg5)),
  18675. Expression.Constant(t6, typeof(TArg6)),
  18676. Expression.Constant(t7, typeof(TArg7)),
  18677. Expression.Constant(t8, typeof(TArg8)),
  18678. Expression.Constant(t9, typeof(TArg9)),
  18679. Expression.Constant(t10, typeof(TArg10))
  18680. )
  18681. );
  18682. }
  18683. /// <summary>
  18684. /// 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.
  18685. /// </summary>
  18686. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18687. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18688. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18689. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18690. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18691. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18692. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18693. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18694. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18695. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18696. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18697. /// <param name="action">Action to convert to an asynchronous action.</param>
  18698. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18699. /// <returns>Asynchronous action.</returns>
  18700. /// <exception cref="T:System.ArgumentNullException">
  18701. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18702. 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)
  18703. {
  18704. if (provider == null)
  18705. throw new ArgumentNullException("provider");
  18706. if (action == null)
  18707. throw new ArgumentNullException("action");
  18708. if (scheduler == null)
  18709. throw new ArgumentNullException("scheduler");
  18710. #if CRIPPLED_REFLECTION
  18711. 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)));
  18712. #else
  18713. 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));
  18714. #endif
  18715. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<Unit>(
  18716. Expression.Invoke(
  18717. Expression.Call(
  18718. null,
  18719. m,
  18720. Expression.Constant(provider, typeof(IQbservableProvider)),
  18721. action,
  18722. Expression.Constant(scheduler, typeof(IScheduler))
  18723. ),
  18724. Expression.Constant(t1, typeof(TArg1)),
  18725. Expression.Constant(t2, typeof(TArg2)),
  18726. Expression.Constant(t3, typeof(TArg3)),
  18727. Expression.Constant(t4, typeof(TArg4)),
  18728. Expression.Constant(t5, typeof(TArg5)),
  18729. Expression.Constant(t6, typeof(TArg6)),
  18730. Expression.Constant(t7, typeof(TArg7)),
  18731. Expression.Constant(t8, typeof(TArg8)),
  18732. Expression.Constant(t9, typeof(TArg9)),
  18733. Expression.Constant(t10, typeof(TArg10))
  18734. )
  18735. );
  18736. }
  18737. /// <summary>
  18738. /// 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.
  18739. /// </summary>
  18740. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18741. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18742. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18743. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18744. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18745. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18746. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18747. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18748. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18749. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18750. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18751. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18752. /// <param name="action">Action to convert to an asynchronous action.</param>
  18753. /// <returns>Asynchronous action.</returns>
  18754. /// <exception cref="T:System.ArgumentNullException">
  18755. /// <paramref name="action" /> is null.</exception>
  18756. 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)
  18757. {
  18758. if (provider == null)
  18759. throw new ArgumentNullException("provider");
  18760. if (action == null)
  18761. throw new ArgumentNullException("action");
  18762. #if CRIPPLED_REFLECTION
  18763. 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>>)));
  18764. #else
  18765. 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));
  18766. #endif
  18767. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<Unit>(
  18768. Expression.Invoke(
  18769. Expression.Call(
  18770. null,
  18771. m,
  18772. Expression.Constant(provider, typeof(IQbservableProvider)),
  18773. action
  18774. ),
  18775. Expression.Constant(t1, typeof(TArg1)),
  18776. Expression.Constant(t2, typeof(TArg2)),
  18777. Expression.Constant(t3, typeof(TArg3)),
  18778. Expression.Constant(t4, typeof(TArg4)),
  18779. Expression.Constant(t5, typeof(TArg5)),
  18780. Expression.Constant(t6, typeof(TArg6)),
  18781. Expression.Constant(t7, typeof(TArg7)),
  18782. Expression.Constant(t8, typeof(TArg8)),
  18783. Expression.Constant(t9, typeof(TArg9)),
  18784. Expression.Constant(t10, typeof(TArg10)),
  18785. Expression.Constant(t11, typeof(TArg11))
  18786. )
  18787. );
  18788. }
  18789. /// <summary>
  18790. /// 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.
  18791. /// </summary>
  18792. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18793. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18794. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18795. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18796. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18797. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18798. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18799. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18800. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18801. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18802. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18803. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18804. /// <param name="action">Action to convert to an asynchronous action.</param>
  18805. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18806. /// <returns>Asynchronous action.</returns>
  18807. /// <exception cref="T:System.ArgumentNullException">
  18808. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18809. 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)
  18810. {
  18811. if (provider == null)
  18812. throw new ArgumentNullException("provider");
  18813. if (action == null)
  18814. throw new ArgumentNullException("action");
  18815. if (scheduler == null)
  18816. throw new ArgumentNullException("scheduler");
  18817. #if CRIPPLED_REFLECTION
  18818. 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)));
  18819. #else
  18820. 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));
  18821. #endif
  18822. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<Unit>(
  18823. Expression.Invoke(
  18824. Expression.Call(
  18825. null,
  18826. m,
  18827. Expression.Constant(provider, typeof(IQbservableProvider)),
  18828. action,
  18829. Expression.Constant(scheduler, typeof(IScheduler))
  18830. ),
  18831. Expression.Constant(t1, typeof(TArg1)),
  18832. Expression.Constant(t2, typeof(TArg2)),
  18833. Expression.Constant(t3, typeof(TArg3)),
  18834. Expression.Constant(t4, typeof(TArg4)),
  18835. Expression.Constant(t5, typeof(TArg5)),
  18836. Expression.Constant(t6, typeof(TArg6)),
  18837. Expression.Constant(t7, typeof(TArg7)),
  18838. Expression.Constant(t8, typeof(TArg8)),
  18839. Expression.Constant(t9, typeof(TArg9)),
  18840. Expression.Constant(t10, typeof(TArg10)),
  18841. Expression.Constant(t11, typeof(TArg11))
  18842. )
  18843. );
  18844. }
  18845. /// <summary>
  18846. /// 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.
  18847. /// </summary>
  18848. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18849. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18850. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18851. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18852. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18853. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18854. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18855. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18856. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18857. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18858. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18859. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18860. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18861. /// <param name="action">Action to convert to an asynchronous action.</param>
  18862. /// <returns>Asynchronous action.</returns>
  18863. /// <exception cref="T:System.ArgumentNullException">
  18864. /// <paramref name="action" /> is null.</exception>
  18865. 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)
  18866. {
  18867. if (provider == null)
  18868. throw new ArgumentNullException("provider");
  18869. if (action == null)
  18870. throw new ArgumentNullException("action");
  18871. #if CRIPPLED_REFLECTION
  18872. 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>>)));
  18873. #else
  18874. 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));
  18875. #endif
  18876. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<Unit>(
  18877. Expression.Invoke(
  18878. Expression.Call(
  18879. null,
  18880. m,
  18881. Expression.Constant(provider, typeof(IQbservableProvider)),
  18882. action
  18883. ),
  18884. Expression.Constant(t1, typeof(TArg1)),
  18885. Expression.Constant(t2, typeof(TArg2)),
  18886. Expression.Constant(t3, typeof(TArg3)),
  18887. Expression.Constant(t4, typeof(TArg4)),
  18888. Expression.Constant(t5, typeof(TArg5)),
  18889. Expression.Constant(t6, typeof(TArg6)),
  18890. Expression.Constant(t7, typeof(TArg7)),
  18891. Expression.Constant(t8, typeof(TArg8)),
  18892. Expression.Constant(t9, typeof(TArg9)),
  18893. Expression.Constant(t10, typeof(TArg10)),
  18894. Expression.Constant(t11, typeof(TArg11)),
  18895. Expression.Constant(t12, typeof(TArg12))
  18896. )
  18897. );
  18898. }
  18899. /// <summary>
  18900. /// 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.
  18901. /// </summary>
  18902. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18903. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18904. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18905. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18906. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18907. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18908. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18909. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18910. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18911. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18912. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18913. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18914. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18915. /// <param name="action">Action to convert to an asynchronous action.</param>
  18916. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18917. /// <returns>Asynchronous action.</returns>
  18918. /// <exception cref="T:System.ArgumentNullException">
  18919. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18920. 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)
  18921. {
  18922. if (provider == null)
  18923. throw new ArgumentNullException("provider");
  18924. if (action == null)
  18925. throw new ArgumentNullException("action");
  18926. if (scheduler == null)
  18927. throw new ArgumentNullException("scheduler");
  18928. #if CRIPPLED_REFLECTION
  18929. 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)));
  18930. #else
  18931. 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));
  18932. #endif
  18933. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<Unit>(
  18934. Expression.Invoke(
  18935. Expression.Call(
  18936. null,
  18937. m,
  18938. Expression.Constant(provider, typeof(IQbservableProvider)),
  18939. action,
  18940. Expression.Constant(scheduler, typeof(IScheduler))
  18941. ),
  18942. Expression.Constant(t1, typeof(TArg1)),
  18943. Expression.Constant(t2, typeof(TArg2)),
  18944. Expression.Constant(t3, typeof(TArg3)),
  18945. Expression.Constant(t4, typeof(TArg4)),
  18946. Expression.Constant(t5, typeof(TArg5)),
  18947. Expression.Constant(t6, typeof(TArg6)),
  18948. Expression.Constant(t7, typeof(TArg7)),
  18949. Expression.Constant(t8, typeof(TArg8)),
  18950. Expression.Constant(t9, typeof(TArg9)),
  18951. Expression.Constant(t10, typeof(TArg10)),
  18952. Expression.Constant(t11, typeof(TArg11)),
  18953. Expression.Constant(t12, typeof(TArg12))
  18954. )
  18955. );
  18956. }
  18957. /// <summary>
  18958. /// 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.
  18959. /// </summary>
  18960. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18961. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18962. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18963. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18964. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18965. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18966. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18967. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18968. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18969. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18970. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18971. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18972. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18973. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18974. /// <param name="action">Action to convert to an asynchronous action.</param>
  18975. /// <returns>Asynchronous action.</returns>
  18976. /// <exception cref="T:System.ArgumentNullException">
  18977. /// <paramref name="action" /> is null.</exception>
  18978. 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)
  18979. {
  18980. if (provider == null)
  18981. throw new ArgumentNullException("provider");
  18982. if (action == null)
  18983. throw new ArgumentNullException("action");
  18984. #if CRIPPLED_REFLECTION
  18985. 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>>)));
  18986. #else
  18987. 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));
  18988. #endif
  18989. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<Unit>(
  18990. Expression.Invoke(
  18991. Expression.Call(
  18992. null,
  18993. m,
  18994. Expression.Constant(provider, typeof(IQbservableProvider)),
  18995. action
  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. Expression.Constant(t7, typeof(TArg7)),
  19004. Expression.Constant(t8, typeof(TArg8)),
  19005. Expression.Constant(t9, typeof(TArg9)),
  19006. Expression.Constant(t10, typeof(TArg10)),
  19007. Expression.Constant(t11, typeof(TArg11)),
  19008. Expression.Constant(t12, typeof(TArg12)),
  19009. Expression.Constant(t13, typeof(TArg13))
  19010. )
  19011. );
  19012. }
  19013. /// <summary>
  19014. /// 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.
  19015. /// </summary>
  19016. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19017. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  19018. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  19019. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  19020. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  19021. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  19022. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  19023. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  19024. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  19025. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  19026. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  19027. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  19028. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  19029. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  19030. /// <param name="action">Action to convert to an asynchronous action.</param>
  19031. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  19032. /// <returns>Asynchronous action.</returns>
  19033. /// <exception cref="T:System.ArgumentNullException">
  19034. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  19035. 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)
  19036. {
  19037. if (provider == null)
  19038. throw new ArgumentNullException("provider");
  19039. if (action == null)
  19040. throw new ArgumentNullException("action");
  19041. if (scheduler == null)
  19042. throw new ArgumentNullException("scheduler");
  19043. #if CRIPPLED_REFLECTION
  19044. 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)));
  19045. #else
  19046. 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));
  19047. #endif
  19048. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<Unit>(
  19049. Expression.Invoke(
  19050. Expression.Call(
  19051. null,
  19052. m,
  19053. Expression.Constant(provider, typeof(IQbservableProvider)),
  19054. action,
  19055. Expression.Constant(scheduler, typeof(IScheduler))
  19056. ),
  19057. Expression.Constant(t1, typeof(TArg1)),
  19058. Expression.Constant(t2, typeof(TArg2)),
  19059. Expression.Constant(t3, typeof(TArg3)),
  19060. Expression.Constant(t4, typeof(TArg4)),
  19061. Expression.Constant(t5, typeof(TArg5)),
  19062. Expression.Constant(t6, typeof(TArg6)),
  19063. Expression.Constant(t7, typeof(TArg7)),
  19064. Expression.Constant(t8, typeof(TArg8)),
  19065. Expression.Constant(t9, typeof(TArg9)),
  19066. Expression.Constant(t10, typeof(TArg10)),
  19067. Expression.Constant(t11, typeof(TArg11)),
  19068. Expression.Constant(t12, typeof(TArg12)),
  19069. Expression.Constant(t13, typeof(TArg13))
  19070. )
  19071. );
  19072. }
  19073. /// <summary>
  19074. /// 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.
  19075. /// </summary>
  19076. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19077. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  19078. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  19079. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  19080. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  19081. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  19082. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  19083. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  19084. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  19085. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  19086. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  19087. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  19088. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  19089. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  19090. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  19091. /// <param name="action">Action to convert to an asynchronous action.</param>
  19092. /// <returns>Asynchronous action.</returns>
  19093. /// <exception cref="T:System.ArgumentNullException">
  19094. /// <paramref name="action" /> is null.</exception>
  19095. 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)
  19096. {
  19097. if (provider == null)
  19098. throw new ArgumentNullException("provider");
  19099. if (action == null)
  19100. throw new ArgumentNullException("action");
  19101. #if CRIPPLED_REFLECTION
  19102. 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>>)));
  19103. #else
  19104. 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));
  19105. #endif
  19106. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<Unit>(
  19107. Expression.Invoke(
  19108. Expression.Call(
  19109. null,
  19110. m,
  19111. Expression.Constant(provider, typeof(IQbservableProvider)),
  19112. action
  19113. ),
  19114. Expression.Constant(t1, typeof(TArg1)),
  19115. Expression.Constant(t2, typeof(TArg2)),
  19116. Expression.Constant(t3, typeof(TArg3)),
  19117. Expression.Constant(t4, typeof(TArg4)),
  19118. Expression.Constant(t5, typeof(TArg5)),
  19119. Expression.Constant(t6, typeof(TArg6)),
  19120. Expression.Constant(t7, typeof(TArg7)),
  19121. Expression.Constant(t8, typeof(TArg8)),
  19122. Expression.Constant(t9, typeof(TArg9)),
  19123. Expression.Constant(t10, typeof(TArg10)),
  19124. Expression.Constant(t11, typeof(TArg11)),
  19125. Expression.Constant(t12, typeof(TArg12)),
  19126. Expression.Constant(t13, typeof(TArg13)),
  19127. Expression.Constant(t14, typeof(TArg14))
  19128. )
  19129. );
  19130. }
  19131. /// <summary>
  19132. /// 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.
  19133. /// </summary>
  19134. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19135. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  19136. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  19137. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  19138. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  19139. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  19140. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  19141. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  19142. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  19143. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  19144. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  19145. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  19146. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  19147. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  19148. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  19149. /// <param name="action">Action to convert to an asynchronous action.</param>
  19150. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  19151. /// <returns>Asynchronous action.</returns>
  19152. /// <exception cref="T:System.ArgumentNullException">
  19153. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  19154. 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)
  19155. {
  19156. if (provider == null)
  19157. throw new ArgumentNullException("provider");
  19158. if (action == null)
  19159. throw new ArgumentNullException("action");
  19160. if (scheduler == null)
  19161. throw new ArgumentNullException("scheduler");
  19162. #if CRIPPLED_REFLECTION
  19163. 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)));
  19164. #else
  19165. 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));
  19166. #endif
  19167. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<Unit>(
  19168. Expression.Invoke(
  19169. Expression.Call(
  19170. null,
  19171. m,
  19172. Expression.Constant(provider, typeof(IQbservableProvider)),
  19173. action,
  19174. Expression.Constant(scheduler, typeof(IScheduler))
  19175. ),
  19176. Expression.Constant(t1, typeof(TArg1)),
  19177. Expression.Constant(t2, typeof(TArg2)),
  19178. Expression.Constant(t3, typeof(TArg3)),
  19179. Expression.Constant(t4, typeof(TArg4)),
  19180. Expression.Constant(t5, typeof(TArg5)),
  19181. Expression.Constant(t6, typeof(TArg6)),
  19182. Expression.Constant(t7, typeof(TArg7)),
  19183. Expression.Constant(t8, typeof(TArg8)),
  19184. Expression.Constant(t9, typeof(TArg9)),
  19185. Expression.Constant(t10, typeof(TArg10)),
  19186. Expression.Constant(t11, typeof(TArg11)),
  19187. Expression.Constant(t12, typeof(TArg12)),
  19188. Expression.Constant(t13, typeof(TArg13)),
  19189. Expression.Constant(t14, typeof(TArg14))
  19190. )
  19191. );
  19192. }
  19193. /// <summary>
  19194. /// 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.
  19195. /// </summary>
  19196. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19197. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  19198. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  19199. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  19200. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  19201. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  19202. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  19203. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  19204. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  19205. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  19206. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  19207. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  19208. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  19209. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  19210. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  19211. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the action.</typeparam>
  19212. /// <param name="action">Action to convert to an asynchronous action.</param>
  19213. /// <returns>Asynchronous action.</returns>
  19214. /// <exception cref="T:System.ArgumentNullException">
  19215. /// <paramref name="action" /> is null.</exception>
  19216. 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)
  19217. {
  19218. if (provider == null)
  19219. throw new ArgumentNullException("provider");
  19220. if (action == null)
  19221. throw new ArgumentNullException("action");
  19222. #if CRIPPLED_REFLECTION
  19223. 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>>)));
  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(TArg10), typeof(TArg11), typeof(TArg12), typeof(TArg13), typeof(TArg14), typeof(TArg15));
  19226. #endif
  19227. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) => provider.CreateQuery<Unit>(
  19228. Expression.Invoke(
  19229. Expression.Call(
  19230. null,
  19231. m,
  19232. Expression.Constant(provider, typeof(IQbservableProvider)),
  19233. action
  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. Expression.Constant(t10, typeof(TArg10)),
  19245. Expression.Constant(t11, typeof(TArg11)),
  19246. Expression.Constant(t12, typeof(TArg12)),
  19247. Expression.Constant(t13, typeof(TArg13)),
  19248. Expression.Constant(t14, typeof(TArg14)),
  19249. Expression.Constant(t15, typeof(TArg15))
  19250. )
  19251. );
  19252. }
  19253. /// <summary>
  19254. /// 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.
  19255. /// </summary>
  19256. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19257. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  19258. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  19259. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  19260. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  19261. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  19262. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  19263. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  19264. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  19265. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  19266. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  19267. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  19268. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  19269. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  19270. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  19271. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the action.</typeparam>
  19272. /// <param name="action">Action to convert to an asynchronous action.</param>
  19273. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  19274. /// <returns>Asynchronous action.</returns>
  19275. /// <exception cref="T:System.ArgumentNullException">
  19276. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  19277. 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)
  19278. {
  19279. if (provider == null)
  19280. throw new ArgumentNullException("provider");
  19281. if (action == null)
  19282. throw new ArgumentNullException("action");
  19283. if (scheduler == null)
  19284. throw new ArgumentNullException("scheduler");
  19285. #if CRIPPLED_REFLECTION
  19286. 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)));
  19287. #else
  19288. 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));
  19289. #endif
  19290. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) => provider.CreateQuery<Unit>(
  19291. Expression.Invoke(
  19292. Expression.Call(
  19293. null,
  19294. m,
  19295. Expression.Constant(provider, typeof(IQbservableProvider)),
  19296. action,
  19297. Expression.Constant(scheduler, typeof(IScheduler))
  19298. ),
  19299. Expression.Constant(t1, typeof(TArg1)),
  19300. Expression.Constant(t2, typeof(TArg2)),
  19301. Expression.Constant(t3, typeof(TArg3)),
  19302. Expression.Constant(t4, typeof(TArg4)),
  19303. Expression.Constant(t5, typeof(TArg5)),
  19304. Expression.Constant(t6, typeof(TArg6)),
  19305. Expression.Constant(t7, typeof(TArg7)),
  19306. Expression.Constant(t8, typeof(TArg8)),
  19307. Expression.Constant(t9, typeof(TArg9)),
  19308. Expression.Constant(t10, typeof(TArg10)),
  19309. Expression.Constant(t11, typeof(TArg11)),
  19310. Expression.Constant(t12, typeof(TArg12)),
  19311. Expression.Constant(t13, typeof(TArg13)),
  19312. Expression.Constant(t14, typeof(TArg14)),
  19313. Expression.Constant(t15, typeof(TArg15))
  19314. )
  19315. );
  19316. }
  19317. /// <summary>
  19318. /// 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.
  19319. /// </summary>
  19320. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19321. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  19322. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  19323. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  19324. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  19325. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  19326. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  19327. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  19328. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  19329. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  19330. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  19331. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  19332. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  19333. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  19334. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  19335. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the action.</typeparam>
  19336. /// <typeparam name="TArg16">The type of the sixteenth argument passed to the action.</typeparam>
  19337. /// <param name="action">Action to convert to an asynchronous action.</param>
  19338. /// <returns>Asynchronous action.</returns>
  19339. /// <exception cref="T:System.ArgumentNullException">
  19340. /// <paramref name="action" /> is null.</exception>
  19341. 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)
  19342. {
  19343. if (provider == null)
  19344. throw new ArgumentNullException("provider");
  19345. if (action == null)
  19346. throw new ArgumentNullException("action");
  19347. #if CRIPPLED_REFLECTION
  19348. 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>>)));
  19349. #else
  19350. 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));
  19351. #endif
  19352. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) => provider.CreateQuery<Unit>(
  19353. Expression.Invoke(
  19354. Expression.Call(
  19355. null,
  19356. m,
  19357. Expression.Constant(provider, typeof(IQbservableProvider)),
  19358. action
  19359. ),
  19360. Expression.Constant(t1, typeof(TArg1)),
  19361. Expression.Constant(t2, typeof(TArg2)),
  19362. Expression.Constant(t3, typeof(TArg3)),
  19363. Expression.Constant(t4, typeof(TArg4)),
  19364. Expression.Constant(t5, typeof(TArg5)),
  19365. Expression.Constant(t6, typeof(TArg6)),
  19366. Expression.Constant(t7, typeof(TArg7)),
  19367. Expression.Constant(t8, typeof(TArg8)),
  19368. Expression.Constant(t9, typeof(TArg9)),
  19369. Expression.Constant(t10, typeof(TArg10)),
  19370. Expression.Constant(t11, typeof(TArg11)),
  19371. Expression.Constant(t12, typeof(TArg12)),
  19372. Expression.Constant(t13, typeof(TArg13)),
  19373. Expression.Constant(t14, typeof(TArg14)),
  19374. Expression.Constant(t15, typeof(TArg15)),
  19375. Expression.Constant(t16, typeof(TArg16))
  19376. )
  19377. );
  19378. }
  19379. /// <summary>
  19380. /// 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.
  19381. /// </summary>
  19382. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19383. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  19384. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  19385. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  19386. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  19387. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  19388. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  19389. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  19390. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  19391. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  19392. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  19393. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  19394. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  19395. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  19396. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  19397. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the action.</typeparam>
  19398. /// <typeparam name="TArg16">The type of the sixteenth argument passed to the action.</typeparam>
  19399. /// <param name="action">Action to convert to an asynchronous action.</param>
  19400. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  19401. /// <returns>Asynchronous action.</returns>
  19402. /// <exception cref="T:System.ArgumentNullException">
  19403. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  19404. 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)
  19405. {
  19406. if (provider == null)
  19407. throw new ArgumentNullException("provider");
  19408. if (action == null)
  19409. throw new ArgumentNullException("action");
  19410. if (scheduler == null)
  19411. throw new ArgumentNullException("scheduler");
  19412. #if CRIPPLED_REFLECTION
  19413. 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)));
  19414. #else
  19415. 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));
  19416. #endif
  19417. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) => provider.CreateQuery<Unit>(
  19418. Expression.Invoke(
  19419. Expression.Call(
  19420. null,
  19421. m,
  19422. Expression.Constant(provider, typeof(IQbservableProvider)),
  19423. action,
  19424. Expression.Constant(scheduler, typeof(IScheduler))
  19425. ),
  19426. Expression.Constant(t1, typeof(TArg1)),
  19427. Expression.Constant(t2, typeof(TArg2)),
  19428. Expression.Constant(t3, typeof(TArg3)),
  19429. Expression.Constant(t4, typeof(TArg4)),
  19430. Expression.Constant(t5, typeof(TArg5)),
  19431. Expression.Constant(t6, typeof(TArg6)),
  19432. Expression.Constant(t7, typeof(TArg7)),
  19433. Expression.Constant(t8, typeof(TArg8)),
  19434. Expression.Constant(t9, typeof(TArg9)),
  19435. Expression.Constant(t10, typeof(TArg10)),
  19436. Expression.Constant(t11, typeof(TArg11)),
  19437. Expression.Constant(t12, typeof(TArg12)),
  19438. Expression.Constant(t13, typeof(TArg13)),
  19439. Expression.Constant(t14, typeof(TArg14)),
  19440. Expression.Constant(t15, typeof(TArg15)),
  19441. Expression.Constant(t16, typeof(TArg16))
  19442. )
  19443. );
  19444. }
  19445. #endif
  19446. /// <summary>
  19447. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19448. /// </summary>
  19449. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19450. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19451. /// <param name="function">Function to convert to an asynchronous function.</param>
  19452. /// <returns>Asynchronous function.</returns>
  19453. /// <exception cref="T:System.ArgumentNullException">
  19454. /// <paramref name="function" /> is null.</exception>
  19455. public static Func<IQbservable<TResult>> ToAsync<TResult>(this IQbservableProvider provider, Expression<Func<TResult>> function)
  19456. {
  19457. if (provider == null)
  19458. throw new ArgumentNullException("provider");
  19459. if (function == null)
  19460. throw new ArgumentNullException("function");
  19461. #if CRIPPLED_REFLECTION
  19462. var m = InfoOf(() => Qbservable.ToAsync<TResult>(default(IQbservableProvider), default(Expression<Func<TResult>>)));
  19463. #else
  19464. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult));
  19465. #endif
  19466. return () => provider.CreateQuery<TResult>(
  19467. Expression.Invoke(
  19468. Expression.Call(
  19469. null,
  19470. m,
  19471. Expression.Constant(provider, typeof(IQbservableProvider)),
  19472. function
  19473. )
  19474. )
  19475. );
  19476. }
  19477. /// <summary>
  19478. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  19479. /// </summary>
  19480. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19481. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19482. /// <param name="function">Function to convert to an asynchronous function.</param>
  19483. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19484. /// <returns>Asynchronous function.</returns>
  19485. /// <exception cref="T:System.ArgumentNullException">
  19486. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19487. public static Func<IQbservable<TResult>> ToAsync<TResult>(this IQbservableProvider provider, Expression<Func<TResult>> function, IScheduler scheduler)
  19488. {
  19489. if (provider == null)
  19490. throw new ArgumentNullException("provider");
  19491. if (function == null)
  19492. throw new ArgumentNullException("function");
  19493. if (scheduler == null)
  19494. throw new ArgumentNullException("scheduler");
  19495. #if CRIPPLED_REFLECTION
  19496. var m = InfoOf(() => Qbservable.ToAsync<TResult>(default(IQbservableProvider), default(Expression<Func<TResult>>), default(IScheduler)));
  19497. #else
  19498. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult));
  19499. #endif
  19500. return () => provider.CreateQuery<TResult>(
  19501. Expression.Invoke(
  19502. Expression.Call(
  19503. null,
  19504. m,
  19505. Expression.Constant(provider, typeof(IQbservableProvider)),
  19506. function,
  19507. Expression.Constant(scheduler, typeof(IScheduler))
  19508. )
  19509. )
  19510. );
  19511. }
  19512. /// <summary>
  19513. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19514. /// </summary>
  19515. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19516. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19517. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19518. /// <param name="function">Function to convert to an asynchronous function.</param>
  19519. /// <returns>Asynchronous function.</returns>
  19520. /// <exception cref="T:System.ArgumentNullException">
  19521. /// <paramref name="function" /> is null.</exception>
  19522. public static Func<TArg1, IQbservable<TResult>> ToAsync<TArg1, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TResult>> function)
  19523. {
  19524. if (provider == null)
  19525. throw new ArgumentNullException("provider");
  19526. if (function == null)
  19527. throw new ArgumentNullException("function");
  19528. #if CRIPPLED_REFLECTION
  19529. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TResult>>)));
  19530. #else
  19531. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TResult));
  19532. #endif
  19533. return (t1) => provider.CreateQuery<TResult>(
  19534. Expression.Invoke(
  19535. Expression.Call(
  19536. null,
  19537. m,
  19538. Expression.Constant(provider, typeof(IQbservableProvider)),
  19539. function
  19540. ),
  19541. Expression.Constant(t1, typeof(TArg1))
  19542. )
  19543. );
  19544. }
  19545. /// <summary>
  19546. /// 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.
  19547. /// </summary>
  19548. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19549. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19550. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19551. /// <param name="function">Function to convert to an asynchronous function.</param>
  19552. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19553. /// <returns>Asynchronous function.</returns>
  19554. /// <exception cref="T:System.ArgumentNullException">
  19555. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19556. public static Func<TArg1, IQbservable<TResult>> ToAsync<TArg1, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TResult>> function, IScheduler scheduler)
  19557. {
  19558. if (provider == null)
  19559. throw new ArgumentNullException("provider");
  19560. if (function == null)
  19561. throw new ArgumentNullException("function");
  19562. if (scheduler == null)
  19563. throw new ArgumentNullException("scheduler");
  19564. #if CRIPPLED_REFLECTION
  19565. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TResult>>), default(IScheduler)));
  19566. #else
  19567. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TResult));
  19568. #endif
  19569. return (t1) => provider.CreateQuery<TResult>(
  19570. Expression.Invoke(
  19571. Expression.Call(
  19572. null,
  19573. m,
  19574. Expression.Constant(provider, typeof(IQbservableProvider)),
  19575. function,
  19576. Expression.Constant(scheduler, typeof(IScheduler))
  19577. ),
  19578. Expression.Constant(t1, typeof(TArg1))
  19579. )
  19580. );
  19581. }
  19582. /// <summary>
  19583. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19584. /// </summary>
  19585. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19586. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19587. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19588. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19589. /// <param name="function">Function to convert to an asynchronous function.</param>
  19590. /// <returns>Asynchronous function.</returns>
  19591. /// <exception cref="T:System.ArgumentNullException">
  19592. /// <paramref name="function" /> is null.</exception>
  19593. public static Func<TArg1, TArg2, IQbservable<TResult>> ToAsync<TArg1, TArg2, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TResult>> function)
  19594. {
  19595. if (provider == null)
  19596. throw new ArgumentNullException("provider");
  19597. if (function == null)
  19598. throw new ArgumentNullException("function");
  19599. #if CRIPPLED_REFLECTION
  19600. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TResult>>)));
  19601. #else
  19602. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TResult));
  19603. #endif
  19604. return (t1, t2) => provider.CreateQuery<TResult>(
  19605. Expression.Invoke(
  19606. Expression.Call(
  19607. null,
  19608. m,
  19609. Expression.Constant(provider, typeof(IQbservableProvider)),
  19610. function
  19611. ),
  19612. Expression.Constant(t1, typeof(TArg1)),
  19613. Expression.Constant(t2, typeof(TArg2))
  19614. )
  19615. );
  19616. }
  19617. /// <summary>
  19618. /// 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.
  19619. /// </summary>
  19620. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19621. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19622. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19623. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19624. /// <param name="function">Function to convert to an asynchronous function.</param>
  19625. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19626. /// <returns>Asynchronous function.</returns>
  19627. /// <exception cref="T:System.ArgumentNullException">
  19628. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19629. public static Func<TArg1, TArg2, IQbservable<TResult>> ToAsync<TArg1, TArg2, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TResult>> function, IScheduler scheduler)
  19630. {
  19631. if (provider == null)
  19632. throw new ArgumentNullException("provider");
  19633. if (function == null)
  19634. throw new ArgumentNullException("function");
  19635. if (scheduler == null)
  19636. throw new ArgumentNullException("scheduler");
  19637. #if CRIPPLED_REFLECTION
  19638. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TResult>>), default(IScheduler)));
  19639. #else
  19640. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TResult));
  19641. #endif
  19642. return (t1, t2) => provider.CreateQuery<TResult>(
  19643. Expression.Invoke(
  19644. Expression.Call(
  19645. null,
  19646. m,
  19647. Expression.Constant(provider, typeof(IQbservableProvider)),
  19648. function,
  19649. Expression.Constant(scheduler, typeof(IScheduler))
  19650. ),
  19651. Expression.Constant(t1, typeof(TArg1)),
  19652. Expression.Constant(t2, typeof(TArg2))
  19653. )
  19654. );
  19655. }
  19656. /// <summary>
  19657. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19658. /// </summary>
  19659. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19660. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19661. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19662. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19663. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19664. /// <param name="function">Function to convert to an asynchronous function.</param>
  19665. /// <returns>Asynchronous function.</returns>
  19666. /// <exception cref="T:System.ArgumentNullException">
  19667. /// <paramref name="function" /> is null.</exception>
  19668. public static Func<TArg1, TArg2, TArg3, IQbservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TResult>> function)
  19669. {
  19670. if (provider == null)
  19671. throw new ArgumentNullException("provider");
  19672. if (function == null)
  19673. throw new ArgumentNullException("function");
  19674. #if CRIPPLED_REFLECTION
  19675. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TResult>>)));
  19676. #else
  19677. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TResult));
  19678. #endif
  19679. return (t1, t2, t3) => provider.CreateQuery<TResult>(
  19680. Expression.Invoke(
  19681. Expression.Call(
  19682. null,
  19683. m,
  19684. Expression.Constant(provider, typeof(IQbservableProvider)),
  19685. function
  19686. ),
  19687. Expression.Constant(t1, typeof(TArg1)),
  19688. Expression.Constant(t2, typeof(TArg2)),
  19689. Expression.Constant(t3, typeof(TArg3))
  19690. )
  19691. );
  19692. }
  19693. /// <summary>
  19694. /// 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.
  19695. /// </summary>
  19696. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19697. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19698. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19699. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19700. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19701. /// <param name="function">Function to convert to an asynchronous function.</param>
  19702. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19703. /// <returns>Asynchronous function.</returns>
  19704. /// <exception cref="T:System.ArgumentNullException">
  19705. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19706. 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)
  19707. {
  19708. if (provider == null)
  19709. throw new ArgumentNullException("provider");
  19710. if (function == null)
  19711. throw new ArgumentNullException("function");
  19712. if (scheduler == null)
  19713. throw new ArgumentNullException("scheduler");
  19714. #if CRIPPLED_REFLECTION
  19715. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TResult>>), default(IScheduler)));
  19716. #else
  19717. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TResult));
  19718. #endif
  19719. return (t1, t2, t3) => provider.CreateQuery<TResult>(
  19720. Expression.Invoke(
  19721. Expression.Call(
  19722. null,
  19723. m,
  19724. Expression.Constant(provider, typeof(IQbservableProvider)),
  19725. function,
  19726. Expression.Constant(scheduler, typeof(IScheduler))
  19727. ),
  19728. Expression.Constant(t1, typeof(TArg1)),
  19729. Expression.Constant(t2, typeof(TArg2)),
  19730. Expression.Constant(t3, typeof(TArg3))
  19731. )
  19732. );
  19733. }
  19734. /// <summary>
  19735. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19736. /// </summary>
  19737. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19738. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19739. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19740. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19741. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19742. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19743. /// <param name="function">Function to convert to an asynchronous function.</param>
  19744. /// <returns>Asynchronous function.</returns>
  19745. /// <exception cref="T:System.ArgumentNullException">
  19746. /// <paramref name="function" /> is null.</exception>
  19747. 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)
  19748. {
  19749. if (provider == null)
  19750. throw new ArgumentNullException("provider");
  19751. if (function == null)
  19752. throw new ArgumentNullException("function");
  19753. #if CRIPPLED_REFLECTION
  19754. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TResult>>)));
  19755. #else
  19756. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TResult));
  19757. #endif
  19758. return (t1, t2, t3, t4) => provider.CreateQuery<TResult>(
  19759. Expression.Invoke(
  19760. Expression.Call(
  19761. null,
  19762. m,
  19763. Expression.Constant(provider, typeof(IQbservableProvider)),
  19764. function
  19765. ),
  19766. Expression.Constant(t1, typeof(TArg1)),
  19767. Expression.Constant(t2, typeof(TArg2)),
  19768. Expression.Constant(t3, typeof(TArg3)),
  19769. Expression.Constant(t4, typeof(TArg4))
  19770. )
  19771. );
  19772. }
  19773. /// <summary>
  19774. /// 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.
  19775. /// </summary>
  19776. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19777. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19778. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19779. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19780. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19781. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19782. /// <param name="function">Function to convert to an asynchronous function.</param>
  19783. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19784. /// <returns>Asynchronous function.</returns>
  19785. /// <exception cref="T:System.ArgumentNullException">
  19786. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19787. 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)
  19788. {
  19789. if (provider == null)
  19790. throw new ArgumentNullException("provider");
  19791. if (function == null)
  19792. throw new ArgumentNullException("function");
  19793. if (scheduler == null)
  19794. throw new ArgumentNullException("scheduler");
  19795. #if CRIPPLED_REFLECTION
  19796. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TResult>>), default(IScheduler)));
  19797. #else
  19798. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TResult));
  19799. #endif
  19800. return (t1, t2, t3, t4) => provider.CreateQuery<TResult>(
  19801. Expression.Invoke(
  19802. Expression.Call(
  19803. null,
  19804. m,
  19805. Expression.Constant(provider, typeof(IQbservableProvider)),
  19806. function,
  19807. Expression.Constant(scheduler, typeof(IScheduler))
  19808. ),
  19809. Expression.Constant(t1, typeof(TArg1)),
  19810. Expression.Constant(t2, typeof(TArg2)),
  19811. Expression.Constant(t3, typeof(TArg3)),
  19812. Expression.Constant(t4, typeof(TArg4))
  19813. )
  19814. );
  19815. }
  19816. #if !NO_LARGEARITY
  19817. /// <summary>
  19818. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19819. /// </summary>
  19820. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19821. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19822. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19823. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19824. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19825. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19826. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19827. /// <param name="function">Function to convert to an asynchronous function.</param>
  19828. /// <returns>Asynchronous function.</returns>
  19829. /// <exception cref="T:System.ArgumentNullException">
  19830. /// <paramref name="function" /> is null.</exception>
  19831. 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)
  19832. {
  19833. if (provider == null)
  19834. throw new ArgumentNullException("provider");
  19835. if (function == null)
  19836. throw new ArgumentNullException("function");
  19837. #if CRIPPLED_REFLECTION
  19838. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>>)));
  19839. #else
  19840. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TResult));
  19841. #endif
  19842. return (t1, t2, t3, t4, t5) => provider.CreateQuery<TResult>(
  19843. Expression.Invoke(
  19844. Expression.Call(
  19845. null,
  19846. m,
  19847. Expression.Constant(provider, typeof(IQbservableProvider)),
  19848. function
  19849. ),
  19850. Expression.Constant(t1, typeof(TArg1)),
  19851. Expression.Constant(t2, typeof(TArg2)),
  19852. Expression.Constant(t3, typeof(TArg3)),
  19853. Expression.Constant(t4, typeof(TArg4)),
  19854. Expression.Constant(t5, typeof(TArg5))
  19855. )
  19856. );
  19857. }
  19858. /// <summary>
  19859. /// 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.
  19860. /// </summary>
  19861. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19862. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19863. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19864. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19865. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19866. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19867. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19868. /// <param name="function">Function to convert to an asynchronous function.</param>
  19869. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19870. /// <returns>Asynchronous function.</returns>
  19871. /// <exception cref="T:System.ArgumentNullException">
  19872. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19873. 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)
  19874. {
  19875. if (provider == null)
  19876. throw new ArgumentNullException("provider");
  19877. if (function == null)
  19878. throw new ArgumentNullException("function");
  19879. if (scheduler == null)
  19880. throw new ArgumentNullException("scheduler");
  19881. #if CRIPPLED_REFLECTION
  19882. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>>), default(IScheduler)));
  19883. #else
  19884. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TResult));
  19885. #endif
  19886. return (t1, t2, t3, t4, t5) => provider.CreateQuery<TResult>(
  19887. Expression.Invoke(
  19888. Expression.Call(
  19889. null,
  19890. m,
  19891. Expression.Constant(provider, typeof(IQbservableProvider)),
  19892. function,
  19893. Expression.Constant(scheduler, typeof(IScheduler))
  19894. ),
  19895. Expression.Constant(t1, typeof(TArg1)),
  19896. Expression.Constant(t2, typeof(TArg2)),
  19897. Expression.Constant(t3, typeof(TArg3)),
  19898. Expression.Constant(t4, typeof(TArg4)),
  19899. Expression.Constant(t5, typeof(TArg5))
  19900. )
  19901. );
  19902. }
  19903. /// <summary>
  19904. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19905. /// </summary>
  19906. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19907. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19908. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19909. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19910. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19911. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19912. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19913. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19914. /// <param name="function">Function to convert to an asynchronous function.</param>
  19915. /// <returns>Asynchronous function.</returns>
  19916. /// <exception cref="T:System.ArgumentNullException">
  19917. /// <paramref name="function" /> is null.</exception>
  19918. 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)
  19919. {
  19920. if (provider == null)
  19921. throw new ArgumentNullException("provider");
  19922. if (function == null)
  19923. throw new ArgumentNullException("function");
  19924. #if CRIPPLED_REFLECTION
  19925. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TResult>>)));
  19926. #else
  19927. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TResult));
  19928. #endif
  19929. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<TResult>(
  19930. Expression.Invoke(
  19931. Expression.Call(
  19932. null,
  19933. m,
  19934. Expression.Constant(provider, typeof(IQbservableProvider)),
  19935. function
  19936. ),
  19937. Expression.Constant(t1, typeof(TArg1)),
  19938. Expression.Constant(t2, typeof(TArg2)),
  19939. Expression.Constant(t3, typeof(TArg3)),
  19940. Expression.Constant(t4, typeof(TArg4)),
  19941. Expression.Constant(t5, typeof(TArg5)),
  19942. Expression.Constant(t6, typeof(TArg6))
  19943. )
  19944. );
  19945. }
  19946. /// <summary>
  19947. /// 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.
  19948. /// </summary>
  19949. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19950. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19951. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19952. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19953. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19954. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19955. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19956. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19957. /// <param name="function">Function to convert to an asynchronous function.</param>
  19958. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19959. /// <returns>Asynchronous function.</returns>
  19960. /// <exception cref="T:System.ArgumentNullException">
  19961. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19962. 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)
  19963. {
  19964. if (provider == null)
  19965. throw new ArgumentNullException("provider");
  19966. if (function == null)
  19967. throw new ArgumentNullException("function");
  19968. if (scheduler == null)
  19969. throw new ArgumentNullException("scheduler");
  19970. #if CRIPPLED_REFLECTION
  19971. 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)));
  19972. #else
  19973. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TResult));
  19974. #endif
  19975. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<TResult>(
  19976. Expression.Invoke(
  19977. Expression.Call(
  19978. null,
  19979. m,
  19980. Expression.Constant(provider, typeof(IQbservableProvider)),
  19981. function,
  19982. Expression.Constant(scheduler, typeof(IScheduler))
  19983. ),
  19984. Expression.Constant(t1, typeof(TArg1)),
  19985. Expression.Constant(t2, typeof(TArg2)),
  19986. Expression.Constant(t3, typeof(TArg3)),
  19987. Expression.Constant(t4, typeof(TArg4)),
  19988. Expression.Constant(t5, typeof(TArg5)),
  19989. Expression.Constant(t6, typeof(TArg6))
  19990. )
  19991. );
  19992. }
  19993. /// <summary>
  19994. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19995. /// </summary>
  19996. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19997. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19998. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19999. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20000. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20001. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20002. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20003. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20004. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20005. /// <param name="function">Function to convert to an asynchronous function.</param>
  20006. /// <returns>Asynchronous function.</returns>
  20007. /// <exception cref="T:System.ArgumentNullException">
  20008. /// <paramref name="function" /> is null.</exception>
  20009. 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)
  20010. {
  20011. if (provider == null)
  20012. throw new ArgumentNullException("provider");
  20013. if (function == null)
  20014. throw new ArgumentNullException("function");
  20015. #if CRIPPLED_REFLECTION
  20016. 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>>)));
  20017. #else
  20018. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TResult));
  20019. #endif
  20020. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<TResult>(
  20021. Expression.Invoke(
  20022. Expression.Call(
  20023. null,
  20024. m,
  20025. Expression.Constant(provider, typeof(IQbservableProvider)),
  20026. function
  20027. ),
  20028. Expression.Constant(t1, typeof(TArg1)),
  20029. Expression.Constant(t2, typeof(TArg2)),
  20030. Expression.Constant(t3, typeof(TArg3)),
  20031. Expression.Constant(t4, typeof(TArg4)),
  20032. Expression.Constant(t5, typeof(TArg5)),
  20033. Expression.Constant(t6, typeof(TArg6)),
  20034. Expression.Constant(t7, typeof(TArg7))
  20035. )
  20036. );
  20037. }
  20038. /// <summary>
  20039. /// 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.
  20040. /// </summary>
  20041. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20042. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20043. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20044. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20045. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20046. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20047. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20048. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20049. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20050. /// <param name="function">Function to convert to an asynchronous function.</param>
  20051. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20052. /// <returns>Asynchronous function.</returns>
  20053. /// <exception cref="T:System.ArgumentNullException">
  20054. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20055. 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)
  20056. {
  20057. if (provider == null)
  20058. throw new ArgumentNullException("provider");
  20059. if (function == null)
  20060. throw new ArgumentNullException("function");
  20061. if (scheduler == null)
  20062. throw new ArgumentNullException("scheduler");
  20063. #if CRIPPLED_REFLECTION
  20064. 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)));
  20065. #else
  20066. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TResult));
  20067. #endif
  20068. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<TResult>(
  20069. Expression.Invoke(
  20070. Expression.Call(
  20071. null,
  20072. m,
  20073. Expression.Constant(provider, typeof(IQbservableProvider)),
  20074. function,
  20075. Expression.Constant(scheduler, typeof(IScheduler))
  20076. ),
  20077. Expression.Constant(t1, typeof(TArg1)),
  20078. Expression.Constant(t2, typeof(TArg2)),
  20079. Expression.Constant(t3, typeof(TArg3)),
  20080. Expression.Constant(t4, typeof(TArg4)),
  20081. Expression.Constant(t5, typeof(TArg5)),
  20082. Expression.Constant(t6, typeof(TArg6)),
  20083. Expression.Constant(t7, typeof(TArg7))
  20084. )
  20085. );
  20086. }
  20087. /// <summary>
  20088. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20089. /// </summary>
  20090. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20091. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20092. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20093. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20094. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20095. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20096. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20097. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20098. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20099. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20100. /// <param name="function">Function to convert to an asynchronous function.</param>
  20101. /// <returns>Asynchronous function.</returns>
  20102. /// <exception cref="T:System.ArgumentNullException">
  20103. /// <paramref name="function" /> is null.</exception>
  20104. 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)
  20105. {
  20106. if (provider == null)
  20107. throw new ArgumentNullException("provider");
  20108. if (function == null)
  20109. throw new ArgumentNullException("function");
  20110. #if CRIPPLED_REFLECTION
  20111. 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>>)));
  20112. #else
  20113. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TResult));
  20114. #endif
  20115. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<TResult>(
  20116. Expression.Invoke(
  20117. Expression.Call(
  20118. null,
  20119. m,
  20120. Expression.Constant(provider, typeof(IQbservableProvider)),
  20121. function
  20122. ),
  20123. Expression.Constant(t1, typeof(TArg1)),
  20124. Expression.Constant(t2, typeof(TArg2)),
  20125. Expression.Constant(t3, typeof(TArg3)),
  20126. Expression.Constant(t4, typeof(TArg4)),
  20127. Expression.Constant(t5, typeof(TArg5)),
  20128. Expression.Constant(t6, typeof(TArg6)),
  20129. Expression.Constant(t7, typeof(TArg7)),
  20130. Expression.Constant(t8, typeof(TArg8))
  20131. )
  20132. );
  20133. }
  20134. /// <summary>
  20135. /// 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.
  20136. /// </summary>
  20137. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20138. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20139. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20140. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20141. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20142. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20143. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20144. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20145. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20146. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20147. /// <param name="function">Function to convert to an asynchronous function.</param>
  20148. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20149. /// <returns>Asynchronous function.</returns>
  20150. /// <exception cref="T:System.ArgumentNullException">
  20151. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20152. 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)
  20153. {
  20154. if (provider == null)
  20155. throw new ArgumentNullException("provider");
  20156. if (function == null)
  20157. throw new ArgumentNullException("function");
  20158. if (scheduler == null)
  20159. throw new ArgumentNullException("scheduler");
  20160. #if CRIPPLED_REFLECTION
  20161. 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)));
  20162. #else
  20163. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TResult));
  20164. #endif
  20165. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<TResult>(
  20166. Expression.Invoke(
  20167. Expression.Call(
  20168. null,
  20169. m,
  20170. Expression.Constant(provider, typeof(IQbservableProvider)),
  20171. function,
  20172. Expression.Constant(scheduler, typeof(IScheduler))
  20173. ),
  20174. Expression.Constant(t1, typeof(TArg1)),
  20175. Expression.Constant(t2, typeof(TArg2)),
  20176. Expression.Constant(t3, typeof(TArg3)),
  20177. Expression.Constant(t4, typeof(TArg4)),
  20178. Expression.Constant(t5, typeof(TArg5)),
  20179. Expression.Constant(t6, typeof(TArg6)),
  20180. Expression.Constant(t7, typeof(TArg7)),
  20181. Expression.Constant(t8, typeof(TArg8))
  20182. )
  20183. );
  20184. }
  20185. /// <summary>
  20186. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20187. /// </summary>
  20188. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20189. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20190. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20191. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20192. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20193. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20194. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20195. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20196. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20197. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20198. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20199. /// <param name="function">Function to convert to an asynchronous function.</param>
  20200. /// <returns>Asynchronous function.</returns>
  20201. /// <exception cref="T:System.ArgumentNullException">
  20202. /// <paramref name="function" /> is null.</exception>
  20203. 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)
  20204. {
  20205. if (provider == null)
  20206. throw new ArgumentNullException("provider");
  20207. if (function == null)
  20208. throw new ArgumentNullException("function");
  20209. #if CRIPPLED_REFLECTION
  20210. 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>>)));
  20211. #else
  20212. 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));
  20213. #endif
  20214. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<TResult>(
  20215. Expression.Invoke(
  20216. Expression.Call(
  20217. null,
  20218. m,
  20219. Expression.Constant(provider, typeof(IQbservableProvider)),
  20220. function
  20221. ),
  20222. Expression.Constant(t1, typeof(TArg1)),
  20223. Expression.Constant(t2, typeof(TArg2)),
  20224. Expression.Constant(t3, typeof(TArg3)),
  20225. Expression.Constant(t4, typeof(TArg4)),
  20226. Expression.Constant(t5, typeof(TArg5)),
  20227. Expression.Constant(t6, typeof(TArg6)),
  20228. Expression.Constant(t7, typeof(TArg7)),
  20229. Expression.Constant(t8, typeof(TArg8)),
  20230. Expression.Constant(t9, typeof(TArg9))
  20231. )
  20232. );
  20233. }
  20234. /// <summary>
  20235. /// 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.
  20236. /// </summary>
  20237. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20238. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20239. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20240. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20241. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20242. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20243. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20244. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20245. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20246. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20247. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20248. /// <param name="function">Function to convert to an asynchronous function.</param>
  20249. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20250. /// <returns>Asynchronous function.</returns>
  20251. /// <exception cref="T:System.ArgumentNullException">
  20252. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20253. 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)
  20254. {
  20255. if (provider == null)
  20256. throw new ArgumentNullException("provider");
  20257. if (function == null)
  20258. throw new ArgumentNullException("function");
  20259. if (scheduler == null)
  20260. throw new ArgumentNullException("scheduler");
  20261. #if CRIPPLED_REFLECTION
  20262. 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)));
  20263. #else
  20264. 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));
  20265. #endif
  20266. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<TResult>(
  20267. Expression.Invoke(
  20268. Expression.Call(
  20269. null,
  20270. m,
  20271. Expression.Constant(provider, typeof(IQbservableProvider)),
  20272. function,
  20273. Expression.Constant(scheduler, typeof(IScheduler))
  20274. ),
  20275. Expression.Constant(t1, typeof(TArg1)),
  20276. Expression.Constant(t2, typeof(TArg2)),
  20277. Expression.Constant(t3, typeof(TArg3)),
  20278. Expression.Constant(t4, typeof(TArg4)),
  20279. Expression.Constant(t5, typeof(TArg5)),
  20280. Expression.Constant(t6, typeof(TArg6)),
  20281. Expression.Constant(t7, typeof(TArg7)),
  20282. Expression.Constant(t8, typeof(TArg8)),
  20283. Expression.Constant(t9, typeof(TArg9))
  20284. )
  20285. );
  20286. }
  20287. /// <summary>
  20288. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20289. /// </summary>
  20290. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20291. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20292. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20293. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20294. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20295. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20296. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20297. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20298. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20299. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20300. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20301. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20302. /// <param name="function">Function to convert to an asynchronous function.</param>
  20303. /// <returns>Asynchronous function.</returns>
  20304. /// <exception cref="T:System.ArgumentNullException">
  20305. /// <paramref name="function" /> is null.</exception>
  20306. 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)
  20307. {
  20308. if (provider == null)
  20309. throw new ArgumentNullException("provider");
  20310. if (function == null)
  20311. throw new ArgumentNullException("function");
  20312. #if CRIPPLED_REFLECTION
  20313. 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>>)));
  20314. #else
  20315. 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));
  20316. #endif
  20317. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<TResult>(
  20318. Expression.Invoke(
  20319. Expression.Call(
  20320. null,
  20321. m,
  20322. Expression.Constant(provider, typeof(IQbservableProvider)),
  20323. function
  20324. ),
  20325. Expression.Constant(t1, typeof(TArg1)),
  20326. Expression.Constant(t2, typeof(TArg2)),
  20327. Expression.Constant(t3, typeof(TArg3)),
  20328. Expression.Constant(t4, typeof(TArg4)),
  20329. Expression.Constant(t5, typeof(TArg5)),
  20330. Expression.Constant(t6, typeof(TArg6)),
  20331. Expression.Constant(t7, typeof(TArg7)),
  20332. Expression.Constant(t8, typeof(TArg8)),
  20333. Expression.Constant(t9, typeof(TArg9)),
  20334. Expression.Constant(t10, typeof(TArg10))
  20335. )
  20336. );
  20337. }
  20338. /// <summary>
  20339. /// 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.
  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 function.</typeparam>
  20343. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20344. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20345. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20346. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20347. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20348. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20349. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20350. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20351. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20352. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20353. /// <param name="function">Function to convert to an asynchronous function.</param>
  20354. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20355. /// <returns>Asynchronous function.</returns>
  20356. /// <exception cref="T:System.ArgumentNullException">
  20357. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20358. 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)
  20359. {
  20360. if (provider == null)
  20361. throw new ArgumentNullException("provider");
  20362. if (function == null)
  20363. throw new ArgumentNullException("function");
  20364. if (scheduler == null)
  20365. throw new ArgumentNullException("scheduler");
  20366. #if CRIPPLED_REFLECTION
  20367. 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)));
  20368. #else
  20369. 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));
  20370. #endif
  20371. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<TResult>(
  20372. Expression.Invoke(
  20373. Expression.Call(
  20374. null,
  20375. m,
  20376. Expression.Constant(provider, typeof(IQbservableProvider)),
  20377. function,
  20378. Expression.Constant(scheduler, typeof(IScheduler))
  20379. ),
  20380. Expression.Constant(t1, typeof(TArg1)),
  20381. Expression.Constant(t2, typeof(TArg2)),
  20382. Expression.Constant(t3, typeof(TArg3)),
  20383. Expression.Constant(t4, typeof(TArg4)),
  20384. Expression.Constant(t5, typeof(TArg5)),
  20385. Expression.Constant(t6, typeof(TArg6)),
  20386. Expression.Constant(t7, typeof(TArg7)),
  20387. Expression.Constant(t8, typeof(TArg8)),
  20388. Expression.Constant(t9, typeof(TArg9)),
  20389. Expression.Constant(t10, typeof(TArg10))
  20390. )
  20391. );
  20392. }
  20393. /// <summary>
  20394. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20395. /// </summary>
  20396. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20397. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20398. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20399. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20400. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20401. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20402. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20403. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20404. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20405. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20406. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20407. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20408. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20409. /// <param name="function">Function to convert to an asynchronous function.</param>
  20410. /// <returns>Asynchronous function.</returns>
  20411. /// <exception cref="T:System.ArgumentNullException">
  20412. /// <paramref name="function" /> is null.</exception>
  20413. 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)
  20414. {
  20415. if (provider == null)
  20416. throw new ArgumentNullException("provider");
  20417. if (function == null)
  20418. throw new ArgumentNullException("function");
  20419. #if CRIPPLED_REFLECTION
  20420. 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>>)));
  20421. #else
  20422. 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));
  20423. #endif
  20424. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<TResult>(
  20425. Expression.Invoke(
  20426. Expression.Call(
  20427. null,
  20428. m,
  20429. Expression.Constant(provider, typeof(IQbservableProvider)),
  20430. function
  20431. ),
  20432. Expression.Constant(t1, typeof(TArg1)),
  20433. Expression.Constant(t2, typeof(TArg2)),
  20434. Expression.Constant(t3, typeof(TArg3)),
  20435. Expression.Constant(t4, typeof(TArg4)),
  20436. Expression.Constant(t5, typeof(TArg5)),
  20437. Expression.Constant(t6, typeof(TArg6)),
  20438. Expression.Constant(t7, typeof(TArg7)),
  20439. Expression.Constant(t8, typeof(TArg8)),
  20440. Expression.Constant(t9, typeof(TArg9)),
  20441. Expression.Constant(t10, typeof(TArg10)),
  20442. Expression.Constant(t11, typeof(TArg11))
  20443. )
  20444. );
  20445. }
  20446. /// <summary>
  20447. /// 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.
  20448. /// </summary>
  20449. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20450. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20451. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20452. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20453. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20454. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20455. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20456. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20457. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20458. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20459. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20460. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20461. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20462. /// <param name="function">Function to convert to an asynchronous function.</param>
  20463. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20464. /// <returns>Asynchronous function.</returns>
  20465. /// <exception cref="T:System.ArgumentNullException">
  20466. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20467. 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)
  20468. {
  20469. if (provider == null)
  20470. throw new ArgumentNullException("provider");
  20471. if (function == null)
  20472. throw new ArgumentNullException("function");
  20473. if (scheduler == null)
  20474. throw new ArgumentNullException("scheduler");
  20475. #if CRIPPLED_REFLECTION
  20476. 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)));
  20477. #else
  20478. 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));
  20479. #endif
  20480. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<TResult>(
  20481. Expression.Invoke(
  20482. Expression.Call(
  20483. null,
  20484. m,
  20485. Expression.Constant(provider, typeof(IQbservableProvider)),
  20486. function,
  20487. Expression.Constant(scheduler, typeof(IScheduler))
  20488. ),
  20489. Expression.Constant(t1, typeof(TArg1)),
  20490. Expression.Constant(t2, typeof(TArg2)),
  20491. Expression.Constant(t3, typeof(TArg3)),
  20492. Expression.Constant(t4, typeof(TArg4)),
  20493. Expression.Constant(t5, typeof(TArg5)),
  20494. Expression.Constant(t6, typeof(TArg6)),
  20495. Expression.Constant(t7, typeof(TArg7)),
  20496. Expression.Constant(t8, typeof(TArg8)),
  20497. Expression.Constant(t9, typeof(TArg9)),
  20498. Expression.Constant(t10, typeof(TArg10)),
  20499. Expression.Constant(t11, typeof(TArg11))
  20500. )
  20501. );
  20502. }
  20503. /// <summary>
  20504. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20505. /// </summary>
  20506. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20507. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20508. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20509. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20510. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20511. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20512. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20513. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20514. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20515. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20516. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20517. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20518. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20519. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20520. /// <param name="function">Function to convert to an asynchronous function.</param>
  20521. /// <returns>Asynchronous function.</returns>
  20522. /// <exception cref="T:System.ArgumentNullException">
  20523. /// <paramref name="function" /> is null.</exception>
  20524. 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)
  20525. {
  20526. if (provider == null)
  20527. throw new ArgumentNullException("provider");
  20528. if (function == null)
  20529. throw new ArgumentNullException("function");
  20530. #if CRIPPLED_REFLECTION
  20531. 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>>)));
  20532. #else
  20533. 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));
  20534. #endif
  20535. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<TResult>(
  20536. Expression.Invoke(
  20537. Expression.Call(
  20538. null,
  20539. m,
  20540. Expression.Constant(provider, typeof(IQbservableProvider)),
  20541. function
  20542. ),
  20543. Expression.Constant(t1, typeof(TArg1)),
  20544. Expression.Constant(t2, typeof(TArg2)),
  20545. Expression.Constant(t3, typeof(TArg3)),
  20546. Expression.Constant(t4, typeof(TArg4)),
  20547. Expression.Constant(t5, typeof(TArg5)),
  20548. Expression.Constant(t6, typeof(TArg6)),
  20549. Expression.Constant(t7, typeof(TArg7)),
  20550. Expression.Constant(t8, typeof(TArg8)),
  20551. Expression.Constant(t9, typeof(TArg9)),
  20552. Expression.Constant(t10, typeof(TArg10)),
  20553. Expression.Constant(t11, typeof(TArg11)),
  20554. Expression.Constant(t12, typeof(TArg12))
  20555. )
  20556. );
  20557. }
  20558. /// <summary>
  20559. /// 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.
  20560. /// </summary>
  20561. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20562. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20563. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20564. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20565. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20566. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20567. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20568. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20569. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20570. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20571. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20572. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20573. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20574. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20575. /// <param name="function">Function to convert to an asynchronous function.</param>
  20576. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20577. /// <returns>Asynchronous function.</returns>
  20578. /// <exception cref="T:System.ArgumentNullException">
  20579. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20580. 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)
  20581. {
  20582. if (provider == null)
  20583. throw new ArgumentNullException("provider");
  20584. if (function == null)
  20585. throw new ArgumentNullException("function");
  20586. if (scheduler == null)
  20587. throw new ArgumentNullException("scheduler");
  20588. #if CRIPPLED_REFLECTION
  20589. 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)));
  20590. #else
  20591. 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));
  20592. #endif
  20593. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<TResult>(
  20594. Expression.Invoke(
  20595. Expression.Call(
  20596. null,
  20597. m,
  20598. Expression.Constant(provider, typeof(IQbservableProvider)),
  20599. function,
  20600. Expression.Constant(scheduler, typeof(IScheduler))
  20601. ),
  20602. Expression.Constant(t1, typeof(TArg1)),
  20603. Expression.Constant(t2, typeof(TArg2)),
  20604. Expression.Constant(t3, typeof(TArg3)),
  20605. Expression.Constant(t4, typeof(TArg4)),
  20606. Expression.Constant(t5, typeof(TArg5)),
  20607. Expression.Constant(t6, typeof(TArg6)),
  20608. Expression.Constant(t7, typeof(TArg7)),
  20609. Expression.Constant(t8, typeof(TArg8)),
  20610. Expression.Constant(t9, typeof(TArg9)),
  20611. Expression.Constant(t10, typeof(TArg10)),
  20612. Expression.Constant(t11, typeof(TArg11)),
  20613. Expression.Constant(t12, typeof(TArg12))
  20614. )
  20615. );
  20616. }
  20617. /// <summary>
  20618. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20619. /// </summary>
  20620. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20621. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20622. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20623. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20624. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20625. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20626. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20627. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20628. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20629. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20630. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20631. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20632. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20633. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20634. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20635. /// <param name="function">Function to convert to an asynchronous function.</param>
  20636. /// <returns>Asynchronous function.</returns>
  20637. /// <exception cref="T:System.ArgumentNullException">
  20638. /// <paramref name="function" /> is null.</exception>
  20639. 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)
  20640. {
  20641. if (provider == null)
  20642. throw new ArgumentNullException("provider");
  20643. if (function == null)
  20644. throw new ArgumentNullException("function");
  20645. #if CRIPPLED_REFLECTION
  20646. 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>>)));
  20647. #else
  20648. 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));
  20649. #endif
  20650. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<TResult>(
  20651. Expression.Invoke(
  20652. Expression.Call(
  20653. null,
  20654. m,
  20655. Expression.Constant(provider, typeof(IQbservableProvider)),
  20656. function
  20657. ),
  20658. Expression.Constant(t1, typeof(TArg1)),
  20659. Expression.Constant(t2, typeof(TArg2)),
  20660. Expression.Constant(t3, typeof(TArg3)),
  20661. Expression.Constant(t4, typeof(TArg4)),
  20662. Expression.Constant(t5, typeof(TArg5)),
  20663. Expression.Constant(t6, typeof(TArg6)),
  20664. Expression.Constant(t7, typeof(TArg7)),
  20665. Expression.Constant(t8, typeof(TArg8)),
  20666. Expression.Constant(t9, typeof(TArg9)),
  20667. Expression.Constant(t10, typeof(TArg10)),
  20668. Expression.Constant(t11, typeof(TArg11)),
  20669. Expression.Constant(t12, typeof(TArg12)),
  20670. Expression.Constant(t13, typeof(TArg13))
  20671. )
  20672. );
  20673. }
  20674. /// <summary>
  20675. /// 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.
  20676. /// </summary>
  20677. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20678. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20679. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20680. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20681. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20682. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20683. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20684. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20685. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20686. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20687. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20688. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20689. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20690. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20691. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20692. /// <param name="function">Function to convert to an asynchronous function.</param>
  20693. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20694. /// <returns>Asynchronous function.</returns>
  20695. /// <exception cref="T:System.ArgumentNullException">
  20696. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20697. 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)
  20698. {
  20699. if (provider == null)
  20700. throw new ArgumentNullException("provider");
  20701. if (function == null)
  20702. throw new ArgumentNullException("function");
  20703. if (scheduler == null)
  20704. throw new ArgumentNullException("scheduler");
  20705. #if CRIPPLED_REFLECTION
  20706. 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)));
  20707. #else
  20708. 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));
  20709. #endif
  20710. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<TResult>(
  20711. Expression.Invoke(
  20712. Expression.Call(
  20713. null,
  20714. m,
  20715. Expression.Constant(provider, typeof(IQbservableProvider)),
  20716. function,
  20717. Expression.Constant(scheduler, typeof(IScheduler))
  20718. ),
  20719. Expression.Constant(t1, typeof(TArg1)),
  20720. Expression.Constant(t2, typeof(TArg2)),
  20721. Expression.Constant(t3, typeof(TArg3)),
  20722. Expression.Constant(t4, typeof(TArg4)),
  20723. Expression.Constant(t5, typeof(TArg5)),
  20724. Expression.Constant(t6, typeof(TArg6)),
  20725. Expression.Constant(t7, typeof(TArg7)),
  20726. Expression.Constant(t8, typeof(TArg8)),
  20727. Expression.Constant(t9, typeof(TArg9)),
  20728. Expression.Constant(t10, typeof(TArg10)),
  20729. Expression.Constant(t11, typeof(TArg11)),
  20730. Expression.Constant(t12, typeof(TArg12)),
  20731. Expression.Constant(t13, typeof(TArg13))
  20732. )
  20733. );
  20734. }
  20735. /// <summary>
  20736. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20737. /// </summary>
  20738. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20739. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20740. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20741. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20742. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20743. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20744. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20745. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20746. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20747. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20748. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20749. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20750. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20751. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20752. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20753. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20754. /// <param name="function">Function to convert to an asynchronous function.</param>
  20755. /// <returns>Asynchronous function.</returns>
  20756. /// <exception cref="T:System.ArgumentNullException">
  20757. /// <paramref name="function" /> is null.</exception>
  20758. 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)
  20759. {
  20760. if (provider == null)
  20761. throw new ArgumentNullException("provider");
  20762. if (function == null)
  20763. throw new ArgumentNullException("function");
  20764. #if CRIPPLED_REFLECTION
  20765. 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>>)));
  20766. #else
  20767. 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));
  20768. #endif
  20769. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<TResult>(
  20770. Expression.Invoke(
  20771. Expression.Call(
  20772. null,
  20773. m,
  20774. Expression.Constant(provider, typeof(IQbservableProvider)),
  20775. function
  20776. ),
  20777. Expression.Constant(t1, typeof(TArg1)),
  20778. Expression.Constant(t2, typeof(TArg2)),
  20779. Expression.Constant(t3, typeof(TArg3)),
  20780. Expression.Constant(t4, typeof(TArg4)),
  20781. Expression.Constant(t5, typeof(TArg5)),
  20782. Expression.Constant(t6, typeof(TArg6)),
  20783. Expression.Constant(t7, typeof(TArg7)),
  20784. Expression.Constant(t8, typeof(TArg8)),
  20785. Expression.Constant(t9, typeof(TArg9)),
  20786. Expression.Constant(t10, typeof(TArg10)),
  20787. Expression.Constant(t11, typeof(TArg11)),
  20788. Expression.Constant(t12, typeof(TArg12)),
  20789. Expression.Constant(t13, typeof(TArg13)),
  20790. Expression.Constant(t14, typeof(TArg14))
  20791. )
  20792. );
  20793. }
  20794. /// <summary>
  20795. /// 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.
  20796. /// </summary>
  20797. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20798. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20799. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20800. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20801. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20802. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20803. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20804. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20805. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20806. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20807. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20808. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20809. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20810. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20811. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20812. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20813. /// <param name="function">Function to convert to an asynchronous function.</param>
  20814. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20815. /// <returns>Asynchronous function.</returns>
  20816. /// <exception cref="T:System.ArgumentNullException">
  20817. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20818. 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)
  20819. {
  20820. if (provider == null)
  20821. throw new ArgumentNullException("provider");
  20822. if (function == null)
  20823. throw new ArgumentNullException("function");
  20824. if (scheduler == null)
  20825. throw new ArgumentNullException("scheduler");
  20826. #if CRIPPLED_REFLECTION
  20827. 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)));
  20828. #else
  20829. 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));
  20830. #endif
  20831. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<TResult>(
  20832. Expression.Invoke(
  20833. Expression.Call(
  20834. null,
  20835. m,
  20836. Expression.Constant(provider, typeof(IQbservableProvider)),
  20837. function,
  20838. Expression.Constant(scheduler, typeof(IScheduler))
  20839. ),
  20840. Expression.Constant(t1, typeof(TArg1)),
  20841. Expression.Constant(t2, typeof(TArg2)),
  20842. Expression.Constant(t3, typeof(TArg3)),
  20843. Expression.Constant(t4, typeof(TArg4)),
  20844. Expression.Constant(t5, typeof(TArg5)),
  20845. Expression.Constant(t6, typeof(TArg6)),
  20846. Expression.Constant(t7, typeof(TArg7)),
  20847. Expression.Constant(t8, typeof(TArg8)),
  20848. Expression.Constant(t9, typeof(TArg9)),
  20849. Expression.Constant(t10, typeof(TArg10)),
  20850. Expression.Constant(t11, typeof(TArg11)),
  20851. Expression.Constant(t12, typeof(TArg12)),
  20852. Expression.Constant(t13, typeof(TArg13)),
  20853. Expression.Constant(t14, typeof(TArg14))
  20854. )
  20855. );
  20856. }
  20857. /// <summary>
  20858. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20859. /// </summary>
  20860. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20861. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20862. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20863. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20864. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20865. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20866. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20867. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20868. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20869. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20870. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20871. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20872. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20873. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20874. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20875. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the function.</typeparam>
  20876. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20877. /// <param name="function">Function to convert to an asynchronous function.</param>
  20878. /// <returns>Asynchronous function.</returns>
  20879. /// <exception cref="T:System.ArgumentNullException">
  20880. /// <paramref name="function" /> is null.</exception>
  20881. 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)
  20882. {
  20883. if (provider == null)
  20884. throw new ArgumentNullException("provider");
  20885. if (function == null)
  20886. throw new ArgumentNullException("function");
  20887. #if CRIPPLED_REFLECTION
  20888. 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>>)));
  20889. #else
  20890. 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));
  20891. #endif
  20892. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) => provider.CreateQuery<TResult>(
  20893. Expression.Invoke(
  20894. Expression.Call(
  20895. null,
  20896. m,
  20897. Expression.Constant(provider, typeof(IQbservableProvider)),
  20898. function
  20899. ),
  20900. Expression.Constant(t1, typeof(TArg1)),
  20901. Expression.Constant(t2, typeof(TArg2)),
  20902. Expression.Constant(t3, typeof(TArg3)),
  20903. Expression.Constant(t4, typeof(TArg4)),
  20904. Expression.Constant(t5, typeof(TArg5)),
  20905. Expression.Constant(t6, typeof(TArg6)),
  20906. Expression.Constant(t7, typeof(TArg7)),
  20907. Expression.Constant(t8, typeof(TArg8)),
  20908. Expression.Constant(t9, typeof(TArg9)),
  20909. Expression.Constant(t10, typeof(TArg10)),
  20910. Expression.Constant(t11, typeof(TArg11)),
  20911. Expression.Constant(t12, typeof(TArg12)),
  20912. Expression.Constant(t13, typeof(TArg13)),
  20913. Expression.Constant(t14, typeof(TArg14)),
  20914. Expression.Constant(t15, typeof(TArg15))
  20915. )
  20916. );
  20917. }
  20918. /// <summary>
  20919. /// 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.
  20920. /// </summary>
  20921. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20922. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20923. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20924. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20925. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20926. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20927. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20928. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20929. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20930. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20931. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20932. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20933. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20934. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20935. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20936. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the function.</typeparam>
  20937. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20938. /// <param name="function">Function to convert to an asynchronous function.</param>
  20939. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20940. /// <returns>Asynchronous function.</returns>
  20941. /// <exception cref="T:System.ArgumentNullException">
  20942. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20943. 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)
  20944. {
  20945. if (provider == null)
  20946. throw new ArgumentNullException("provider");
  20947. if (function == null)
  20948. throw new ArgumentNullException("function");
  20949. if (scheduler == null)
  20950. throw new ArgumentNullException("scheduler");
  20951. #if CRIPPLED_REFLECTION
  20952. 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)));
  20953. #else
  20954. 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));
  20955. #endif
  20956. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) => provider.CreateQuery<TResult>(
  20957. Expression.Invoke(
  20958. Expression.Call(
  20959. null,
  20960. m,
  20961. Expression.Constant(provider, typeof(IQbservableProvider)),
  20962. function,
  20963. Expression.Constant(scheduler, typeof(IScheduler))
  20964. ),
  20965. Expression.Constant(t1, typeof(TArg1)),
  20966. Expression.Constant(t2, typeof(TArg2)),
  20967. Expression.Constant(t3, typeof(TArg3)),
  20968. Expression.Constant(t4, typeof(TArg4)),
  20969. Expression.Constant(t5, typeof(TArg5)),
  20970. Expression.Constant(t6, typeof(TArg6)),
  20971. Expression.Constant(t7, typeof(TArg7)),
  20972. Expression.Constant(t8, typeof(TArg8)),
  20973. Expression.Constant(t9, typeof(TArg9)),
  20974. Expression.Constant(t10, typeof(TArg10)),
  20975. Expression.Constant(t11, typeof(TArg11)),
  20976. Expression.Constant(t12, typeof(TArg12)),
  20977. Expression.Constant(t13, typeof(TArg13)),
  20978. Expression.Constant(t14, typeof(TArg14)),
  20979. Expression.Constant(t15, typeof(TArg15))
  20980. )
  20981. );
  20982. }
  20983. /// <summary>
  20984. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20985. /// </summary>
  20986. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20987. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20988. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20989. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20990. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20991. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20992. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20993. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20994. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20995. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20996. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20997. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20998. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20999. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  21000. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  21001. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the function.</typeparam>
  21002. /// <typeparam name="TArg16">The type of the sixteenth argument passed to the function.</typeparam>
  21003. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  21004. /// <param name="function">Function to convert to an asynchronous function.</param>
  21005. /// <returns>Asynchronous function.</returns>
  21006. /// <exception cref="T:System.ArgumentNullException">
  21007. /// <paramref name="function" /> is null.</exception>
  21008. 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)
  21009. {
  21010. if (provider == null)
  21011. throw new ArgumentNullException("provider");
  21012. if (function == null)
  21013. throw new ArgumentNullException("function");
  21014. #if CRIPPLED_REFLECTION
  21015. 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>>)));
  21016. #else
  21017. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10), typeof(TArg11), typeof(TArg12), typeof(TArg13), typeof(TArg14), typeof(TArg15), typeof(TArg16), typeof(TResult));
  21018. #endif
  21019. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) => provider.CreateQuery<TResult>(
  21020. Expression.Invoke(
  21021. Expression.Call(
  21022. null,
  21023. m,
  21024. Expression.Constant(provider, typeof(IQbservableProvider)),
  21025. function
  21026. ),
  21027. Expression.Constant(t1, typeof(TArg1)),
  21028. Expression.Constant(t2, typeof(TArg2)),
  21029. Expression.Constant(t3, typeof(TArg3)),
  21030. Expression.Constant(t4, typeof(TArg4)),
  21031. Expression.Constant(t5, typeof(TArg5)),
  21032. Expression.Constant(t6, typeof(TArg6)),
  21033. Expression.Constant(t7, typeof(TArg7)),
  21034. Expression.Constant(t8, typeof(TArg8)),
  21035. Expression.Constant(t9, typeof(TArg9)),
  21036. Expression.Constant(t10, typeof(TArg10)),
  21037. Expression.Constant(t11, typeof(TArg11)),
  21038. Expression.Constant(t12, typeof(TArg12)),
  21039. Expression.Constant(t13, typeof(TArg13)),
  21040. Expression.Constant(t14, typeof(TArg14)),
  21041. Expression.Constant(t15, typeof(TArg15)),
  21042. Expression.Constant(t16, typeof(TArg16))
  21043. )
  21044. );
  21045. }
  21046. /// <summary>
  21047. /// 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.
  21048. /// </summary>
  21049. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21050. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  21051. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  21052. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  21053. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  21054. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  21055. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  21056. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  21057. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  21058. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  21059. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  21060. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  21061. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  21062. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  21063. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  21064. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the function.</typeparam>
  21065. /// <typeparam name="TArg16">The type of the sixteenth argument passed to the function.</typeparam>
  21066. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  21067. /// <param name="function">Function to convert to an asynchronous function.</param>
  21068. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  21069. /// <returns>Asynchronous function.</returns>
  21070. /// <exception cref="T:System.ArgumentNullException">
  21071. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  21072. 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)
  21073. {
  21074. if (provider == null)
  21075. throw new ArgumentNullException("provider");
  21076. if (function == null)
  21077. throw new ArgumentNullException("function");
  21078. if (scheduler == null)
  21079. throw new ArgumentNullException("scheduler");
  21080. #if CRIPPLED_REFLECTION
  21081. 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)));
  21082. #else
  21083. 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));
  21084. #endif
  21085. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) => provider.CreateQuery<TResult>(
  21086. Expression.Invoke(
  21087. Expression.Call(
  21088. null,
  21089. m,
  21090. Expression.Constant(provider, typeof(IQbservableProvider)),
  21091. function,
  21092. Expression.Constant(scheduler, typeof(IScheduler))
  21093. ),
  21094. Expression.Constant(t1, typeof(TArg1)),
  21095. Expression.Constant(t2, typeof(TArg2)),
  21096. Expression.Constant(t3, typeof(TArg3)),
  21097. Expression.Constant(t4, typeof(TArg4)),
  21098. Expression.Constant(t5, typeof(TArg5)),
  21099. Expression.Constant(t6, typeof(TArg6)),
  21100. Expression.Constant(t7, typeof(TArg7)),
  21101. Expression.Constant(t8, typeof(TArg8)),
  21102. Expression.Constant(t9, typeof(TArg9)),
  21103. Expression.Constant(t10, typeof(TArg10)),
  21104. Expression.Constant(t11, typeof(TArg11)),
  21105. Expression.Constant(t12, typeof(TArg12)),
  21106. Expression.Constant(t13, typeof(TArg13)),
  21107. Expression.Constant(t14, typeof(TArg14)),
  21108. Expression.Constant(t15, typeof(TArg15)),
  21109. Expression.Constant(t16, typeof(TArg16))
  21110. )
  21111. );
  21112. }
  21113. #endif
  21114. /// <summary>
  21115. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21116. /// </summary>
  21117. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21118. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21119. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21120. /// <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>
  21121. /// <exception cref="T:System.ArgumentNullException">
  21122. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21123. /// <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>
  21124. #if PREFERASYNC
  21125. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21126. #endif
  21127. public static Func<IQbservable<Unit>> FromAsyncPattern(this IQbservableProvider provider, Expression<Func<AsyncCallback, object, IAsyncResult>> begin, Expression<Action<IAsyncResult>>end)
  21128. {
  21129. if (provider == null)
  21130. throw new ArgumentNullException("provider");
  21131. if (begin == null)
  21132. throw new ArgumentNullException("begin");
  21133. if (end == null)
  21134. throw new ArgumentNullException("end");
  21135. #if CRIPPLED_REFLECTION
  21136. var m = InfoOf(() => Qbservable.FromAsyncPattern(default(IQbservableProvider), default(Expression<Func<AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  21137. #else
  21138. var m = (MethodInfo)MethodInfo.GetCurrentMethod();
  21139. #endif
  21140. return () => provider.CreateQuery<Unit>(
  21141. Expression.Invoke(
  21142. Expression.Call(
  21143. null,
  21144. m,
  21145. Expression.Constant(provider, typeof(IQbservableProvider)),
  21146. begin,
  21147. end
  21148. )
  21149. )
  21150. );
  21151. }
  21152. /// <summary>
  21153. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21154. /// </summary>
  21155. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21156. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21157. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21158. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21159. /// <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>
  21160. /// <exception cref="T:System.ArgumentNullException">
  21161. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21162. /// <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>
  21163. #if PREFERASYNC
  21164. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21165. #endif
  21166. public static Func<TArg1, IQbservable<Unit>> FromAsyncPattern<TArg1>(this IQbservableProvider provider, Expression<Func<TArg1, AsyncCallback, object, IAsyncResult>> begin, Expression<Action<IAsyncResult>>end)
  21167. {
  21168. if (provider == null)
  21169. throw new ArgumentNullException("provider");
  21170. if (begin == null)
  21171. throw new ArgumentNullException("begin");
  21172. if (end == null)
  21173. throw new ArgumentNullException("end");
  21174. #if CRIPPLED_REFLECTION
  21175. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1>(default(IQbservableProvider), default(Expression<Func<TArg1, AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  21176. #else
  21177. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1));
  21178. #endif
  21179. return (t1) => provider.CreateQuery<Unit>(
  21180. Expression.Invoke(
  21181. Expression.Call(
  21182. null,
  21183. m,
  21184. Expression.Constant(provider, typeof(IQbservableProvider)),
  21185. begin,
  21186. end
  21187. ),
  21188. Expression.Constant(t1, typeof(TArg1))
  21189. )
  21190. );
  21191. }
  21192. /// <summary>
  21193. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21194. /// </summary>
  21195. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21196. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21197. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21198. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21199. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21200. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result (represented as a Unit value) as an observable sequence.</returns>
  21201. /// <exception cref="T:System.ArgumentNullException">
  21202. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21203. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  21204. #if PREFERASYNC
  21205. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21206. #endif
  21207. public static Func<TArg1, TArg2, IQbservable<Unit>> FromAsyncPattern<TArg1, TArg2>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, AsyncCallback, object, IAsyncResult>> begin, Expression<Action<IAsyncResult>>end)
  21208. {
  21209. if (provider == null)
  21210. throw new ArgumentNullException("provider");
  21211. if (begin == null)
  21212. throw new ArgumentNullException("begin");
  21213. if (end == null)
  21214. throw new ArgumentNullException("end");
  21215. #if CRIPPLED_REFLECTION
  21216. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  21217. #else
  21218. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2));
  21219. #endif
  21220. return (t1, t2) => provider.CreateQuery<Unit>(
  21221. Expression.Invoke(
  21222. Expression.Call(
  21223. null,
  21224. m,
  21225. Expression.Constant(provider, typeof(IQbservableProvider)),
  21226. begin,
  21227. end
  21228. ),
  21229. Expression.Constant(t1, typeof(TArg1)),
  21230. Expression.Constant(t2, typeof(TArg2))
  21231. )
  21232. );
  21233. }
  21234. #if !NO_LARGEARITY
  21235. /// <summary>
  21236. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21237. /// </summary>
  21238. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21239. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21240. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21241. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21242. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21243. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21244. /// <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>
  21245. /// <exception cref="T:System.ArgumentNullException">
  21246. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21247. /// <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>
  21248. #if PREFERASYNC
  21249. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21250. #endif
  21251. 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)
  21252. {
  21253. if (provider == null)
  21254. throw new ArgumentNullException("provider");
  21255. if (begin == null)
  21256. throw new ArgumentNullException("begin");
  21257. if (end == null)
  21258. throw new ArgumentNullException("end");
  21259. #if CRIPPLED_REFLECTION
  21260. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TArg3>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  21261. #else
  21262. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3));
  21263. #endif
  21264. return (t1, t2, t3) => provider.CreateQuery<Unit>(
  21265. Expression.Invoke(
  21266. Expression.Call(
  21267. null,
  21268. m,
  21269. Expression.Constant(provider, typeof(IQbservableProvider)),
  21270. begin,
  21271. end
  21272. ),
  21273. Expression.Constant(t1, typeof(TArg1)),
  21274. Expression.Constant(t2, typeof(TArg2)),
  21275. Expression.Constant(t3, typeof(TArg3))
  21276. )
  21277. );
  21278. }
  21279. /// <summary>
  21280. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21281. /// </summary>
  21282. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21283. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21284. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21285. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21286. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21287. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21288. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21289. /// <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>
  21290. /// <exception cref="T:System.ArgumentNullException">
  21291. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21292. /// <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>
  21293. #if PREFERASYNC
  21294. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21295. #endif
  21296. 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)
  21297. {
  21298. if (provider == null)
  21299. throw new ArgumentNullException("provider");
  21300. if (begin == null)
  21301. throw new ArgumentNullException("begin");
  21302. if (end == null)
  21303. throw new ArgumentNullException("end");
  21304. #if CRIPPLED_REFLECTION
  21305. 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>>)));
  21306. #else
  21307. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4));
  21308. #endif
  21309. return (t1, t2, t3, t4) => provider.CreateQuery<Unit>(
  21310. Expression.Invoke(
  21311. Expression.Call(
  21312. null,
  21313. m,
  21314. Expression.Constant(provider, typeof(IQbservableProvider)),
  21315. begin,
  21316. end
  21317. ),
  21318. Expression.Constant(t1, typeof(TArg1)),
  21319. Expression.Constant(t2, typeof(TArg2)),
  21320. Expression.Constant(t3, typeof(TArg3)),
  21321. Expression.Constant(t4, typeof(TArg4))
  21322. )
  21323. );
  21324. }
  21325. /// <summary>
  21326. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21327. /// </summary>
  21328. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21329. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21330. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21331. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21332. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21333. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21334. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21335. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21336. /// <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>
  21337. /// <exception cref="T:System.ArgumentNullException">
  21338. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21339. /// <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>
  21340. #if PREFERASYNC
  21341. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21342. #endif
  21343. 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)
  21344. {
  21345. if (provider == null)
  21346. throw new ArgumentNullException("provider");
  21347. if (begin == null)
  21348. throw new ArgumentNullException("begin");
  21349. if (end == null)
  21350. throw new ArgumentNullException("end");
  21351. #if CRIPPLED_REFLECTION
  21352. 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>>)));
  21353. #else
  21354. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5));
  21355. #endif
  21356. return (t1, t2, t3, t4, t5) => provider.CreateQuery<Unit>(
  21357. Expression.Invoke(
  21358. Expression.Call(
  21359. null,
  21360. m,
  21361. Expression.Constant(provider, typeof(IQbservableProvider)),
  21362. begin,
  21363. end
  21364. ),
  21365. Expression.Constant(t1, typeof(TArg1)),
  21366. Expression.Constant(t2, typeof(TArg2)),
  21367. Expression.Constant(t3, typeof(TArg3)),
  21368. Expression.Constant(t4, typeof(TArg4)),
  21369. Expression.Constant(t5, typeof(TArg5))
  21370. )
  21371. );
  21372. }
  21373. /// <summary>
  21374. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21375. /// </summary>
  21376. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21377. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21378. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21379. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21380. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21381. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21382. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21383. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21384. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21385. /// <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>
  21386. /// <exception cref="T:System.ArgumentNullException">
  21387. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21388. /// <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>
  21389. #if PREFERASYNC
  21390. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21391. #endif
  21392. 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)
  21393. {
  21394. if (provider == null)
  21395. throw new ArgumentNullException("provider");
  21396. if (begin == null)
  21397. throw new ArgumentNullException("begin");
  21398. if (end == null)
  21399. throw new ArgumentNullException("end");
  21400. #if CRIPPLED_REFLECTION
  21401. 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>>)));
  21402. #else
  21403. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6));
  21404. #endif
  21405. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<Unit>(
  21406. Expression.Invoke(
  21407. Expression.Call(
  21408. null,
  21409. m,
  21410. Expression.Constant(provider, typeof(IQbservableProvider)),
  21411. begin,
  21412. end
  21413. ),
  21414. Expression.Constant(t1, typeof(TArg1)),
  21415. Expression.Constant(t2, typeof(TArg2)),
  21416. Expression.Constant(t3, typeof(TArg3)),
  21417. Expression.Constant(t4, typeof(TArg4)),
  21418. Expression.Constant(t5, typeof(TArg5)),
  21419. Expression.Constant(t6, typeof(TArg6))
  21420. )
  21421. );
  21422. }
  21423. /// <summary>
  21424. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21425. /// </summary>
  21426. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21427. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21428. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21429. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21430. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21431. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21432. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21433. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21434. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21435. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21436. /// <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>
  21437. /// <exception cref="T:System.ArgumentNullException">
  21438. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21439. /// <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>
  21440. #if PREFERASYNC
  21441. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21442. #endif
  21443. 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)
  21444. {
  21445. if (provider == null)
  21446. throw new ArgumentNullException("provider");
  21447. if (begin == null)
  21448. throw new ArgumentNullException("begin");
  21449. if (end == null)
  21450. throw new ArgumentNullException("end");
  21451. #if CRIPPLED_REFLECTION
  21452. 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>>)));
  21453. #else
  21454. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7));
  21455. #endif
  21456. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<Unit>(
  21457. Expression.Invoke(
  21458. Expression.Call(
  21459. null,
  21460. m,
  21461. Expression.Constant(provider, typeof(IQbservableProvider)),
  21462. begin,
  21463. end
  21464. ),
  21465. Expression.Constant(t1, typeof(TArg1)),
  21466. Expression.Constant(t2, typeof(TArg2)),
  21467. Expression.Constant(t3, typeof(TArg3)),
  21468. Expression.Constant(t4, typeof(TArg4)),
  21469. Expression.Constant(t5, typeof(TArg5)),
  21470. Expression.Constant(t6, typeof(TArg6)),
  21471. Expression.Constant(t7, typeof(TArg7))
  21472. )
  21473. );
  21474. }
  21475. /// <summary>
  21476. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21477. /// </summary>
  21478. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21479. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21480. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21481. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21482. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21483. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21484. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21485. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21486. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21487. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21488. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21489. /// <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>
  21490. /// <exception cref="T:System.ArgumentNullException">
  21491. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21492. /// <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>
  21493. #if PREFERASYNC
  21494. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21495. #endif
  21496. 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)
  21497. {
  21498. if (provider == null)
  21499. throw new ArgumentNullException("provider");
  21500. if (begin == null)
  21501. throw new ArgumentNullException("begin");
  21502. if (end == null)
  21503. throw new ArgumentNullException("end");
  21504. #if CRIPPLED_REFLECTION
  21505. 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>>)));
  21506. #else
  21507. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8));
  21508. #endif
  21509. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<Unit>(
  21510. Expression.Invoke(
  21511. Expression.Call(
  21512. null,
  21513. m,
  21514. Expression.Constant(provider, typeof(IQbservableProvider)),
  21515. begin,
  21516. end
  21517. ),
  21518. Expression.Constant(t1, typeof(TArg1)),
  21519. Expression.Constant(t2, typeof(TArg2)),
  21520. Expression.Constant(t3, typeof(TArg3)),
  21521. Expression.Constant(t4, typeof(TArg4)),
  21522. Expression.Constant(t5, typeof(TArg5)),
  21523. Expression.Constant(t6, typeof(TArg6)),
  21524. Expression.Constant(t7, typeof(TArg7)),
  21525. Expression.Constant(t8, typeof(TArg8))
  21526. )
  21527. );
  21528. }
  21529. /// <summary>
  21530. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21531. /// </summary>
  21532. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21533. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21534. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21535. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21536. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21537. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21538. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21539. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21540. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21541. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21542. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21543. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21544. /// <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>
  21545. /// <exception cref="T:System.ArgumentNullException">
  21546. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21547. /// <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>
  21548. #if PREFERASYNC
  21549. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21550. #endif
  21551. 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)
  21552. {
  21553. if (provider == null)
  21554. throw new ArgumentNullException("provider");
  21555. if (begin == null)
  21556. throw new ArgumentNullException("begin");
  21557. if (end == null)
  21558. throw new ArgumentNullException("end");
  21559. #if CRIPPLED_REFLECTION
  21560. 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>>)));
  21561. #else
  21562. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9));
  21563. #endif
  21564. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<Unit>(
  21565. Expression.Invoke(
  21566. Expression.Call(
  21567. null,
  21568. m,
  21569. Expression.Constant(provider, typeof(IQbservableProvider)),
  21570. begin,
  21571. end
  21572. ),
  21573. Expression.Constant(t1, typeof(TArg1)),
  21574. Expression.Constant(t2, typeof(TArg2)),
  21575. Expression.Constant(t3, typeof(TArg3)),
  21576. Expression.Constant(t4, typeof(TArg4)),
  21577. Expression.Constant(t5, typeof(TArg5)),
  21578. Expression.Constant(t6, typeof(TArg6)),
  21579. Expression.Constant(t7, typeof(TArg7)),
  21580. Expression.Constant(t8, typeof(TArg8)),
  21581. Expression.Constant(t9, typeof(TArg9))
  21582. )
  21583. );
  21584. }
  21585. /// <summary>
  21586. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21587. /// </summary>
  21588. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21589. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21590. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21591. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21592. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21593. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21594. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21595. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21596. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21597. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21598. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21599. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21600. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21601. /// <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>
  21602. /// <exception cref="T:System.ArgumentNullException">
  21603. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21604. /// <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>
  21605. #if PREFERASYNC
  21606. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21607. #endif
  21608. 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)
  21609. {
  21610. if (provider == null)
  21611. throw new ArgumentNullException("provider");
  21612. if (begin == null)
  21613. throw new ArgumentNullException("begin");
  21614. if (end == null)
  21615. throw new ArgumentNullException("end");
  21616. #if CRIPPLED_REFLECTION
  21617. 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>>)));
  21618. #else
  21619. 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));
  21620. #endif
  21621. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<Unit>(
  21622. Expression.Invoke(
  21623. Expression.Call(
  21624. null,
  21625. m,
  21626. Expression.Constant(provider, typeof(IQbservableProvider)),
  21627. begin,
  21628. end
  21629. ),
  21630. Expression.Constant(t1, typeof(TArg1)),
  21631. Expression.Constant(t2, typeof(TArg2)),
  21632. Expression.Constant(t3, typeof(TArg3)),
  21633. Expression.Constant(t4, typeof(TArg4)),
  21634. Expression.Constant(t5, typeof(TArg5)),
  21635. Expression.Constant(t6, typeof(TArg6)),
  21636. Expression.Constant(t7, typeof(TArg7)),
  21637. Expression.Constant(t8, typeof(TArg8)),
  21638. Expression.Constant(t9, typeof(TArg9)),
  21639. Expression.Constant(t10, typeof(TArg10))
  21640. )
  21641. );
  21642. }
  21643. /// <summary>
  21644. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21645. /// </summary>
  21646. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21647. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21648. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21649. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21650. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21651. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21652. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21653. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21654. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21655. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21656. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21657. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  21658. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21659. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21660. /// <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>
  21661. /// <exception cref="T:System.ArgumentNullException">
  21662. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21663. /// <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>
  21664. #if PREFERASYNC
  21665. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21666. #endif
  21667. 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)
  21668. {
  21669. if (provider == null)
  21670. throw new ArgumentNullException("provider");
  21671. if (begin == null)
  21672. throw new ArgumentNullException("begin");
  21673. if (end == null)
  21674. throw new ArgumentNullException("end");
  21675. #if CRIPPLED_REFLECTION
  21676. 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>>)));
  21677. #else
  21678. 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));
  21679. #endif
  21680. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<Unit>(
  21681. Expression.Invoke(
  21682. Expression.Call(
  21683. null,
  21684. m,
  21685. Expression.Constant(provider, typeof(IQbservableProvider)),
  21686. begin,
  21687. end
  21688. ),
  21689. Expression.Constant(t1, typeof(TArg1)),
  21690. Expression.Constant(t2, typeof(TArg2)),
  21691. Expression.Constant(t3, typeof(TArg3)),
  21692. Expression.Constant(t4, typeof(TArg4)),
  21693. Expression.Constant(t5, typeof(TArg5)),
  21694. Expression.Constant(t6, typeof(TArg6)),
  21695. Expression.Constant(t7, typeof(TArg7)),
  21696. Expression.Constant(t8, typeof(TArg8)),
  21697. Expression.Constant(t9, typeof(TArg9)),
  21698. Expression.Constant(t10, typeof(TArg10)),
  21699. Expression.Constant(t11, typeof(TArg11))
  21700. )
  21701. );
  21702. }
  21703. /// <summary>
  21704. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21705. /// </summary>
  21706. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21707. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21708. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21709. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21710. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21711. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21712. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21713. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21714. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21715. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21716. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21717. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  21718. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  21719. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21720. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21721. /// <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>
  21722. /// <exception cref="T:System.ArgumentNullException">
  21723. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21724. /// <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>
  21725. #if PREFERASYNC
  21726. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21727. #endif
  21728. 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)
  21729. {
  21730. if (provider == null)
  21731. throw new ArgumentNullException("provider");
  21732. if (begin == null)
  21733. throw new ArgumentNullException("begin");
  21734. if (end == null)
  21735. throw new ArgumentNullException("end");
  21736. #if CRIPPLED_REFLECTION
  21737. 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>>)));
  21738. #else
  21739. 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));
  21740. #endif
  21741. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<Unit>(
  21742. Expression.Invoke(
  21743. Expression.Call(
  21744. null,
  21745. m,
  21746. Expression.Constant(provider, typeof(IQbservableProvider)),
  21747. begin,
  21748. end
  21749. ),
  21750. Expression.Constant(t1, typeof(TArg1)),
  21751. Expression.Constant(t2, typeof(TArg2)),
  21752. Expression.Constant(t3, typeof(TArg3)),
  21753. Expression.Constant(t4, typeof(TArg4)),
  21754. Expression.Constant(t5, typeof(TArg5)),
  21755. Expression.Constant(t6, typeof(TArg6)),
  21756. Expression.Constant(t7, typeof(TArg7)),
  21757. Expression.Constant(t8, typeof(TArg8)),
  21758. Expression.Constant(t9, typeof(TArg9)),
  21759. Expression.Constant(t10, typeof(TArg10)),
  21760. Expression.Constant(t11, typeof(TArg11)),
  21761. Expression.Constant(t12, typeof(TArg12))
  21762. )
  21763. );
  21764. }
  21765. /// <summary>
  21766. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21767. /// </summary>
  21768. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21769. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21770. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21771. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21772. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21773. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21774. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21775. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21776. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21777. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21778. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21779. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  21780. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  21781. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the begin delegate.</typeparam>
  21782. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21783. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21784. /// <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>
  21785. /// <exception cref="T:System.ArgumentNullException">
  21786. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21787. /// <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>
  21788. #if PREFERASYNC
  21789. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21790. #endif
  21791. 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)
  21792. {
  21793. if (provider == null)
  21794. throw new ArgumentNullException("provider");
  21795. if (begin == null)
  21796. throw new ArgumentNullException("begin");
  21797. if (end == null)
  21798. throw new ArgumentNullException("end");
  21799. #if CRIPPLED_REFLECTION
  21800. 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>>)));
  21801. #else
  21802. 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));
  21803. #endif
  21804. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<Unit>(
  21805. Expression.Invoke(
  21806. Expression.Call(
  21807. null,
  21808. m,
  21809. Expression.Constant(provider, typeof(IQbservableProvider)),
  21810. begin,
  21811. end
  21812. ),
  21813. Expression.Constant(t1, typeof(TArg1)),
  21814. Expression.Constant(t2, typeof(TArg2)),
  21815. Expression.Constant(t3, typeof(TArg3)),
  21816. Expression.Constant(t4, typeof(TArg4)),
  21817. Expression.Constant(t5, typeof(TArg5)),
  21818. Expression.Constant(t6, typeof(TArg6)),
  21819. Expression.Constant(t7, typeof(TArg7)),
  21820. Expression.Constant(t8, typeof(TArg8)),
  21821. Expression.Constant(t9, typeof(TArg9)),
  21822. Expression.Constant(t10, typeof(TArg10)),
  21823. Expression.Constant(t11, typeof(TArg11)),
  21824. Expression.Constant(t12, typeof(TArg12)),
  21825. Expression.Constant(t13, typeof(TArg13))
  21826. )
  21827. );
  21828. }
  21829. /// <summary>
  21830. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21831. /// </summary>
  21832. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21833. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21834. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21835. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21836. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21837. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21838. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21839. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21840. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21841. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21842. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21843. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  21844. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  21845. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the begin delegate.</typeparam>
  21846. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the begin delegate.</typeparam>
  21847. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21848. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21849. /// <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>
  21850. /// <exception cref="T:System.ArgumentNullException">
  21851. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21852. /// <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>
  21853. #if PREFERASYNC
  21854. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21855. #endif
  21856. 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)
  21857. {
  21858. if (provider == null)
  21859. throw new ArgumentNullException("provider");
  21860. if (begin == null)
  21861. throw new ArgumentNullException("begin");
  21862. if (end == null)
  21863. throw new ArgumentNullException("end");
  21864. #if CRIPPLED_REFLECTION
  21865. 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>>)));
  21866. #else
  21867. 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));
  21868. #endif
  21869. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<Unit>(
  21870. Expression.Invoke(
  21871. Expression.Call(
  21872. null,
  21873. m,
  21874. Expression.Constant(provider, typeof(IQbservableProvider)),
  21875. begin,
  21876. end
  21877. ),
  21878. Expression.Constant(t1, typeof(TArg1)),
  21879. Expression.Constant(t2, typeof(TArg2)),
  21880. Expression.Constant(t3, typeof(TArg3)),
  21881. Expression.Constant(t4, typeof(TArg4)),
  21882. Expression.Constant(t5, typeof(TArg5)),
  21883. Expression.Constant(t6, typeof(TArg6)),
  21884. Expression.Constant(t7, typeof(TArg7)),
  21885. Expression.Constant(t8, typeof(TArg8)),
  21886. Expression.Constant(t9, typeof(TArg9)),
  21887. Expression.Constant(t10, typeof(TArg10)),
  21888. Expression.Constant(t11, typeof(TArg11)),
  21889. Expression.Constant(t12, typeof(TArg12)),
  21890. Expression.Constant(t13, typeof(TArg13)),
  21891. Expression.Constant(t14, typeof(TArg14))
  21892. )
  21893. );
  21894. }
  21895. #endif
  21896. /// <summary>
  21897. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21898. /// </summary>
  21899. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21900. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21901. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21902. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21903. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21904. /// <exception cref="T:System.ArgumentNullException">
  21905. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21906. /// <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>
  21907. #if PREFERASYNC
  21908. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21909. #endif
  21910. public static Func<IQbservable<TResult>> FromAsyncPattern<TResult>(this IQbservableProvider provider, Expression<Func<AsyncCallback, object, IAsyncResult>> begin, Expression<Func<IAsyncResult, TResult>>end)
  21911. {
  21912. if (provider == null)
  21913. throw new ArgumentNullException("provider");
  21914. if (begin == null)
  21915. throw new ArgumentNullException("begin");
  21916. if (end == null)
  21917. throw new ArgumentNullException("end");
  21918. #if CRIPPLED_REFLECTION
  21919. var m = InfoOf(() => Qbservable.FromAsyncPattern<TResult>(default(IQbservableProvider), default(Expression<Func<AsyncCallback, object, IAsyncResult>>), default(Expression<Func<IAsyncResult, TResult>>)));
  21920. #else
  21921. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult));
  21922. #endif
  21923. return () => provider.CreateQuery<TResult>(
  21924. Expression.Invoke(
  21925. Expression.Call(
  21926. null,
  21927. m,
  21928. Expression.Constant(provider, typeof(IQbservableProvider)),
  21929. begin,
  21930. end
  21931. )
  21932. )
  21933. );
  21934. }
  21935. /// <summary>
  21936. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21937. /// </summary>
  21938. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21939. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21940. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21941. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21942. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21943. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21944. /// <exception cref="T:System.ArgumentNullException">
  21945. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21946. /// <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>
  21947. #if PREFERASYNC
  21948. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21949. #endif
  21950. public static Func<TArg1, IQbservable<TResult>> FromAsyncPattern<TArg1, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, AsyncCallback, object, IAsyncResult>> begin, Expression<Func<IAsyncResult, TResult>>end)
  21951. {
  21952. if (provider == null)
  21953. throw new ArgumentNullException("provider");
  21954. if (begin == null)
  21955. throw new ArgumentNullException("begin");
  21956. if (end == null)
  21957. throw new ArgumentNullException("end");
  21958. #if CRIPPLED_REFLECTION
  21959. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, AsyncCallback, object, IAsyncResult>>), default(Expression<Func<IAsyncResult, TResult>>)));
  21960. #else
  21961. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TResult));
  21962. #endif
  21963. return (t1) => provider.CreateQuery<TResult>(
  21964. Expression.Invoke(
  21965. Expression.Call(
  21966. null,
  21967. m,
  21968. Expression.Constant(provider, typeof(IQbservableProvider)),
  21969. begin,
  21970. end
  21971. ),
  21972. Expression.Constant(t1, typeof(TArg1))
  21973. )
  21974. );
  21975. }
  21976. /// <summary>
  21977. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21978. /// </summary>
  21979. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21980. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21981. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21982. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21983. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21984. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21985. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21986. /// <exception cref="T:System.ArgumentNullException">
  21987. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21988. /// <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>
  21989. #if PREFERASYNC
  21990. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21991. #endif
  21992. 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)
  21993. {
  21994. if (provider == null)
  21995. throw new ArgumentNullException("provider");
  21996. if (begin == null)
  21997. throw new ArgumentNullException("begin");
  21998. if (end == null)
  21999. throw new ArgumentNullException("end");
  22000. #if CRIPPLED_REFLECTION
  22001. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, AsyncCallback, object, IAsyncResult>>), default(Expression<Func<IAsyncResult, TResult>>)));
  22002. #else
  22003. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TResult));
  22004. #endif
  22005. return (t1, t2) => provider.CreateQuery<TResult>(
  22006. Expression.Invoke(
  22007. Expression.Call(
  22008. null,
  22009. m,
  22010. Expression.Constant(provider, typeof(IQbservableProvider)),
  22011. begin,
  22012. end
  22013. ),
  22014. Expression.Constant(t1, typeof(TArg1)),
  22015. Expression.Constant(t2, typeof(TArg2))
  22016. )
  22017. );
  22018. }
  22019. #if !NO_LARGEARITY
  22020. /// <summary>
  22021. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22022. /// </summary>
  22023. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  22024. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22025. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22026. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22027. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22028. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22029. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22030. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22031. /// <exception cref="T:System.ArgumentNullException">
  22032. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22033. /// <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>
  22034. #if PREFERASYNC
  22035. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22036. #endif
  22037. 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)
  22038. {
  22039. if (provider == null)
  22040. throw new ArgumentNullException("provider");
  22041. if (begin == null)
  22042. throw new ArgumentNullException("begin");
  22043. if (end == null)
  22044. throw new ArgumentNullException("end");
  22045. #if CRIPPLED_REFLECTION
  22046. 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>>)));
  22047. #else
  22048. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TResult));
  22049. #endif
  22050. return (t1, t2, t3) => provider.CreateQuery<TResult>(
  22051. Expression.Invoke(
  22052. Expression.Call(
  22053. null,
  22054. m,
  22055. Expression.Constant(provider, typeof(IQbservableProvider)),
  22056. begin,
  22057. end
  22058. ),
  22059. Expression.Constant(t1, typeof(TArg1)),
  22060. Expression.Constant(t2, typeof(TArg2)),
  22061. Expression.Constant(t3, typeof(TArg3))
  22062. )
  22063. );
  22064. }
  22065. /// <summary>
  22066. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22067. /// </summary>
  22068. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  22069. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22070. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22071. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22072. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22073. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22074. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22075. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22076. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22077. /// <exception cref="T:System.ArgumentNullException">
  22078. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22079. /// <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>
  22080. #if PREFERASYNC
  22081. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22082. #endif
  22083. 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)
  22084. {
  22085. if (provider == null)
  22086. throw new ArgumentNullException("provider");
  22087. if (begin == null)
  22088. throw new ArgumentNullException("begin");
  22089. if (end == null)
  22090. throw new ArgumentNullException("end");
  22091. #if CRIPPLED_REFLECTION
  22092. 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>>)));
  22093. #else
  22094. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TResult));
  22095. #endif
  22096. return (t1, t2, t3, t4) => provider.CreateQuery<TResult>(
  22097. Expression.Invoke(
  22098. Expression.Call(
  22099. null,
  22100. m,
  22101. Expression.Constant(provider, typeof(IQbservableProvider)),
  22102. begin,
  22103. end
  22104. ),
  22105. Expression.Constant(t1, typeof(TArg1)),
  22106. Expression.Constant(t2, typeof(TArg2)),
  22107. Expression.Constant(t3, typeof(TArg3)),
  22108. Expression.Constant(t4, typeof(TArg4))
  22109. )
  22110. );
  22111. }
  22112. /// <summary>
  22113. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22114. /// </summary>
  22115. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  22116. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22117. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22118. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22119. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22120. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22121. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22122. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22123. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22124. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22125. /// <exception cref="T:System.ArgumentNullException">
  22126. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22127. /// <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>
  22128. #if PREFERASYNC
  22129. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22130. #endif
  22131. 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)
  22132. {
  22133. if (provider == null)
  22134. throw new ArgumentNullException("provider");
  22135. if (begin == null)
  22136. throw new ArgumentNullException("begin");
  22137. if (end == null)
  22138. throw new ArgumentNullException("end");
  22139. #if CRIPPLED_REFLECTION
  22140. 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>>)));
  22141. #else
  22142. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TResult));
  22143. #endif
  22144. return (t1, t2, t3, t4, t5) => provider.CreateQuery<TResult>(
  22145. Expression.Invoke(
  22146. Expression.Call(
  22147. null,
  22148. m,
  22149. Expression.Constant(provider, typeof(IQbservableProvider)),
  22150. begin,
  22151. end
  22152. ),
  22153. Expression.Constant(t1, typeof(TArg1)),
  22154. Expression.Constant(t2, typeof(TArg2)),
  22155. Expression.Constant(t3, typeof(TArg3)),
  22156. Expression.Constant(t4, typeof(TArg4)),
  22157. Expression.Constant(t5, typeof(TArg5))
  22158. )
  22159. );
  22160. }
  22161. /// <summary>
  22162. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22163. /// </summary>
  22164. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  22165. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22166. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22167. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22168. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22169. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22170. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22171. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22172. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22173. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22174. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22175. /// <exception cref="T:System.ArgumentNullException">
  22176. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22177. /// <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>
  22178. #if PREFERASYNC
  22179. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22180. #endif
  22181. 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)
  22182. {
  22183. if (provider == null)
  22184. throw new ArgumentNullException("provider");
  22185. if (begin == null)
  22186. throw new ArgumentNullException("begin");
  22187. if (end == null)
  22188. throw new ArgumentNullException("end");
  22189. #if CRIPPLED_REFLECTION
  22190. 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>>)));
  22191. #else
  22192. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TResult));
  22193. #endif
  22194. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<TResult>(
  22195. Expression.Invoke(
  22196. Expression.Call(
  22197. null,
  22198. m,
  22199. Expression.Constant(provider, typeof(IQbservableProvider)),
  22200. begin,
  22201. end
  22202. ),
  22203. Expression.Constant(t1, typeof(TArg1)),
  22204. Expression.Constant(t2, typeof(TArg2)),
  22205. Expression.Constant(t3, typeof(TArg3)),
  22206. Expression.Constant(t4, typeof(TArg4)),
  22207. Expression.Constant(t5, typeof(TArg5)),
  22208. Expression.Constant(t6, typeof(TArg6))
  22209. )
  22210. );
  22211. }
  22212. /// <summary>
  22213. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22214. /// </summary>
  22215. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  22216. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22217. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22218. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22219. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22220. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22221. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22222. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  22223. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22224. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22225. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22226. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22227. /// <exception cref="T:System.ArgumentNullException">
  22228. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22229. /// <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>
  22230. #if PREFERASYNC
  22231. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22232. #endif
  22233. 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)
  22234. {
  22235. if (provider == null)
  22236. throw new ArgumentNullException("provider");
  22237. if (begin == null)
  22238. throw new ArgumentNullException("begin");
  22239. if (end == null)
  22240. throw new ArgumentNullException("end");
  22241. #if CRIPPLED_REFLECTION
  22242. 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>>)));
  22243. #else
  22244. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TResult));
  22245. #endif
  22246. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<TResult>(
  22247. Expression.Invoke(
  22248. Expression.Call(
  22249. null,
  22250. m,
  22251. Expression.Constant(provider, typeof(IQbservableProvider)),
  22252. begin,
  22253. end
  22254. ),
  22255. Expression.Constant(t1, typeof(TArg1)),
  22256. Expression.Constant(t2, typeof(TArg2)),
  22257. Expression.Constant(t3, typeof(TArg3)),
  22258. Expression.Constant(t4, typeof(TArg4)),
  22259. Expression.Constant(t5, typeof(TArg5)),
  22260. Expression.Constant(t6, typeof(TArg6)),
  22261. Expression.Constant(t7, typeof(TArg7))
  22262. )
  22263. );
  22264. }
  22265. /// <summary>
  22266. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22267. /// </summary>
  22268. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  22269. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22270. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22271. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22272. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22273. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22274. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22275. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  22276. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  22277. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22278. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22279. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22280. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22281. /// <exception cref="T:System.ArgumentNullException">
  22282. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22283. /// <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>
  22284. #if PREFERASYNC
  22285. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22286. #endif
  22287. 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)
  22288. {
  22289. if (provider == null)
  22290. throw new ArgumentNullException("provider");
  22291. if (begin == null)
  22292. throw new ArgumentNullException("begin");
  22293. if (end == null)
  22294. throw new ArgumentNullException("end");
  22295. #if CRIPPLED_REFLECTION
  22296. 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>>)));
  22297. #else
  22298. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TResult));
  22299. #endif
  22300. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<TResult>(
  22301. Expression.Invoke(
  22302. Expression.Call(
  22303. null,
  22304. m,
  22305. Expression.Constant(provider, typeof(IQbservableProvider)),
  22306. begin,
  22307. end
  22308. ),
  22309. Expression.Constant(t1, typeof(TArg1)),
  22310. Expression.Constant(t2, typeof(TArg2)),
  22311. Expression.Constant(t3, typeof(TArg3)),
  22312. Expression.Constant(t4, typeof(TArg4)),
  22313. Expression.Constant(t5, typeof(TArg5)),
  22314. Expression.Constant(t6, typeof(TArg6)),
  22315. Expression.Constant(t7, typeof(TArg7)),
  22316. Expression.Constant(t8, typeof(TArg8))
  22317. )
  22318. );
  22319. }
  22320. /// <summary>
  22321. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22322. /// </summary>
  22323. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  22324. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22325. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22326. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22327. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22328. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22329. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22330. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  22331. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  22332. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  22333. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22334. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22335. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22336. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22337. /// <exception cref="T:System.ArgumentNullException">
  22338. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22339. /// <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>
  22340. #if PREFERASYNC
  22341. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22342. #endif
  22343. 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)
  22344. {
  22345. if (provider == null)
  22346. throw new ArgumentNullException("provider");
  22347. if (begin == null)
  22348. throw new ArgumentNullException("begin");
  22349. if (end == null)
  22350. throw new ArgumentNullException("end");
  22351. #if CRIPPLED_REFLECTION
  22352. 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>>)));
  22353. #else
  22354. 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));
  22355. #endif
  22356. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<TResult>(
  22357. Expression.Invoke(
  22358. Expression.Call(
  22359. null,
  22360. m,
  22361. Expression.Constant(provider, typeof(IQbservableProvider)),
  22362. begin,
  22363. end
  22364. ),
  22365. Expression.Constant(t1, typeof(TArg1)),
  22366. Expression.Constant(t2, typeof(TArg2)),
  22367. Expression.Constant(t3, typeof(TArg3)),
  22368. Expression.Constant(t4, typeof(TArg4)),
  22369. Expression.Constant(t5, typeof(TArg5)),
  22370. Expression.Constant(t6, typeof(TArg6)),
  22371. Expression.Constant(t7, typeof(TArg7)),
  22372. Expression.Constant(t8, typeof(TArg8)),
  22373. Expression.Constant(t9, typeof(TArg9))
  22374. )
  22375. );
  22376. }
  22377. /// <summary>
  22378. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22379. /// </summary>
  22380. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  22381. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22382. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22383. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22384. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22385. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22386. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22387. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  22388. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  22389. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  22390. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  22391. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22392. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22393. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22394. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22395. /// <exception cref="T:System.ArgumentNullException">
  22396. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22397. /// <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>
  22398. #if PREFERASYNC
  22399. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22400. #endif
  22401. 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)
  22402. {
  22403. if (provider == null)
  22404. throw new ArgumentNullException("provider");
  22405. if (begin == null)
  22406. throw new ArgumentNullException("begin");
  22407. if (end == null)
  22408. throw new ArgumentNullException("end");
  22409. #if CRIPPLED_REFLECTION
  22410. 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>>)));
  22411. #else
  22412. 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));
  22413. #endif
  22414. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<TResult>(
  22415. Expression.Invoke(
  22416. Expression.Call(
  22417. null,
  22418. m,
  22419. Expression.Constant(provider, typeof(IQbservableProvider)),
  22420. begin,
  22421. end
  22422. ),
  22423. Expression.Constant(t1, typeof(TArg1)),
  22424. Expression.Constant(t2, typeof(TArg2)),
  22425. Expression.Constant(t3, typeof(TArg3)),
  22426. Expression.Constant(t4, typeof(TArg4)),
  22427. Expression.Constant(t5, typeof(TArg5)),
  22428. Expression.Constant(t6, typeof(TArg6)),
  22429. Expression.Constant(t7, typeof(TArg7)),
  22430. Expression.Constant(t8, typeof(TArg8)),
  22431. Expression.Constant(t9, typeof(TArg9)),
  22432. Expression.Constant(t10, typeof(TArg10))
  22433. )
  22434. );
  22435. }
  22436. /// <summary>
  22437. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22438. /// </summary>
  22439. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  22440. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22441. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22442. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22443. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22444. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22445. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22446. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  22447. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  22448. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  22449. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  22450. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  22451. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22452. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22453. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22454. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22455. /// <exception cref="T:System.ArgumentNullException">
  22456. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22457. /// <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>
  22458. #if PREFERASYNC
  22459. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22460. #endif
  22461. 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)
  22462. {
  22463. if (provider == null)
  22464. throw new ArgumentNullException("provider");
  22465. if (begin == null)
  22466. throw new ArgumentNullException("begin");
  22467. if (end == null)
  22468. throw new ArgumentNullException("end");
  22469. #if CRIPPLED_REFLECTION
  22470. 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>>)));
  22471. #else
  22472. 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));
  22473. #endif
  22474. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<TResult>(
  22475. Expression.Invoke(
  22476. Expression.Call(
  22477. null,
  22478. m,
  22479. Expression.Constant(provider, typeof(IQbservableProvider)),
  22480. begin,
  22481. end
  22482. ),
  22483. Expression.Constant(t1, typeof(TArg1)),
  22484. Expression.Constant(t2, typeof(TArg2)),
  22485. Expression.Constant(t3, typeof(TArg3)),
  22486. Expression.Constant(t4, typeof(TArg4)),
  22487. Expression.Constant(t5, typeof(TArg5)),
  22488. Expression.Constant(t6, typeof(TArg6)),
  22489. Expression.Constant(t7, typeof(TArg7)),
  22490. Expression.Constant(t8, typeof(TArg8)),
  22491. Expression.Constant(t9, typeof(TArg9)),
  22492. Expression.Constant(t10, typeof(TArg10)),
  22493. Expression.Constant(t11, typeof(TArg11))
  22494. )
  22495. );
  22496. }
  22497. /// <summary>
  22498. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22499. /// </summary>
  22500. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  22501. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22502. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22503. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22504. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22505. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22506. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22507. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  22508. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  22509. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  22510. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  22511. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  22512. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  22513. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22514. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22515. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22516. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22517. /// <exception cref="T:System.ArgumentNullException">
  22518. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22519. /// <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>
  22520. #if PREFERASYNC
  22521. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22522. #endif
  22523. 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)
  22524. {
  22525. if (provider == null)
  22526. throw new ArgumentNullException("provider");
  22527. if (begin == null)
  22528. throw new ArgumentNullException("begin");
  22529. if (end == null)
  22530. throw new ArgumentNullException("end");
  22531. #if CRIPPLED_REFLECTION
  22532. 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>>)));
  22533. #else
  22534. 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));
  22535. #endif
  22536. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<TResult>(
  22537. Expression.Invoke(
  22538. Expression.Call(
  22539. null,
  22540. m,
  22541. Expression.Constant(provider, typeof(IQbservableProvider)),
  22542. begin,
  22543. end
  22544. ),
  22545. Expression.Constant(t1, typeof(TArg1)),
  22546. Expression.Constant(t2, typeof(TArg2)),
  22547. Expression.Constant(t3, typeof(TArg3)),
  22548. Expression.Constant(t4, typeof(TArg4)),
  22549. Expression.Constant(t5, typeof(TArg5)),
  22550. Expression.Constant(t6, typeof(TArg6)),
  22551. Expression.Constant(t7, typeof(TArg7)),
  22552. Expression.Constant(t8, typeof(TArg8)),
  22553. Expression.Constant(t9, typeof(TArg9)),
  22554. Expression.Constant(t10, typeof(TArg10)),
  22555. Expression.Constant(t11, typeof(TArg11)),
  22556. Expression.Constant(t12, typeof(TArg12))
  22557. )
  22558. );
  22559. }
  22560. /// <summary>
  22561. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22562. /// </summary>
  22563. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  22564. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22565. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22566. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22567. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22568. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22569. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22570. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  22571. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  22572. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  22573. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  22574. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  22575. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  22576. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the begin delegate.</typeparam>
  22577. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22578. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22579. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22580. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22581. /// <exception cref="T:System.ArgumentNullException">
  22582. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22583. /// <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>
  22584. #if PREFERASYNC
  22585. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22586. #endif
  22587. 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)
  22588. {
  22589. if (provider == null)
  22590. throw new ArgumentNullException("provider");
  22591. if (begin == null)
  22592. throw new ArgumentNullException("begin");
  22593. if (end == null)
  22594. throw new ArgumentNullException("end");
  22595. #if CRIPPLED_REFLECTION
  22596. 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>>)));
  22597. #else
  22598. 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));
  22599. #endif
  22600. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<TResult>(
  22601. Expression.Invoke(
  22602. Expression.Call(
  22603. null,
  22604. m,
  22605. Expression.Constant(provider, typeof(IQbservableProvider)),
  22606. begin,
  22607. end
  22608. ),
  22609. Expression.Constant(t1, typeof(TArg1)),
  22610. Expression.Constant(t2, typeof(TArg2)),
  22611. Expression.Constant(t3, typeof(TArg3)),
  22612. Expression.Constant(t4, typeof(TArg4)),
  22613. Expression.Constant(t5, typeof(TArg5)),
  22614. Expression.Constant(t6, typeof(TArg6)),
  22615. Expression.Constant(t7, typeof(TArg7)),
  22616. Expression.Constant(t8, typeof(TArg8)),
  22617. Expression.Constant(t9, typeof(TArg9)),
  22618. Expression.Constant(t10, typeof(TArg10)),
  22619. Expression.Constant(t11, typeof(TArg11)),
  22620. Expression.Constant(t12, typeof(TArg12)),
  22621. Expression.Constant(t13, typeof(TArg13))
  22622. )
  22623. );
  22624. }
  22625. /// <summary>
  22626. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22627. /// </summary>
  22628. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  22629. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22630. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22631. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22632. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22633. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22634. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22635. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  22636. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  22637. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  22638. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  22639. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  22640. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  22641. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the begin delegate.</typeparam>
  22642. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the begin delegate.</typeparam>
  22643. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22644. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22645. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22646. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22647. /// <exception cref="T:System.ArgumentNullException">
  22648. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22649. /// <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>
  22650. #if PREFERASYNC
  22651. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22652. #endif
  22653. 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)
  22654. {
  22655. if (provider == null)
  22656. throw new ArgumentNullException("provider");
  22657. if (begin == null)
  22658. throw new ArgumentNullException("begin");
  22659. if (end == null)
  22660. throw new ArgumentNullException("end");
  22661. #if CRIPPLED_REFLECTION
  22662. 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>>)));
  22663. #else
  22664. 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));
  22665. #endif
  22666. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<TResult>(
  22667. Expression.Invoke(
  22668. Expression.Call(
  22669. null,
  22670. m,
  22671. Expression.Constant(provider, typeof(IQbservableProvider)),
  22672. begin,
  22673. end
  22674. ),
  22675. Expression.Constant(t1, typeof(TArg1)),
  22676. Expression.Constant(t2, typeof(TArg2)),
  22677. Expression.Constant(t3, typeof(TArg3)),
  22678. Expression.Constant(t4, typeof(TArg4)),
  22679. Expression.Constant(t5, typeof(TArg5)),
  22680. Expression.Constant(t6, typeof(TArg6)),
  22681. Expression.Constant(t7, typeof(TArg7)),
  22682. Expression.Constant(t8, typeof(TArg8)),
  22683. Expression.Constant(t9, typeof(TArg9)),
  22684. Expression.Constant(t10, typeof(TArg10)),
  22685. Expression.Constant(t11, typeof(TArg11)),
  22686. Expression.Constant(t12, typeof(TArg12)),
  22687. Expression.Constant(t13, typeof(TArg13)),
  22688. Expression.Constant(t14, typeof(TArg14))
  22689. )
  22690. );
  22691. }
  22692. #endif
  22693. }
  22694. }
  22695. #endif
  22696. #pragma warning restore 1591