Qbservable.Generated.cs 1.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739
  1. /*
  2. * WARNING: Auto-generated file (5/1/2015 21:21:20)
  3. * Run Rx's auto-homoiconizer tool to generate this file (in the HomoIcon directory).
  4. */
  5. #pragma warning disable 1591
  6. #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 implement 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 implement 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 implement 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 implement 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. /// </summary>
  4567. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  4568. /// <param name="actionAsync">Asynchronous action to convert.</param>
  4569. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  4570. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  4571. /// <exception cref="T:System.ArgumentNullException">
  4572. /// <paramref name="actionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  4573. public static IQbservable<Unit> FromAsync(this IQbservableProvider provider, Expression<Func<Task>> actionAsync, IScheduler scheduler)
  4574. {
  4575. if (provider == null)
  4576. throw new ArgumentNullException("provider");
  4577. if (actionAsync == null)
  4578. throw new ArgumentNullException("actionAsync");
  4579. if (scheduler == null)
  4580. throw new ArgumentNullException("scheduler");
  4581. return provider.CreateQuery<Unit>(
  4582. Expression.Call(
  4583. null,
  4584. #if CRIPPLED_REFLECTION
  4585. InfoOf(() => Qbservable.FromAsync(default(IQbservableProvider), default(Expression<Func<Task>>), default(IScheduler))),
  4586. #else
  4587. (MethodInfo)MethodInfo.GetCurrentMethod(),
  4588. #endif
  4589. Expression.Constant(provider, typeof(IQbservableProvider)),
  4590. actionAsync,
  4591. Expression.Constant(scheduler, typeof(IScheduler))
  4592. )
  4593. );
  4594. }
  4595. #endif
  4596. #if !NO_TPL
  4597. /// <summary>
  4598. /// Converts to asynchronous action into an observable sequence. Each subscription to the resulting sequence causes the action to be started.
  4599. /// 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.
  4600. /// </summary>
  4601. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  4602. /// <param name="actionAsync">Asynchronous action to convert.</param>
  4603. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  4604. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous function will be signaled.</remarks>
  4605. /// <exception cref="T:System.ArgumentNullException">
  4606. /// <paramref name="actionAsync" /> is null.</exception>
  4607. public static IQbservable<Unit> FromAsync(this IQbservableProvider provider, Expression<Func<CancellationToken, Task>> actionAsync)
  4608. {
  4609. if (provider == null)
  4610. throw new ArgumentNullException("provider");
  4611. if (actionAsync == null)
  4612. throw new ArgumentNullException("actionAsync");
  4613. return provider.CreateQuery<Unit>(
  4614. Expression.Call(
  4615. null,
  4616. #if CRIPPLED_REFLECTION
  4617. InfoOf(() => Qbservable.FromAsync(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task>>))),
  4618. #else
  4619. (MethodInfo)MethodInfo.GetCurrentMethod(),
  4620. #endif
  4621. Expression.Constant(provider, typeof(IQbservableProvider)),
  4622. actionAsync
  4623. )
  4624. );
  4625. }
  4626. #endif
  4627. #if !NO_TPL
  4628. /// <summary>
  4629. /// Converts to asynchronous action into an observable sequence. Each subscription to the resulting sequence causes the action to be started.
  4630. /// 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.
  4631. /// </summary>
  4632. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  4633. /// <param name="actionAsync">Asynchronous action to convert.</param>
  4634. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  4635. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  4636. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous function will be signaled.</remarks>
  4637. /// <exception cref="T:System.ArgumentNullException">
  4638. /// <paramref name="actionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  4639. public static IQbservable<Unit> FromAsync(this IQbservableProvider provider, Expression<Func<CancellationToken, Task>> actionAsync, IScheduler scheduler)
  4640. {
  4641. if (provider == null)
  4642. throw new ArgumentNullException("provider");
  4643. if (actionAsync == null)
  4644. throw new ArgumentNullException("actionAsync");
  4645. if (scheduler == null)
  4646. throw new ArgumentNullException("scheduler");
  4647. return provider.CreateQuery<Unit>(
  4648. Expression.Call(
  4649. null,
  4650. #if CRIPPLED_REFLECTION
  4651. InfoOf(() => Qbservable.FromAsync(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task>>), default(IScheduler))),
  4652. #else
  4653. (MethodInfo)MethodInfo.GetCurrentMethod(),
  4654. #endif
  4655. Expression.Constant(provider, typeof(IQbservableProvider)),
  4656. actionAsync,
  4657. Expression.Constant(scheduler, typeof(IScheduler))
  4658. )
  4659. );
  4660. }
  4661. #endif
  4662. #if !NO_TPL
  4663. /// <summary>
  4664. /// Converts to asynchronous function into an observable sequence. Each subscription to the resulting sequence causes the function to be started.
  4665. /// </summary>
  4666. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  4667. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  4668. /// <param name="functionAsync">Asynchronous function to convert.</param>
  4669. /// <returns>An observable sequence exposing the result of invoking the function, or an exception.</returns>
  4670. /// <exception cref="T:System.ArgumentNullException">
  4671. /// <paramref name="functionAsync" /> is null.</exception>
  4672. public static IQbservable<TResult> FromAsync<TResult>(this IQbservableProvider provider, Expression<Func<Task<TResult>>> functionAsync)
  4673. {
  4674. if (provider == null)
  4675. throw new ArgumentNullException("provider");
  4676. if (functionAsync == null)
  4677. throw new ArgumentNullException("functionAsync");
  4678. return provider.CreateQuery<TResult>(
  4679. Expression.Call(
  4680. null,
  4681. #if CRIPPLED_REFLECTION
  4682. InfoOf(() => Qbservable.FromAsync<TResult>(default(IQbservableProvider), default(Expression<Func<Task<TResult>>>))),
  4683. #else
  4684. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4685. #endif
  4686. Expression.Constant(provider, typeof(IQbservableProvider)),
  4687. functionAsync
  4688. )
  4689. );
  4690. }
  4691. #endif
  4692. #if !NO_TPL
  4693. /// <summary>
  4694. /// Converts to asynchronous function into an observable sequence. Each subscription to the resulting sequence causes the function to be started.
  4695. /// 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.
  4696. /// </summary>
  4697. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  4698. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  4699. /// <param name="functionAsync">Asynchronous function to convert.</param>
  4700. /// <returns>An observable sequence exposing the result of invoking the function, or an exception.</returns>
  4701. /// <exception cref="T:System.ArgumentNullException">
  4702. /// <paramref name="functionAsync" /> is null.</exception>
  4703. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous function will be signaled.</remarks>
  4704. public static IQbservable<TResult> FromAsync<TResult>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<TResult>>> functionAsync)
  4705. {
  4706. if (provider == null)
  4707. throw new ArgumentNullException("provider");
  4708. if (functionAsync == null)
  4709. throw new ArgumentNullException("functionAsync");
  4710. return provider.CreateQuery<TResult>(
  4711. Expression.Call(
  4712. null,
  4713. #if CRIPPLED_REFLECTION
  4714. InfoOf(() => Qbservable.FromAsync<TResult>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<TResult>>>))),
  4715. #else
  4716. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4717. #endif
  4718. Expression.Constant(provider, typeof(IQbservableProvider)),
  4719. functionAsync
  4720. )
  4721. );
  4722. }
  4723. #endif
  4724. #if !NO_TPL
  4725. /// <summary>
  4726. /// Converts to asynchronous function into an observable sequence. Each subscription to the resulting sequence causes the function to be started.
  4727. /// </summary>
  4728. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  4729. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  4730. /// <param name="functionAsync">Asynchronous function to convert.</param>
  4731. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  4732. /// <returns>An observable sequence exposing the result of invoking the function, or an exception.</returns>
  4733. /// <exception cref="T:System.ArgumentNullException">
  4734. /// <paramref name="functionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  4735. public static IQbservable<TResult> FromAsync<TResult>(this IQbservableProvider provider, Expression<Func<Task<TResult>>> functionAsync, IScheduler scheduler)
  4736. {
  4737. if (provider == null)
  4738. throw new ArgumentNullException("provider");
  4739. if (functionAsync == null)
  4740. throw new ArgumentNullException("functionAsync");
  4741. if (scheduler == null)
  4742. throw new ArgumentNullException("scheduler");
  4743. return provider.CreateQuery<TResult>(
  4744. Expression.Call(
  4745. null,
  4746. #if CRIPPLED_REFLECTION
  4747. InfoOf(() => Qbservable.FromAsync<TResult>(default(IQbservableProvider), default(Expression<Func<Task<TResult>>>), default(IScheduler))),
  4748. #else
  4749. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4750. #endif
  4751. Expression.Constant(provider, typeof(IQbservableProvider)),
  4752. functionAsync,
  4753. Expression.Constant(scheduler, typeof(IScheduler))
  4754. )
  4755. );
  4756. }
  4757. #endif
  4758. #if !NO_TPL
  4759. /// <summary>
  4760. /// Converts to asynchronous function into an observable sequence. Each subscription to the resulting sequence causes the function to be started.
  4761. /// 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.
  4762. /// </summary>
  4763. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  4764. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  4765. /// <param name="functionAsync">Asynchronous function to convert.</param>
  4766. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  4767. /// <returns>An observable sequence exposing the result of invoking the function, or an exception.</returns>
  4768. /// <exception cref="T:System.ArgumentNullException">
  4769. /// <paramref name="functionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  4770. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous function will be signaled.</remarks>
  4771. public static IQbservable<TResult> FromAsync<TResult>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<TResult>>> functionAsync, IScheduler scheduler)
  4772. {
  4773. if (provider == null)
  4774. throw new ArgumentNullException("provider");
  4775. if (functionAsync == null)
  4776. throw new ArgumentNullException("functionAsync");
  4777. if (scheduler == null)
  4778. throw new ArgumentNullException("scheduler");
  4779. return provider.CreateQuery<TResult>(
  4780. Expression.Call(
  4781. null,
  4782. #if CRIPPLED_REFLECTION
  4783. InfoOf(() => Qbservable.FromAsync<TResult>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<TResult>>>), default(IScheduler))),
  4784. #else
  4785. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4786. #endif
  4787. Expression.Constant(provider, typeof(IQbservableProvider)),
  4788. functionAsync,
  4789. Expression.Constant(scheduler, typeof(IScheduler))
  4790. )
  4791. );
  4792. }
  4793. #endif
  4794. /// <summary>
  4795. /// Converts an Action-based .NET event to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence.
  4796. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  4797. /// </summary>
  4798. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  4799. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  4800. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  4801. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  4802. /// <exception cref="T:System.ArgumentNullException">
  4803. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  4804. /// <remarks>
  4805. /// <para>
  4806. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  4807. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  4808. /// </para>
  4809. /// <para>
  4810. /// 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.
  4811. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  4812. /// </para>
  4813. /// <para>
  4814. /// If no SynchronizationContext is present at the point of calling FromEvent, add and remove handler invocations are made synchronously on the thread
  4815. /// making the Subscribe or Dispose call, respectively.
  4816. /// </para>
  4817. /// <para>
  4818. /// It's recommended to lift FromEvent calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  4819. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  4820. /// more concise and easier to understand.
  4821. /// </para>
  4822. /// </remarks>
  4823. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  4824. public static IQbservable<Unit> FromEvent(this IQbservableProvider provider, Expression<Action<Action>> addHandler, Expression<Action<Action>> removeHandler)
  4825. {
  4826. if (provider == null)
  4827. throw new ArgumentNullException("provider");
  4828. if (addHandler == null)
  4829. throw new ArgumentNullException("addHandler");
  4830. if (removeHandler == null)
  4831. throw new ArgumentNullException("removeHandler");
  4832. return provider.CreateQuery<Unit>(
  4833. Expression.Call(
  4834. null,
  4835. #if CRIPPLED_REFLECTION
  4836. InfoOf(() => Qbservable.FromEvent(default(IQbservableProvider), default(Expression<Action<Action>>), default(Expression<Action<Action>>))),
  4837. #else
  4838. (MethodInfo)MethodInfo.GetCurrentMethod(),
  4839. #endif
  4840. Expression.Constant(provider, typeof(IQbservableProvider)),
  4841. addHandler,
  4842. removeHandler
  4843. )
  4844. );
  4845. }
  4846. /// <summary>
  4847. /// Converts an Action-based .NET event to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence.
  4848. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  4849. /// </summary>
  4850. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  4851. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  4852. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  4853. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  4854. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  4855. /// <exception cref="T:System.ArgumentNullException">
  4856. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  4857. /// <remarks>
  4858. /// <para>
  4859. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  4860. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  4861. /// </para>
  4862. /// <para>
  4863. /// 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
  4864. /// accessed from the same context, as required by some UI frameworks.
  4865. /// </para>
  4866. /// <para>
  4867. /// It's recommended to lift FromEvent calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  4868. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEvent that omit the IScheduler
  4869. /// parameter. For more information, see the remarks section on those overloads.
  4870. /// </para>
  4871. /// </remarks>
  4872. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  4873. public static IQbservable<Unit> FromEvent(this IQbservableProvider provider, Expression<Action<Action>> addHandler, Expression<Action<Action>> removeHandler, IScheduler scheduler)
  4874. {
  4875. if (provider == null)
  4876. throw new ArgumentNullException("provider");
  4877. if (addHandler == null)
  4878. throw new ArgumentNullException("addHandler");
  4879. if (removeHandler == null)
  4880. throw new ArgumentNullException("removeHandler");
  4881. if (scheduler == null)
  4882. throw new ArgumentNullException("scheduler");
  4883. return provider.CreateQuery<Unit>(
  4884. Expression.Call(
  4885. null,
  4886. #if CRIPPLED_REFLECTION
  4887. InfoOf(() => Qbservable.FromEvent(default(IQbservableProvider), default(Expression<Action<Action>>), default(Expression<Action<Action>>), default(IScheduler))),
  4888. #else
  4889. (MethodInfo)MethodInfo.GetCurrentMethod(),
  4890. #endif
  4891. Expression.Constant(provider, typeof(IQbservableProvider)),
  4892. addHandler,
  4893. removeHandler,
  4894. Expression.Constant(scheduler, typeof(IScheduler))
  4895. )
  4896. );
  4897. }
  4898. /// <summary>
  4899. /// 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.
  4900. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  4901. /// </summary>
  4902. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  4903. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  4904. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  4905. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  4906. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  4907. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  4908. /// <exception cref="T:System.ArgumentNullException">
  4909. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  4910. /// <remarks>
  4911. /// <para>
  4912. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  4913. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  4914. /// </para>
  4915. /// <para>
  4916. /// 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.
  4917. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  4918. /// </para>
  4919. /// <para>
  4920. /// If no SynchronizationContext is present at the point of calling FromEvent, add and remove handler invocations are made synchronously on the thread
  4921. /// making the Subscribe or Dispose call, respectively.
  4922. /// </para>
  4923. /// <para>
  4924. /// It's recommended to lift FromEvent calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  4925. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  4926. /// more concise and easier to understand.
  4927. /// </para>
  4928. /// </remarks>
  4929. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  4930. public static IQbservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)
  4931. {
  4932. if (provider == null)
  4933. throw new ArgumentNullException("provider");
  4934. if (addHandler == null)
  4935. throw new ArgumentNullException("addHandler");
  4936. if (removeHandler == null)
  4937. throw new ArgumentNullException("removeHandler");
  4938. return provider.CreateQuery<TEventArgs>(
  4939. Expression.Call(
  4940. null,
  4941. #if CRIPPLED_REFLECTION
  4942. InfoOf(() => Qbservable.FromEvent<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>))),
  4943. #else
  4944. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  4945. #endif
  4946. Expression.Constant(provider, typeof(IQbservableProvider)),
  4947. addHandler,
  4948. removeHandler
  4949. )
  4950. );
  4951. }
  4952. /// <summary>
  4953. /// 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.
  4954. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  4955. /// </summary>
  4956. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  4957. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  4958. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  4959. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  4960. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  4961. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  4962. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  4963. /// <exception cref="T:System.ArgumentNullException">
  4964. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  4965. /// <remarks>
  4966. /// <para>
  4967. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  4968. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  4969. /// </para>
  4970. /// <para>
  4971. /// 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
  4972. /// accessed from the same context, as required by some UI frameworks.
  4973. /// </para>
  4974. /// <para>
  4975. /// It's recommended to lift FromEvent calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  4976. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEvent that omit the IScheduler
  4977. /// parameter. For more information, see the remarks section on those overloads.
  4978. /// </para>
  4979. /// </remarks>
  4980. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  4981. public static IQbservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler, IScheduler scheduler)
  4982. {
  4983. if (provider == null)
  4984. throw new ArgumentNullException("provider");
  4985. if (addHandler == null)
  4986. throw new ArgumentNullException("addHandler");
  4987. if (removeHandler == null)
  4988. throw new ArgumentNullException("removeHandler");
  4989. if (scheduler == null)
  4990. throw new ArgumentNullException("scheduler");
  4991. return provider.CreateQuery<TEventArgs>(
  4992. Expression.Call(
  4993. null,
  4994. #if CRIPPLED_REFLECTION
  4995. InfoOf(() => Qbservable.FromEvent<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>), default(IScheduler))),
  4996. #else
  4997. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  4998. #endif
  4999. Expression.Constant(provider, typeof(IQbservableProvider)),
  5000. addHandler,
  5001. removeHandler,
  5002. Expression.Constant(scheduler, typeof(IScheduler))
  5003. )
  5004. );
  5005. }
  5006. /// <summary>
  5007. /// 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.
  5008. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  5009. /// </summary>
  5010. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5011. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5012. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5013. /// <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>
  5014. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5015. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5016. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  5017. /// <exception cref="T:System.ArgumentNullException">
  5018. /// <paramref name="conversion" /> or <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  5019. /// <remarks>
  5020. /// <para>
  5021. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5022. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5023. /// </para>
  5024. /// <para>
  5025. /// 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.
  5026. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5027. /// </para>
  5028. /// <para>
  5029. /// If no SynchronizationContext is present at the point of calling FromEvent, add and remove handler invocations are made synchronously on the thread
  5030. /// making the Subscribe or Dispose call, respectively.
  5031. /// </para>
  5032. /// <para>
  5033. /// It's recommended to lift FromEvent calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5034. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5035. /// more concise and easier to understand.
  5036. /// </para>
  5037. /// </remarks>
  5038. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  5039. public static IQbservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Func<Action<TEventArgs>, TDelegate>> conversion, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)
  5040. {
  5041. if (provider == null)
  5042. throw new ArgumentNullException("provider");
  5043. if (conversion == null)
  5044. throw new ArgumentNullException("conversion");
  5045. if (addHandler == null)
  5046. throw new ArgumentNullException("addHandler");
  5047. if (removeHandler == null)
  5048. throw new ArgumentNullException("removeHandler");
  5049. return provider.CreateQuery<TEventArgs>(
  5050. Expression.Call(
  5051. null,
  5052. #if CRIPPLED_REFLECTION
  5053. InfoOf(() => Qbservable.FromEvent<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Func<Action<TEventArgs>, TDelegate>>), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>))),
  5054. #else
  5055. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  5056. #endif
  5057. Expression.Constant(provider, typeof(IQbservableProvider)),
  5058. conversion,
  5059. addHandler,
  5060. removeHandler
  5061. )
  5062. );
  5063. }
  5064. /// <summary>
  5065. /// 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.
  5066. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  5067. /// </summary>
  5068. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5069. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5070. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5071. /// <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>
  5072. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5073. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5074. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5075. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  5076. /// <exception cref="T:System.ArgumentNullException">
  5077. /// <paramref name="conversion" /> or <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5078. /// <remarks>
  5079. /// <para>
  5080. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5081. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5082. /// </para>
  5083. /// <para>
  5084. /// 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
  5085. /// accessed from the same context, as required by some UI frameworks.
  5086. /// </para>
  5087. /// <para>
  5088. /// It's recommended to lift FromEvent calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5089. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEvent that omit the IScheduler
  5090. /// parameter. For more information, see the remarks section on those overloads.
  5091. /// </para>
  5092. /// </remarks>
  5093. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  5094. 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)
  5095. {
  5096. if (provider == null)
  5097. throw new ArgumentNullException("provider");
  5098. if (conversion == null)
  5099. throw new ArgumentNullException("conversion");
  5100. if (addHandler == null)
  5101. throw new ArgumentNullException("addHandler");
  5102. if (removeHandler == null)
  5103. throw new ArgumentNullException("removeHandler");
  5104. if (scheduler == null)
  5105. throw new ArgumentNullException("scheduler");
  5106. return provider.CreateQuery<TEventArgs>(
  5107. Expression.Call(
  5108. null,
  5109. #if CRIPPLED_REFLECTION
  5110. InfoOf(() => Qbservable.FromEvent<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Func<Action<TEventArgs>, TDelegate>>), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>), default(IScheduler))),
  5111. #else
  5112. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  5113. #endif
  5114. Expression.Constant(provider, typeof(IQbservableProvider)),
  5115. conversion,
  5116. addHandler,
  5117. removeHandler,
  5118. Expression.Constant(scheduler, typeof(IScheduler))
  5119. )
  5120. );
  5121. }
  5122. /// <summary>
  5123. /// Converts a generic Action-based .NET event to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5124. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  5125. /// </summary>
  5126. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5127. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5128. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5129. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5130. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  5131. /// <exception cref="T:System.ArgumentNullException">
  5132. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  5133. /// <remarks>
  5134. /// <para>
  5135. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5136. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5137. /// </para>
  5138. /// <para>
  5139. /// 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.
  5140. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5141. /// </para>
  5142. /// <para>
  5143. /// If no SynchronizationContext is present at the point of calling FromEvent, add and remove handler invocations are made synchronously on the thread
  5144. /// making the Subscribe or Dispose call, respectively.
  5145. /// </para>
  5146. /// <para>
  5147. /// It's recommended to lift FromEvent calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5148. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5149. /// more concise and easier to understand.
  5150. /// </para>
  5151. /// </remarks>
  5152. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  5153. public static IQbservable<TEventArgs> FromEvent<TEventArgs>(this IQbservableProvider provider, Expression<Action<Action<TEventArgs>>> addHandler, Expression<Action<Action<TEventArgs>>> removeHandler)
  5154. {
  5155. if (provider == null)
  5156. throw new ArgumentNullException("provider");
  5157. if (addHandler == null)
  5158. throw new ArgumentNullException("addHandler");
  5159. if (removeHandler == null)
  5160. throw new ArgumentNullException("removeHandler");
  5161. return provider.CreateQuery<TEventArgs>(
  5162. Expression.Call(
  5163. null,
  5164. #if CRIPPLED_REFLECTION
  5165. InfoOf(() => Qbservable.FromEvent<TEventArgs>(default(IQbservableProvider), default(Expression<Action<Action<TEventArgs>>>), default(Expression<Action<Action<TEventArgs>>>))),
  5166. #else
  5167. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  5168. #endif
  5169. Expression.Constant(provider, typeof(IQbservableProvider)),
  5170. addHandler,
  5171. removeHandler
  5172. )
  5173. );
  5174. }
  5175. /// <summary>
  5176. /// Converts a generic Action-based .NET event to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5177. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  5178. /// </summary>
  5179. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5180. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5181. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5182. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5183. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5184. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  5185. /// <exception cref="T:System.ArgumentNullException">
  5186. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5187. /// <remarks>
  5188. /// <para>
  5189. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5190. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5191. /// </para>
  5192. /// <para>
  5193. /// 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
  5194. /// accessed from the same context, as required by some UI frameworks.
  5195. /// </para>
  5196. /// <para>
  5197. /// It's recommended to lift FromEvent calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5198. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEvent that omit the IScheduler
  5199. /// parameter. For more information, see the remarks section on those overloads.
  5200. /// </para>
  5201. /// </remarks>
  5202. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  5203. public static IQbservable<TEventArgs> FromEvent<TEventArgs>(this IQbservableProvider provider, Expression<Action<Action<TEventArgs>>> addHandler, Expression<Action<Action<TEventArgs>>> removeHandler, IScheduler scheduler)
  5204. {
  5205. if (provider == null)
  5206. throw new ArgumentNullException("provider");
  5207. if (addHandler == null)
  5208. throw new ArgumentNullException("addHandler");
  5209. if (removeHandler == null)
  5210. throw new ArgumentNullException("removeHandler");
  5211. if (scheduler == null)
  5212. throw new ArgumentNullException("scheduler");
  5213. return provider.CreateQuery<TEventArgs>(
  5214. Expression.Call(
  5215. null,
  5216. #if CRIPPLED_REFLECTION
  5217. InfoOf(() => Qbservable.FromEvent<TEventArgs>(default(IQbservableProvider), default(Expression<Action<Action<TEventArgs>>>), default(Expression<Action<Action<TEventArgs>>>), default(IScheduler))),
  5218. #else
  5219. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  5220. #endif
  5221. Expression.Constant(provider, typeof(IQbservableProvider)),
  5222. addHandler,
  5223. removeHandler,
  5224. Expression.Constant(scheduler, typeof(IScheduler))
  5225. )
  5226. );
  5227. }
  5228. #if !NO_EVENTARGS_CONSTRAINT
  5229. /// <summary>
  5230. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="T:System.EventHandler" />, to an observable sequence.
  5231. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5232. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5233. /// </summary>
  5234. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5235. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5236. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5237. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5238. /// <exception cref="T:System.ArgumentNullException">
  5239. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  5240. /// <remarks>
  5241. /// <para>
  5242. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5243. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5244. /// </para>
  5245. /// <para>
  5246. /// 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.
  5247. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5248. /// </para>
  5249. /// <para>
  5250. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5251. /// making the Subscribe or Dispose call, respectively.
  5252. /// </para>
  5253. /// <para>
  5254. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5255. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5256. /// more concise and easier to understand.
  5257. /// </para>
  5258. /// </remarks>
  5259. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5260. public static IQbservable<EventPattern<EventArgs>> FromEventPattern(this IQbservableProvider provider, Expression<Action<EventHandler>> addHandler, Expression<Action<EventHandler>> removeHandler)
  5261. {
  5262. if (provider == null)
  5263. throw new ArgumentNullException("provider");
  5264. if (addHandler == null)
  5265. throw new ArgumentNullException("addHandler");
  5266. if (removeHandler == null)
  5267. throw new ArgumentNullException("removeHandler");
  5268. return provider.CreateQuery<EventPattern<EventArgs>>(
  5269. Expression.Call(
  5270. null,
  5271. #if CRIPPLED_REFLECTION
  5272. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Expression<Action<EventHandler>>), default(Expression<Action<EventHandler>>))),
  5273. #else
  5274. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5275. #endif
  5276. Expression.Constant(provider, typeof(IQbservableProvider)),
  5277. addHandler,
  5278. removeHandler
  5279. )
  5280. );
  5281. }
  5282. #else
  5283. /// <summary>
  5284. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="T:System.EventHandler" />, to an observable sequence.
  5285. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5286. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5287. /// </summary>
  5288. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5289. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5290. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5291. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5292. /// <exception cref="T:System.ArgumentNullException">
  5293. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  5294. /// <remarks>
  5295. /// <para>
  5296. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5297. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5298. /// </para>
  5299. /// <para>
  5300. /// 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.
  5301. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5302. /// </para>
  5303. /// <para>
  5304. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5305. /// making the Subscribe or Dispose call, respectively.
  5306. /// </para>
  5307. /// <para>
  5308. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5309. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5310. /// more concise and easier to understand.
  5311. /// </para>
  5312. /// </remarks>
  5313. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5314. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, Expression<Action<EventHandler>> addHandler, Expression<Action<EventHandler>> removeHandler)
  5315. {
  5316. if (provider == null)
  5317. throw new ArgumentNullException("provider");
  5318. if (addHandler == null)
  5319. throw new ArgumentNullException("addHandler");
  5320. if (removeHandler == null)
  5321. throw new ArgumentNullException("removeHandler");
  5322. return provider.CreateQuery<EventPattern<object>>(
  5323. Expression.Call(
  5324. null,
  5325. #if CRIPPLED_REFLECTION
  5326. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Expression<Action<EventHandler>>), default(Expression<Action<EventHandler>>))),
  5327. #else
  5328. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5329. #endif
  5330. Expression.Constant(provider, typeof(IQbservableProvider)),
  5331. addHandler,
  5332. removeHandler
  5333. )
  5334. );
  5335. }
  5336. #endif
  5337. #if !NO_EVENTARGS_CONSTRAINT
  5338. /// <summary>
  5339. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="T:System.EventHandler" />, to an observable sequence.
  5340. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5341. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5342. /// </summary>
  5343. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5344. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5345. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5346. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5347. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5348. /// <exception cref="T:System.ArgumentNullException">
  5349. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5350. /// <remarks>
  5351. /// <para>
  5352. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5353. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5354. /// </para>
  5355. /// <para>
  5356. /// 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
  5357. /// accessed from the same context, as required by some UI frameworks.
  5358. /// </para>
  5359. /// <para>
  5360. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5361. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5362. /// parameter. For more information, see the remarks section on those overloads.
  5363. /// </para>
  5364. /// </remarks>
  5365. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5366. public static IQbservable<EventPattern<EventArgs>> FromEventPattern(this IQbservableProvider provider, Expression<Action<EventHandler>> addHandler, Expression<Action<EventHandler>> removeHandler, IScheduler scheduler)
  5367. {
  5368. if (provider == null)
  5369. throw new ArgumentNullException("provider");
  5370. if (addHandler == null)
  5371. throw new ArgumentNullException("addHandler");
  5372. if (removeHandler == null)
  5373. throw new ArgumentNullException("removeHandler");
  5374. if (scheduler == null)
  5375. throw new ArgumentNullException("scheduler");
  5376. return provider.CreateQuery<EventPattern<EventArgs>>(
  5377. Expression.Call(
  5378. null,
  5379. #if CRIPPLED_REFLECTION
  5380. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Expression<Action<EventHandler>>), default(Expression<Action<EventHandler>>), default(IScheduler))),
  5381. #else
  5382. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5383. #endif
  5384. Expression.Constant(provider, typeof(IQbservableProvider)),
  5385. addHandler,
  5386. removeHandler,
  5387. Expression.Constant(scheduler, typeof(IScheduler))
  5388. )
  5389. );
  5390. }
  5391. #else
  5392. /// <summary>
  5393. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="T:System.EventHandler" />, to an observable sequence.
  5394. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5395. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5396. /// </summary>
  5397. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5398. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5399. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5400. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5401. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5402. /// <exception cref="T:System.ArgumentNullException">
  5403. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5404. /// <remarks>
  5405. /// <para>
  5406. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5407. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5408. /// </para>
  5409. /// <para>
  5410. /// 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
  5411. /// accessed from the same context, as required by some UI frameworks.
  5412. /// </para>
  5413. /// <para>
  5414. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5415. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5416. /// parameter. For more information, see the remarks section on those overloads.
  5417. /// </para>
  5418. /// </remarks>
  5419. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5420. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, Expression<Action<EventHandler>> addHandler, Expression<Action<EventHandler>> removeHandler, IScheduler scheduler)
  5421. {
  5422. if (provider == null)
  5423. throw new ArgumentNullException("provider");
  5424. if (addHandler == null)
  5425. throw new ArgumentNullException("addHandler");
  5426. if (removeHandler == null)
  5427. throw new ArgumentNullException("removeHandler");
  5428. if (scheduler == null)
  5429. throw new ArgumentNullException("scheduler");
  5430. return provider.CreateQuery<EventPattern<object>>(
  5431. Expression.Call(
  5432. null,
  5433. #if CRIPPLED_REFLECTION
  5434. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Expression<Action<EventHandler>>), default(Expression<Action<EventHandler>>), default(IScheduler))),
  5435. #else
  5436. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5437. #endif
  5438. Expression.Constant(provider, typeof(IQbservableProvider)),
  5439. addHandler,
  5440. removeHandler,
  5441. Expression.Constant(scheduler, typeof(IScheduler))
  5442. )
  5443. );
  5444. }
  5445. #endif
  5446. #if !NO_EVENTARGS_CONSTRAINT
  5447. /// <summary>
  5448. /// Converts an instance .NET event, conforming to the standard .NET event pattern with an <see cref="T:System.EventArgs" /> parameter, to an observable sequence.
  5449. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5450. /// Reflection is used to discover the event based on the target object type and the specified event name.
  5451. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5452. /// </summary>
  5453. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5454. /// <param name="target">Object instance that exposes the event to convert.</param>
  5455. /// <param name="eventName">Name of the event to convert.</param>
  5456. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5457. /// <exception cref="T:System.ArgumentNullException">
  5458. /// <paramref name="target" /> or <paramref name="eventName" /> is null.</exception>
  5459. /// <exception cref="T:System.InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5460. /// <remarks>
  5461. /// <para>
  5462. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5463. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5464. /// </para>
  5465. /// <para>
  5466. /// 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.
  5467. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5468. /// </para>
  5469. /// <para>
  5470. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5471. /// making the Subscribe or Dispose call, respectively.
  5472. /// </para>
  5473. /// <para>
  5474. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5475. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5476. /// more concise and easier to understand.
  5477. /// </para>
  5478. /// </remarks>
  5479. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5480. public static IQbservable<EventPattern<EventArgs>> FromEventPattern(this IQbservableProvider provider, object target, string eventName)
  5481. {
  5482. if (provider == null)
  5483. throw new ArgumentNullException("provider");
  5484. if (target == null)
  5485. throw new ArgumentNullException("target");
  5486. if (eventName == null)
  5487. throw new ArgumentNullException("eventName");
  5488. return provider.CreateQuery<EventPattern<EventArgs>>(
  5489. Expression.Call(
  5490. null,
  5491. #if CRIPPLED_REFLECTION
  5492. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(object), default(string))),
  5493. #else
  5494. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5495. #endif
  5496. Expression.Constant(provider, typeof(IQbservableProvider)),
  5497. Expression.Constant(target, typeof(object)),
  5498. Expression.Constant(eventName, typeof(string))
  5499. )
  5500. );
  5501. }
  5502. #else
  5503. /// <summary>
  5504. /// Converts an instance .NET event, conforming to the standard .NET event pattern with an <see cref="T:System.EventArgs" /> parameter, to an observable sequence.
  5505. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5506. /// Reflection is used to discover the event based on the target object type and the specified event name.
  5507. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5508. /// </summary>
  5509. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5510. /// <param name="target">Object instance that exposes the event to convert.</param>
  5511. /// <param name="eventName">Name of the event to convert.</param>
  5512. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5513. /// <exception cref="T:System.ArgumentNullException">
  5514. /// <paramref name="target" /> or <paramref name="eventName" /> is null.</exception>
  5515. /// <exception cref="T:System.InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5516. /// <remarks>
  5517. /// <para>
  5518. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5519. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5520. /// </para>
  5521. /// <para>
  5522. /// 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.
  5523. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5524. /// </para>
  5525. /// <para>
  5526. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5527. /// making the Subscribe or Dispose call, respectively.
  5528. /// </para>
  5529. /// <para>
  5530. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5531. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5532. /// more concise and easier to understand.
  5533. /// </para>
  5534. /// </remarks>
  5535. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5536. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, object target, string eventName)
  5537. {
  5538. if (provider == null)
  5539. throw new ArgumentNullException("provider");
  5540. if (target == null)
  5541. throw new ArgumentNullException("target");
  5542. if (eventName == null)
  5543. throw new ArgumentNullException("eventName");
  5544. return provider.CreateQuery<EventPattern<object>>(
  5545. Expression.Call(
  5546. null,
  5547. #if CRIPPLED_REFLECTION
  5548. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(object), default(string))),
  5549. #else
  5550. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5551. #endif
  5552. Expression.Constant(provider, typeof(IQbservableProvider)),
  5553. Expression.Constant(target, typeof(object)),
  5554. Expression.Constant(eventName, typeof(string))
  5555. )
  5556. );
  5557. }
  5558. #endif
  5559. #if !NO_EVENTARGS_CONSTRAINT
  5560. /// <summary>
  5561. /// Converts an instance .NET event, conforming to the standard .NET event pattern with an <see cref="T:System.EventArgs" /> parameter, to an observable sequence.
  5562. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5563. /// Reflection is used to discover the event based on the target object type and the specified event name.
  5564. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5565. /// </summary>
  5566. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5567. /// <param name="target">Object instance that exposes the event to convert.</param>
  5568. /// <param name="eventName">Name of the event to convert.</param>
  5569. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5570. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5571. /// <exception cref="T:System.ArgumentNullException">
  5572. /// <paramref name="target" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  5573. /// <exception cref="T:System.InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5574. /// <remarks>
  5575. /// <para>
  5576. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5577. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5578. /// </para>
  5579. /// <para>
  5580. /// 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
  5581. /// accessed from the same context, as required by some UI frameworks.
  5582. /// </para>
  5583. /// <para>
  5584. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5585. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5586. /// parameter. For more information, see the remarks section on those overloads.
  5587. /// </para>
  5588. /// </remarks>
  5589. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5590. public static IQbservable<EventPattern<EventArgs>> FromEventPattern(this IQbservableProvider provider, object target, string eventName, IScheduler scheduler)
  5591. {
  5592. if (provider == null)
  5593. throw new ArgumentNullException("provider");
  5594. if (target == null)
  5595. throw new ArgumentNullException("target");
  5596. if (eventName == null)
  5597. throw new ArgumentNullException("eventName");
  5598. if (scheduler == null)
  5599. throw new ArgumentNullException("scheduler");
  5600. return provider.CreateQuery<EventPattern<EventArgs>>(
  5601. Expression.Call(
  5602. null,
  5603. #if CRIPPLED_REFLECTION
  5604. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(object), default(string), default(IScheduler))),
  5605. #else
  5606. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5607. #endif
  5608. Expression.Constant(provider, typeof(IQbservableProvider)),
  5609. Expression.Constant(target, typeof(object)),
  5610. Expression.Constant(eventName, typeof(string)),
  5611. Expression.Constant(scheduler, typeof(IScheduler))
  5612. )
  5613. );
  5614. }
  5615. #else
  5616. /// <summary>
  5617. /// Converts an instance .NET event, conforming to the standard .NET event pattern with an <see cref="T:System.EventArgs" /> parameter, to an observable sequence.
  5618. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5619. /// Reflection is used to discover the event based on the target object type and the specified event name.
  5620. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5621. /// </summary>
  5622. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5623. /// <param name="target">Object instance that exposes the event to convert.</param>
  5624. /// <param name="eventName">Name of the event to convert.</param>
  5625. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5626. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5627. /// <exception cref="T:System.ArgumentNullException">
  5628. /// <paramref name="target" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  5629. /// <exception cref="T:System.InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5630. /// <remarks>
  5631. /// <para>
  5632. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5633. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5634. /// </para>
  5635. /// <para>
  5636. /// 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
  5637. /// accessed from the same context, as required by some UI frameworks.
  5638. /// </para>
  5639. /// <para>
  5640. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5641. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5642. /// parameter. For more information, see the remarks section on those overloads.
  5643. /// </para>
  5644. /// </remarks>
  5645. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5646. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, object target, string eventName, IScheduler scheduler)
  5647. {
  5648. if (provider == null)
  5649. throw new ArgumentNullException("provider");
  5650. if (target == null)
  5651. throw new ArgumentNullException("target");
  5652. if (eventName == null)
  5653. throw new ArgumentNullException("eventName");
  5654. if (scheduler == null)
  5655. throw new ArgumentNullException("scheduler");
  5656. return provider.CreateQuery<EventPattern<object>>(
  5657. Expression.Call(
  5658. null,
  5659. #if CRIPPLED_REFLECTION
  5660. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(object), default(string), default(IScheduler))),
  5661. #else
  5662. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5663. #endif
  5664. Expression.Constant(provider, typeof(IQbservableProvider)),
  5665. Expression.Constant(target, typeof(object)),
  5666. Expression.Constant(eventName, typeof(string)),
  5667. Expression.Constant(scheduler, typeof(IScheduler))
  5668. )
  5669. );
  5670. }
  5671. #endif
  5672. #if !NO_EVENTARGS_CONSTRAINT
  5673. /// <summary>
  5674. /// Converts a static .NET event, conforming to the standard .NET event pattern with an <see cref="T:System.EventArgs" /> parameter, to an observable sequence.
  5675. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5676. /// Reflection is used to discover the event based on the specified type and the specified event name.
  5677. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5678. /// </summary>
  5679. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5680. /// <param name="type">Type that exposes the static event to convert.</param>
  5681. /// <param name="eventName">Name of the event to convert.</param>
  5682. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5683. /// <exception cref="T:System.ArgumentNullException">
  5684. /// <paramref name="type" /> or <paramref name="eventName" /> is null.</exception>
  5685. /// <exception cref="T:System.InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5686. /// <remarks>
  5687. /// <para>
  5688. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5689. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5690. /// </para>
  5691. /// <para>
  5692. /// 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.
  5693. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5694. /// </para>
  5695. /// <para>
  5696. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5697. /// making the Subscribe or Dispose call, respectively.
  5698. /// </para>
  5699. /// <para>
  5700. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5701. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5702. /// more concise and easier to understand.
  5703. /// </para>
  5704. /// </remarks>
  5705. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5706. public static IQbservable<EventPattern<EventArgs>> FromEventPattern(this IQbservableProvider provider, Type type, string eventName)
  5707. {
  5708. if (provider == null)
  5709. throw new ArgumentNullException("provider");
  5710. if (type == null)
  5711. throw new ArgumentNullException("type");
  5712. if (eventName == null)
  5713. throw new ArgumentNullException("eventName");
  5714. return provider.CreateQuery<EventPattern<EventArgs>>(
  5715. Expression.Call(
  5716. null,
  5717. #if CRIPPLED_REFLECTION
  5718. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Type), default(string))),
  5719. #else
  5720. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5721. #endif
  5722. Expression.Constant(provider, typeof(IQbservableProvider)),
  5723. Expression.Constant(type, typeof(Type)),
  5724. Expression.Constant(eventName, typeof(string))
  5725. )
  5726. );
  5727. }
  5728. #else
  5729. /// <summary>
  5730. /// Converts a static .NET event, conforming to the standard .NET event pattern with an <see cref="T:System.EventArgs" /> parameter, to an observable sequence.
  5731. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5732. /// Reflection is used to discover the event based on the specified type and the specified event name.
  5733. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5734. /// </summary>
  5735. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5736. /// <param name="type">Type that exposes the static event to convert.</param>
  5737. /// <param name="eventName">Name of the event to convert.</param>
  5738. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5739. /// <exception cref="T:System.ArgumentNullException">
  5740. /// <paramref name="type" /> or <paramref name="eventName" /> is null.</exception>
  5741. /// <exception cref="T:System.InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5742. /// <remarks>
  5743. /// <para>
  5744. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5745. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5746. /// </para>
  5747. /// <para>
  5748. /// 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.
  5749. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5750. /// </para>
  5751. /// <para>
  5752. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5753. /// making the Subscribe or Dispose call, respectively.
  5754. /// </para>
  5755. /// <para>
  5756. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5757. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5758. /// more concise and easier to understand.
  5759. /// </para>
  5760. /// </remarks>
  5761. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5762. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, Type type, string eventName)
  5763. {
  5764. if (provider == null)
  5765. throw new ArgumentNullException("provider");
  5766. if (type == null)
  5767. throw new ArgumentNullException("type");
  5768. if (eventName == null)
  5769. throw new ArgumentNullException("eventName");
  5770. return provider.CreateQuery<EventPattern<object>>(
  5771. Expression.Call(
  5772. null,
  5773. #if CRIPPLED_REFLECTION
  5774. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Type), default(string))),
  5775. #else
  5776. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5777. #endif
  5778. Expression.Constant(provider, typeof(IQbservableProvider)),
  5779. Expression.Constant(type, typeof(Type)),
  5780. Expression.Constant(eventName, typeof(string))
  5781. )
  5782. );
  5783. }
  5784. #endif
  5785. #if !NO_EVENTARGS_CONSTRAINT
  5786. /// <summary>
  5787. /// Converts a static .NET event, conforming to the standard .NET event pattern with an <see cref="T:System.EventArgs" /> parameter, to an observable sequence.
  5788. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5789. /// Reflection is used to discover the event based on the specified type and the specified event name.
  5790. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5791. /// </summary>
  5792. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5793. /// <param name="type">Type that exposes the static event to convert.</param>
  5794. /// <param name="eventName">Name of the event to convert.</param>
  5795. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5796. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5797. /// <exception cref="T:System.ArgumentNullException">
  5798. /// <paramref name="type" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  5799. /// <exception cref="T:System.InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5800. /// <remarks>
  5801. /// <para>
  5802. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5803. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5804. /// </para>
  5805. /// <para>
  5806. /// 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
  5807. /// accessed from the same context, as required by some UI frameworks.
  5808. /// </para>
  5809. /// <para>
  5810. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5811. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5812. /// parameter. For more information, see the remarks section on those overloads.
  5813. /// </para>
  5814. /// </remarks>
  5815. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5816. public static IQbservable<EventPattern<EventArgs>> FromEventPattern(this IQbservableProvider provider, Type type, string eventName, IScheduler scheduler)
  5817. {
  5818. if (provider == null)
  5819. throw new ArgumentNullException("provider");
  5820. if (type == null)
  5821. throw new ArgumentNullException("type");
  5822. if (eventName == null)
  5823. throw new ArgumentNullException("eventName");
  5824. if (scheduler == null)
  5825. throw new ArgumentNullException("scheduler");
  5826. return provider.CreateQuery<EventPattern<EventArgs>>(
  5827. Expression.Call(
  5828. null,
  5829. #if CRIPPLED_REFLECTION
  5830. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Type), default(string), default(IScheduler))),
  5831. #else
  5832. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5833. #endif
  5834. Expression.Constant(provider, typeof(IQbservableProvider)),
  5835. Expression.Constant(type, typeof(Type)),
  5836. Expression.Constant(eventName, typeof(string)),
  5837. Expression.Constant(scheduler, typeof(IScheduler))
  5838. )
  5839. );
  5840. }
  5841. #else
  5842. /// <summary>
  5843. /// Converts a static .NET event, conforming to the standard .NET event pattern with an <see cref="T:System.EventArgs" /> parameter, to an observable sequence.
  5844. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5845. /// Reflection is used to discover the event based on the specified type and the specified event name.
  5846. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5847. /// </summary>
  5848. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5849. /// <param name="type">Type that exposes the static event to convert.</param>
  5850. /// <param name="eventName">Name of the event to convert.</param>
  5851. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5852. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5853. /// <exception cref="T:System.ArgumentNullException">
  5854. /// <paramref name="type" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  5855. /// <exception cref="T:System.InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5856. /// <remarks>
  5857. /// <para>
  5858. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5859. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5860. /// </para>
  5861. /// <para>
  5862. /// 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
  5863. /// accessed from the same context, as required by some UI frameworks.
  5864. /// </para>
  5865. /// <para>
  5866. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5867. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5868. /// parameter. For more information, see the remarks section on those overloads.
  5869. /// </para>
  5870. /// </remarks>
  5871. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5872. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, Type type, string eventName, IScheduler scheduler)
  5873. {
  5874. if (provider == null)
  5875. throw new ArgumentNullException("provider");
  5876. if (type == null)
  5877. throw new ArgumentNullException("type");
  5878. if (eventName == null)
  5879. throw new ArgumentNullException("eventName");
  5880. if (scheduler == null)
  5881. throw new ArgumentNullException("scheduler");
  5882. return provider.CreateQuery<EventPattern<object>>(
  5883. Expression.Call(
  5884. null,
  5885. #if CRIPPLED_REFLECTION
  5886. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Type), default(string), default(IScheduler))),
  5887. #else
  5888. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5889. #endif
  5890. Expression.Constant(provider, typeof(IQbservableProvider)),
  5891. Expression.Constant(type, typeof(Type)),
  5892. Expression.Constant(eventName, typeof(string)),
  5893. Expression.Constant(scheduler, typeof(IScheduler))
  5894. )
  5895. );
  5896. }
  5897. #endif
  5898. /// <summary>
  5899. /// Converts a .NET event, conforming to the standard .NET event pattern based on a supplied event delegate type, to an observable sequence.
  5900. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5901. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5902. /// </summary>
  5903. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5904. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5905. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5906. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5907. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5908. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5909. /// <exception cref="T:System.ArgumentNullException">
  5910. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  5911. /// <remarks>
  5912. /// <para>
  5913. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5914. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5915. /// </para>
  5916. /// <para>
  5917. /// 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.
  5918. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5919. /// </para>
  5920. /// <para>
  5921. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5922. /// making the Subscribe or Dispose call, respectively.
  5923. /// </para>
  5924. /// <para>
  5925. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5926. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5927. /// more concise and easier to understand.
  5928. /// </para>
  5929. /// </remarks>
  5930. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5931. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)
  5932. #if !NO_EVENTARGS_CONSTRAINT
  5933. where TEventArgs : EventArgs
  5934. #endif
  5935. {
  5936. if (provider == null)
  5937. throw new ArgumentNullException("provider");
  5938. if (addHandler == null)
  5939. throw new ArgumentNullException("addHandler");
  5940. if (removeHandler == null)
  5941. throw new ArgumentNullException("removeHandler");
  5942. return provider.CreateQuery<EventPattern<TEventArgs>>(
  5943. Expression.Call(
  5944. null,
  5945. #if CRIPPLED_REFLECTION
  5946. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>))),
  5947. #else
  5948. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  5949. #endif
  5950. Expression.Constant(provider, typeof(IQbservableProvider)),
  5951. addHandler,
  5952. removeHandler
  5953. )
  5954. );
  5955. }
  5956. /// <summary>
  5957. /// Converts a .NET event, conforming to the standard .NET event pattern based on a supplied event delegate type, to an observable sequence.
  5958. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5959. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5960. /// </summary>
  5961. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5962. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5963. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5964. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5965. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5966. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5967. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5968. /// <exception cref="T:System.ArgumentNullException">
  5969. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5970. /// <remarks>
  5971. /// <para>
  5972. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5973. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5974. /// </para>
  5975. /// <para>
  5976. /// 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
  5977. /// accessed from the same context, as required by some UI frameworks.
  5978. /// </para>
  5979. /// <para>
  5980. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5981. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5982. /// parameter. For more information, see the remarks section on those overloads.
  5983. /// </para>
  5984. /// </remarks>
  5985. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5986. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler, IScheduler scheduler)
  5987. #if !NO_EVENTARGS_CONSTRAINT
  5988. where TEventArgs : EventArgs
  5989. #endif
  5990. {
  5991. if (provider == null)
  5992. throw new ArgumentNullException("provider");
  5993. if (addHandler == null)
  5994. throw new ArgumentNullException("addHandler");
  5995. if (removeHandler == null)
  5996. throw new ArgumentNullException("removeHandler");
  5997. if (scheduler == null)
  5998. throw new ArgumentNullException("scheduler");
  5999. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6000. Expression.Call(
  6001. null,
  6002. #if CRIPPLED_REFLECTION
  6003. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>), default(IScheduler))),
  6004. #else
  6005. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  6006. #endif
  6007. Expression.Constant(provider, typeof(IQbservableProvider)),
  6008. addHandler,
  6009. removeHandler,
  6010. Expression.Constant(scheduler, typeof(IScheduler))
  6011. )
  6012. );
  6013. }
  6014. /// <summary>
  6015. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="T:System.EventHandler`1" />, to an observable sequence.
  6016. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6017. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6018. /// </summary>
  6019. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6020. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  6021. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6022. /// <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>
  6023. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  6024. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  6025. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6026. /// <exception cref="T:System.ArgumentNullException">
  6027. /// <paramref name="conversion" /> or <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  6028. /// <remarks>
  6029. /// <para>
  6030. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6031. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6032. /// </para>
  6033. /// <para>
  6034. /// 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.
  6035. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  6036. /// </para>
  6037. /// <para>
  6038. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  6039. /// making the Subscribe or Dispose call, respectively.
  6040. /// </para>
  6041. /// <para>
  6042. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  6043. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  6044. /// more concise and easier to understand.
  6045. /// </para>
  6046. /// </remarks>
  6047. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6048. 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)
  6049. #if !NO_EVENTARGS_CONSTRAINT
  6050. where TEventArgs : EventArgs
  6051. #endif
  6052. {
  6053. if (provider == null)
  6054. throw new ArgumentNullException("provider");
  6055. if (conversion == null)
  6056. throw new ArgumentNullException("conversion");
  6057. if (addHandler == null)
  6058. throw new ArgumentNullException("addHandler");
  6059. if (removeHandler == null)
  6060. throw new ArgumentNullException("removeHandler");
  6061. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6062. Expression.Call(
  6063. null,
  6064. #if CRIPPLED_REFLECTION
  6065. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Func<EventHandler<TEventArgs>, TDelegate>>), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>))),
  6066. #else
  6067. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  6068. #endif
  6069. Expression.Constant(provider, typeof(IQbservableProvider)),
  6070. conversion,
  6071. addHandler,
  6072. removeHandler
  6073. )
  6074. );
  6075. }
  6076. /// <summary>
  6077. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="T:System.EventHandler`1" />, to an observable sequence.
  6078. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6079. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6080. /// </summary>
  6081. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6082. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  6083. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6084. /// <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>
  6085. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  6086. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  6087. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  6088. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6089. /// <exception cref="T:System.ArgumentNullException">
  6090. /// <paramref name="conversion" /> or <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  6091. /// <remarks>
  6092. /// <para>
  6093. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6094. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6095. /// </para>
  6096. /// <para>
  6097. /// 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
  6098. /// accessed from the same context, as required by some UI frameworks.
  6099. /// </para>
  6100. /// <para>
  6101. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  6102. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  6103. /// parameter. For more information, see the remarks section on those overloads.
  6104. /// </para>
  6105. /// </remarks>
  6106. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6107. 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)
  6108. #if !NO_EVENTARGS_CONSTRAINT
  6109. where TEventArgs : EventArgs
  6110. #endif
  6111. {
  6112. if (provider == null)
  6113. throw new ArgumentNullException("provider");
  6114. if (conversion == null)
  6115. throw new ArgumentNullException("conversion");
  6116. if (addHandler == null)
  6117. throw new ArgumentNullException("addHandler");
  6118. if (removeHandler == null)
  6119. throw new ArgumentNullException("removeHandler");
  6120. if (scheduler == null)
  6121. throw new ArgumentNullException("scheduler");
  6122. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6123. Expression.Call(
  6124. null,
  6125. #if CRIPPLED_REFLECTION
  6126. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Func<EventHandler<TEventArgs>, TDelegate>>), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>), default(IScheduler))),
  6127. #else
  6128. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  6129. #endif
  6130. Expression.Constant(provider, typeof(IQbservableProvider)),
  6131. conversion,
  6132. addHandler,
  6133. removeHandler,
  6134. Expression.Constant(scheduler, typeof(IScheduler))
  6135. )
  6136. );
  6137. }
  6138. /// <summary>
  6139. /// 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.
  6140. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6141. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6142. /// </summary>
  6143. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6144. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  6145. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  6146. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6147. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  6148. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  6149. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6150. /// <exception cref="T:System.ArgumentNullException">
  6151. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  6152. /// <remarks>
  6153. /// <para>
  6154. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6155. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6156. /// </para>
  6157. /// <para>
  6158. /// 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.
  6159. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  6160. /// </para>
  6161. /// <para>
  6162. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  6163. /// making the Subscribe or Dispose call, respectively.
  6164. /// </para>
  6165. /// <para>
  6166. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  6167. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  6168. /// more concise and easier to understand.
  6169. /// </para>
  6170. /// </remarks>
  6171. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6172. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TDelegate, TSender, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)
  6173. #if !NO_EVENTARGS_CONSTRAINT
  6174. where TEventArgs : EventArgs
  6175. #endif
  6176. {
  6177. if (provider == null)
  6178. throw new ArgumentNullException("provider");
  6179. if (addHandler == null)
  6180. throw new ArgumentNullException("addHandler");
  6181. if (removeHandler == null)
  6182. throw new ArgumentNullException("removeHandler");
  6183. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  6184. Expression.Call(
  6185. null,
  6186. #if CRIPPLED_REFLECTION
  6187. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TSender, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>))),
  6188. #else
  6189. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TSender), typeof(TEventArgs)),
  6190. #endif
  6191. Expression.Constant(provider, typeof(IQbservableProvider)),
  6192. addHandler,
  6193. removeHandler
  6194. )
  6195. );
  6196. }
  6197. /// <summary>
  6198. /// 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.
  6199. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6200. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6201. /// </summary>
  6202. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6203. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  6204. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  6205. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6206. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  6207. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  6208. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  6209. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6210. /// <exception cref="T:System.ArgumentNullException">
  6211. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  6212. /// <remarks>
  6213. /// <para>
  6214. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6215. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6216. /// </para>
  6217. /// <para>
  6218. /// 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
  6219. /// accessed from the same context, as required by some UI frameworks.
  6220. /// </para>
  6221. /// <para>
  6222. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  6223. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  6224. /// parameter. For more information, see the remarks section on those overloads.
  6225. /// </para>
  6226. /// </remarks>
  6227. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6228. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TDelegate, TSender, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler, IScheduler scheduler)
  6229. #if !NO_EVENTARGS_CONSTRAINT
  6230. where TEventArgs : EventArgs
  6231. #endif
  6232. {
  6233. if (provider == null)
  6234. throw new ArgumentNullException("provider");
  6235. if (addHandler == null)
  6236. throw new ArgumentNullException("addHandler");
  6237. if (removeHandler == null)
  6238. throw new ArgumentNullException("removeHandler");
  6239. if (scheduler == null)
  6240. throw new ArgumentNullException("scheduler");
  6241. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  6242. Expression.Call(
  6243. null,
  6244. #if CRIPPLED_REFLECTION
  6245. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TSender, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>), default(IScheduler))),
  6246. #else
  6247. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TSender), typeof(TEventArgs)),
  6248. #endif
  6249. Expression.Constant(provider, typeof(IQbservableProvider)),
  6250. addHandler,
  6251. removeHandler,
  6252. Expression.Constant(scheduler, typeof(IScheduler))
  6253. )
  6254. );
  6255. }
  6256. /// <summary>
  6257. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="T:System.EventHandler`1" />, to an observable sequence.
  6258. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6259. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6260. /// </summary>
  6261. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6262. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6263. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  6264. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  6265. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6266. /// <remarks>
  6267. /// <para>
  6268. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6269. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6270. /// </para>
  6271. /// <para>
  6272. /// 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.
  6273. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  6274. /// </para>
  6275. /// <para>
  6276. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  6277. /// making the Subscribe or Dispose call, respectively.
  6278. /// </para>
  6279. /// <para>
  6280. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  6281. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  6282. /// more concise and easier to understand.
  6283. /// </para>
  6284. /// </remarks>
  6285. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6286. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, Expression<Action<EventHandler<TEventArgs>>> addHandler, Expression<Action<EventHandler<TEventArgs>>> removeHandler)
  6287. #if !NO_EVENTARGS_CONSTRAINT
  6288. where TEventArgs : EventArgs
  6289. #endif
  6290. {
  6291. if (provider == null)
  6292. throw new ArgumentNullException("provider");
  6293. if (addHandler == null)
  6294. throw new ArgumentNullException("addHandler");
  6295. if (removeHandler == null)
  6296. throw new ArgumentNullException("removeHandler");
  6297. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6298. Expression.Call(
  6299. null,
  6300. #if CRIPPLED_REFLECTION
  6301. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(Expression<Action<EventHandler<TEventArgs>>>), default(Expression<Action<EventHandler<TEventArgs>>>))),
  6302. #else
  6303. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  6304. #endif
  6305. Expression.Constant(provider, typeof(IQbservableProvider)),
  6306. addHandler,
  6307. removeHandler
  6308. )
  6309. );
  6310. }
  6311. /// <summary>
  6312. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="T:System.EventHandler`1" />, to an observable sequence.
  6313. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6314. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6315. /// </summary>
  6316. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6317. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6318. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  6319. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  6320. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  6321. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6322. /// <remarks>
  6323. /// <para>
  6324. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6325. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6326. /// </para>
  6327. /// <para>
  6328. /// 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
  6329. /// accessed from the same context, as required by some UI frameworks.
  6330. /// </para>
  6331. /// <para>
  6332. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  6333. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  6334. /// parameter. For more information, see the remarks section on those overloads.
  6335. /// </para>
  6336. /// </remarks>
  6337. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6338. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, Expression<Action<EventHandler<TEventArgs>>> addHandler, Expression<Action<EventHandler<TEventArgs>>> removeHandler, IScheduler scheduler)
  6339. #if !NO_EVENTARGS_CONSTRAINT
  6340. where TEventArgs : EventArgs
  6341. #endif
  6342. {
  6343. if (provider == null)
  6344. throw new ArgumentNullException("provider");
  6345. if (addHandler == null)
  6346. throw new ArgumentNullException("addHandler");
  6347. if (removeHandler == null)
  6348. throw new ArgumentNullException("removeHandler");
  6349. if (scheduler == null)
  6350. throw new ArgumentNullException("scheduler");
  6351. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6352. Expression.Call(
  6353. null,
  6354. #if CRIPPLED_REFLECTION
  6355. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(Expression<Action<EventHandler<TEventArgs>>>), default(Expression<Action<EventHandler<TEventArgs>>>), default(IScheduler))),
  6356. #else
  6357. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  6358. #endif
  6359. Expression.Constant(provider, typeof(IQbservableProvider)),
  6360. addHandler,
  6361. removeHandler,
  6362. Expression.Constant(scheduler, typeof(IScheduler))
  6363. )
  6364. );
  6365. }
  6366. /// <summary>
  6367. /// Converts an instance .NET event, conforming to the standard .NET event pattern with strongly typed event arguments, to an observable sequence.
  6368. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6369. /// Reflection is used to discover the event based on the target object type and the specified event name.
  6370. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6371. /// </summary>
  6372. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6373. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6374. /// <param name="target">Object instance that exposes the event to convert.</param>
  6375. /// <param name="eventName">Name of the event to convert.</param>
  6376. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6377. /// <exception cref="T:System.ArgumentNullException">
  6378. /// <paramref name="target" /> or <paramref name="eventName" /> is null.</exception>
  6379. /// <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>
  6380. /// <remarks>
  6381. /// <para>
  6382. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6383. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6384. /// </para>
  6385. /// <para>
  6386. /// 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.
  6387. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  6388. /// </para>
  6389. /// <para>
  6390. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  6391. /// making the Subscribe or Dispose call, respectively.
  6392. /// </para>
  6393. /// <para>
  6394. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  6395. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  6396. /// more concise and easier to understand.
  6397. /// </para>
  6398. /// </remarks>
  6399. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6400. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, object target, string eventName)
  6401. #if !NO_EVENTARGS_CONSTRAINT
  6402. where TEventArgs : EventArgs
  6403. #endif
  6404. {
  6405. if (provider == null)
  6406. throw new ArgumentNullException("provider");
  6407. if (target == null)
  6408. throw new ArgumentNullException("target");
  6409. if (eventName == null)
  6410. throw new ArgumentNullException("eventName");
  6411. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6412. Expression.Call(
  6413. null,
  6414. #if CRIPPLED_REFLECTION
  6415. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(object), default(string))),
  6416. #else
  6417. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  6418. #endif
  6419. Expression.Constant(provider, typeof(IQbservableProvider)),
  6420. Expression.Constant(target, typeof(object)),
  6421. Expression.Constant(eventName, typeof(string))
  6422. )
  6423. );
  6424. }
  6425. /// <summary>
  6426. /// Converts an instance .NET event, conforming to the standard .NET event pattern with strongly typed event arguments, to an observable sequence.
  6427. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6428. /// Reflection is used to discover the event based on the target object type and the specified event name.
  6429. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6430. /// </summary>
  6431. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6432. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6433. /// <param name="target">Object instance that exposes the event to convert.</param>
  6434. /// <param name="eventName">Name of the event to convert.</param>
  6435. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  6436. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6437. /// <exception cref="T:System.ArgumentNullException">
  6438. /// <paramref name="target" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  6439. /// <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>
  6440. /// <remarks>
  6441. /// <para>
  6442. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6443. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6444. /// </para>
  6445. /// <para>
  6446. /// 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
  6447. /// accessed from the same context, as required by some UI frameworks.
  6448. /// </para>
  6449. /// <para>
  6450. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  6451. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  6452. /// parameter. For more information, see the remarks section on those overloads.
  6453. /// </para>
  6454. /// </remarks>
  6455. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6456. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, object target, string eventName, IScheduler scheduler)
  6457. #if !NO_EVENTARGS_CONSTRAINT
  6458. where TEventArgs : EventArgs
  6459. #endif
  6460. {
  6461. if (provider == null)
  6462. throw new ArgumentNullException("provider");
  6463. if (target == null)
  6464. throw new ArgumentNullException("target");
  6465. if (eventName == null)
  6466. throw new ArgumentNullException("eventName");
  6467. if (scheduler == null)
  6468. throw new ArgumentNullException("scheduler");
  6469. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6470. Expression.Call(
  6471. null,
  6472. #if CRIPPLED_REFLECTION
  6473. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(object), default(string), default(IScheduler))),
  6474. #else
  6475. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  6476. #endif
  6477. Expression.Constant(provider, typeof(IQbservableProvider)),
  6478. Expression.Constant(target, typeof(object)),
  6479. Expression.Constant(eventName, typeof(string)),
  6480. Expression.Constant(scheduler, typeof(IScheduler))
  6481. )
  6482. );
  6483. }
  6484. /// <summary>
  6485. /// Converts a static .NET event, conforming to the standard .NET event pattern with strongly typed event arguments, to an observable sequence.
  6486. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6487. /// Reflection is used to discover the event based on the specified type and the specified event name.
  6488. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6489. /// </summary>
  6490. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6491. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6492. /// <param name="type">Type that exposes the static event to convert.</param>
  6493. /// <param name="eventName">Name of the event to convert.</param>
  6494. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6495. /// <exception cref="T:System.ArgumentNullException">
  6496. /// <paramref name="type" /> or <paramref name="eventName" /> is null.</exception>
  6497. /// <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>
  6498. /// <remarks>
  6499. /// <para>
  6500. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6501. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6502. /// </para>
  6503. /// <para>
  6504. /// 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.
  6505. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  6506. /// </para>
  6507. /// <para>
  6508. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  6509. /// making the Subscribe or Dispose call, respectively.
  6510. /// </para>
  6511. /// <para>
  6512. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  6513. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  6514. /// more concise and easier to understand.
  6515. /// </para>
  6516. /// </remarks>
  6517. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6518. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, Type type, string eventName)
  6519. #if !NO_EVENTARGS_CONSTRAINT
  6520. where TEventArgs : EventArgs
  6521. #endif
  6522. {
  6523. if (provider == null)
  6524. throw new ArgumentNullException("provider");
  6525. if (type == null)
  6526. throw new ArgumentNullException("type");
  6527. if (eventName == null)
  6528. throw new ArgumentNullException("eventName");
  6529. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6530. Expression.Call(
  6531. null,
  6532. #if CRIPPLED_REFLECTION
  6533. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(Type), default(string))),
  6534. #else
  6535. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  6536. #endif
  6537. Expression.Constant(provider, typeof(IQbservableProvider)),
  6538. Expression.Constant(type, typeof(Type)),
  6539. Expression.Constant(eventName, typeof(string))
  6540. )
  6541. );
  6542. }
  6543. /// <summary>
  6544. /// Converts a static .NET event, conforming to the standard .NET event pattern with strongly typed event arguments, to an observable sequence.
  6545. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6546. /// Reflection is used to discover the event based on the specified type and the specified event name.
  6547. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6548. /// </summary>
  6549. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6550. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6551. /// <param name="type">Type that exposes the static event to convert.</param>
  6552. /// <param name="eventName">Name of the event to convert.</param>
  6553. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  6554. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6555. /// <exception cref="T:System.ArgumentNullException">
  6556. /// <paramref name="type" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  6557. /// <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>
  6558. /// <remarks>
  6559. /// <para>
  6560. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6561. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6562. /// </para>
  6563. /// <para>
  6564. /// 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
  6565. /// accessed from the same context, as required by some UI frameworks.
  6566. /// </para>
  6567. /// <para>
  6568. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  6569. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  6570. /// parameter. For more information, see the remarks section on those overloads.
  6571. /// </para>
  6572. /// </remarks>
  6573. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6574. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, Type type, string eventName, IScheduler scheduler)
  6575. #if !NO_EVENTARGS_CONSTRAINT
  6576. where TEventArgs : EventArgs
  6577. #endif
  6578. {
  6579. if (provider == null)
  6580. throw new ArgumentNullException("provider");
  6581. if (type == null)
  6582. throw new ArgumentNullException("type");
  6583. if (eventName == null)
  6584. throw new ArgumentNullException("eventName");
  6585. if (scheduler == null)
  6586. throw new ArgumentNullException("scheduler");
  6587. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6588. Expression.Call(
  6589. null,
  6590. #if CRIPPLED_REFLECTION
  6591. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(Type), default(string), default(IScheduler))),
  6592. #else
  6593. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  6594. #endif
  6595. Expression.Constant(provider, typeof(IQbservableProvider)),
  6596. Expression.Constant(type, typeof(Type)),
  6597. Expression.Constant(eventName, typeof(string)),
  6598. Expression.Constant(scheduler, typeof(IScheduler))
  6599. )
  6600. );
  6601. }
  6602. /// <summary>
  6603. /// 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.
  6604. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6605. /// Reflection is used to discover the event based on the target object type and the specified event name.
  6606. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6607. /// </summary>
  6608. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6609. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  6610. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6611. /// <param name="target">Object instance that exposes the event to convert.</param>
  6612. /// <param name="eventName">Name of the event to convert.</param>
  6613. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6614. /// <exception cref="T:System.ArgumentNullException">
  6615. /// <paramref name="target" /> or <paramref name="eventName" /> is null.</exception>
  6616. /// <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>
  6617. /// <remarks>
  6618. /// <para>
  6619. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6620. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6621. /// </para>
  6622. /// <para>
  6623. /// 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.
  6624. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  6625. /// </para>
  6626. /// <para>
  6627. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  6628. /// making the Subscribe or Dispose call, respectively.
  6629. /// </para>
  6630. /// <para>
  6631. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  6632. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  6633. /// more concise and easier to understand.
  6634. /// </para>
  6635. /// </remarks>
  6636. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6637. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(this IQbservableProvider provider, object target, string eventName)
  6638. #if !NO_EVENTARGS_CONSTRAINT
  6639. where TEventArgs : EventArgs
  6640. #endif
  6641. {
  6642. if (provider == null)
  6643. throw new ArgumentNullException("provider");
  6644. if (target == null)
  6645. throw new ArgumentNullException("target");
  6646. if (eventName == null)
  6647. throw new ArgumentNullException("eventName");
  6648. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  6649. Expression.Call(
  6650. null,
  6651. #if CRIPPLED_REFLECTION
  6652. InfoOf(() => Qbservable.FromEventPattern<TSender, TEventArgs>(default(IQbservableProvider), default(object), default(string))),
  6653. #else
  6654. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSender), typeof(TEventArgs)),
  6655. #endif
  6656. Expression.Constant(provider, typeof(IQbservableProvider)),
  6657. Expression.Constant(target, typeof(object)),
  6658. Expression.Constant(eventName, typeof(string))
  6659. )
  6660. );
  6661. }
  6662. /// <summary>
  6663. /// 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.
  6664. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6665. /// Reflection is used to discover the event based on the target object type and the specified event name.
  6666. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6667. /// </summary>
  6668. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6669. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  6670. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6671. /// <param name="target">Object instance that exposes the event to convert.</param>
  6672. /// <param name="eventName">Name of the event to convert.</param>
  6673. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  6674. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6675. /// <exception cref="T:System.ArgumentNullException">
  6676. /// <paramref name="target" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  6677. /// <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>
  6678. /// <remarks>
  6679. /// <para>
  6680. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6681. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6682. /// </para>
  6683. /// <para>
  6684. /// 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
  6685. /// accessed from the same context, as required by some UI frameworks.
  6686. /// </para>
  6687. /// <para>
  6688. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  6689. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  6690. /// parameter. For more information, see the remarks section on those overloads.
  6691. /// </para>
  6692. /// </remarks>
  6693. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6694. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(this IQbservableProvider provider, object target, string eventName, IScheduler scheduler)
  6695. #if !NO_EVENTARGS_CONSTRAINT
  6696. where TEventArgs : EventArgs
  6697. #endif
  6698. {
  6699. if (provider == null)
  6700. throw new ArgumentNullException("provider");
  6701. if (target == null)
  6702. throw new ArgumentNullException("target");
  6703. if (eventName == null)
  6704. throw new ArgumentNullException("eventName");
  6705. if (scheduler == null)
  6706. throw new ArgumentNullException("scheduler");
  6707. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  6708. Expression.Call(
  6709. null,
  6710. #if CRIPPLED_REFLECTION
  6711. InfoOf(() => Qbservable.FromEventPattern<TSender, TEventArgs>(default(IQbservableProvider), default(object), default(string), default(IScheduler))),
  6712. #else
  6713. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSender), typeof(TEventArgs)),
  6714. #endif
  6715. Expression.Constant(provider, typeof(IQbservableProvider)),
  6716. Expression.Constant(target, typeof(object)),
  6717. Expression.Constant(eventName, typeof(string)),
  6718. Expression.Constant(scheduler, typeof(IScheduler))
  6719. )
  6720. );
  6721. }
  6722. /// <summary>
  6723. /// 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.
  6724. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6725. /// Reflection is used to discover the event based on the specified type and the specified event name.
  6726. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6727. /// </summary>
  6728. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6729. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  6730. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6731. /// <param name="type">Type that exposes the static event to convert.</param>
  6732. /// <param name="eventName">Name of the event to convert.</param>
  6733. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6734. /// <exception cref="T:System.ArgumentNullException">
  6735. /// <paramref name="type" /> or <paramref name="eventName" /> is null.</exception>
  6736. /// <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>
  6737. /// <remarks>
  6738. /// <para>
  6739. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6740. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6741. /// </para>
  6742. /// <para>
  6743. /// 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.
  6744. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  6745. /// </para>
  6746. /// <para>
  6747. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  6748. /// making the Subscribe or Dispose call, respectively.
  6749. /// </para>
  6750. /// <para>
  6751. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  6752. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  6753. /// more concise and easier to understand.
  6754. /// </para>
  6755. /// </remarks>
  6756. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6757. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(this IQbservableProvider provider, Type type, string eventName)
  6758. #if !NO_EVENTARGS_CONSTRAINT
  6759. where TEventArgs : EventArgs
  6760. #endif
  6761. {
  6762. if (provider == null)
  6763. throw new ArgumentNullException("provider");
  6764. if (type == null)
  6765. throw new ArgumentNullException("type");
  6766. if (eventName == null)
  6767. throw new ArgumentNullException("eventName");
  6768. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  6769. Expression.Call(
  6770. null,
  6771. #if CRIPPLED_REFLECTION
  6772. InfoOf(() => Qbservable.FromEventPattern<TSender, TEventArgs>(default(IQbservableProvider), default(Type), default(string))),
  6773. #else
  6774. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSender), typeof(TEventArgs)),
  6775. #endif
  6776. Expression.Constant(provider, typeof(IQbservableProvider)),
  6777. Expression.Constant(type, typeof(Type)),
  6778. Expression.Constant(eventName, typeof(string))
  6779. )
  6780. );
  6781. }
  6782. /// <summary>
  6783. /// 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.
  6784. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6785. /// Reflection is used to discover the event based on the specified type and the specified event name.
  6786. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6787. /// </summary>
  6788. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6789. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  6790. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6791. /// <param name="type">Type that exposes the static event to convert.</param>
  6792. /// <param name="eventName">Name of the event to convert.</param>
  6793. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  6794. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6795. /// <exception cref="T:System.ArgumentNullException">
  6796. /// <paramref name="type" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  6797. /// <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>
  6798. /// <remarks>
  6799. /// <para>
  6800. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6801. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6802. /// </para>
  6803. /// <para>
  6804. /// 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
  6805. /// accessed from the same context, as required by some UI frameworks.
  6806. /// </para>
  6807. /// <para>
  6808. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  6809. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  6810. /// parameter. For more information, see the remarks section on those overloads.
  6811. /// </para>
  6812. /// </remarks>
  6813. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6814. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(this IQbservableProvider provider, Type type, string eventName, IScheduler scheduler)
  6815. #if !NO_EVENTARGS_CONSTRAINT
  6816. where TEventArgs : EventArgs
  6817. #endif
  6818. {
  6819. if (provider == null)
  6820. throw new ArgumentNullException("provider");
  6821. if (type == null)
  6822. throw new ArgumentNullException("type");
  6823. if (eventName == null)
  6824. throw new ArgumentNullException("eventName");
  6825. if (scheduler == null)
  6826. throw new ArgumentNullException("scheduler");
  6827. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  6828. Expression.Call(
  6829. null,
  6830. #if CRIPPLED_REFLECTION
  6831. InfoOf(() => Qbservable.FromEventPattern<TSender, TEventArgs>(default(IQbservableProvider), default(Type), default(string), default(IScheduler))),
  6832. #else
  6833. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSender), typeof(TEventArgs)),
  6834. #endif
  6835. Expression.Constant(provider, typeof(IQbservableProvider)),
  6836. Expression.Constant(type, typeof(Type)),
  6837. Expression.Constant(eventName, typeof(string)),
  6838. Expression.Constant(scheduler, typeof(IScheduler))
  6839. )
  6840. );
  6841. }
  6842. /// <summary>
  6843. /// Generates an observable sequence by running a state-driven loop producing the sequence's elements.
  6844. /// </summary>
  6845. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6846. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6847. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6848. /// <param name="initialState">Initial state.</param>
  6849. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6850. /// <param name="iterate">Iteration step function.</param>
  6851. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6852. /// <returns>The generated sequence.</returns>
  6853. /// <exception cref="T:System.ArgumentNullException">
  6854. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> is null.</exception>
  6855. 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)
  6856. {
  6857. if (provider == null)
  6858. throw new ArgumentNullException("provider");
  6859. if (condition == null)
  6860. throw new ArgumentNullException("condition");
  6861. if (iterate == null)
  6862. throw new ArgumentNullException("iterate");
  6863. if (resultSelector == null)
  6864. throw new ArgumentNullException("resultSelector");
  6865. return provider.CreateQuery<TResult>(
  6866. Expression.Call(
  6867. null,
  6868. #if CRIPPLED_REFLECTION
  6869. InfoOf(() => Qbservable.Generate<TState, TResult>(default(IQbservableProvider), default(TState), default(Expression<Func<TState, bool>>), default(Expression<Func<TState, TState>>), default(Expression<Func<TState, TResult>>))),
  6870. #else
  6871. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6872. #endif
  6873. Expression.Constant(provider, typeof(IQbservableProvider)),
  6874. Expression.Constant(initialState, typeof(TState)),
  6875. condition,
  6876. iterate,
  6877. resultSelector
  6878. )
  6879. );
  6880. }
  6881. /// <summary>
  6882. /// Generates an observable sequence by running a state-driven loop producing the sequence's elements, using the specified scheduler to send out observer messages.
  6883. /// </summary>
  6884. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6885. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6886. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6887. /// <param name="initialState">Initial state.</param>
  6888. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6889. /// <param name="iterate">Iteration step function.</param>
  6890. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6891. /// <param name="scheduler">Scheduler on which to run the generator loop.</param>
  6892. /// <returns>The generated sequence.</returns>
  6893. /// <exception cref="T:System.ArgumentNullException">
  6894. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> or <paramref name="scheduler" /> is null.</exception>
  6895. 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)
  6896. {
  6897. if (provider == null)
  6898. throw new ArgumentNullException("provider");
  6899. if (condition == null)
  6900. throw new ArgumentNullException("condition");
  6901. if (iterate == null)
  6902. throw new ArgumentNullException("iterate");
  6903. if (resultSelector == null)
  6904. throw new ArgumentNullException("resultSelector");
  6905. if (scheduler == null)
  6906. throw new ArgumentNullException("scheduler");
  6907. return provider.CreateQuery<TResult>(
  6908. Expression.Call(
  6909. null,
  6910. #if CRIPPLED_REFLECTION
  6911. 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))),
  6912. #else
  6913. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6914. #endif
  6915. Expression.Constant(provider, typeof(IQbservableProvider)),
  6916. Expression.Constant(initialState, typeof(TState)),
  6917. condition,
  6918. iterate,
  6919. resultSelector,
  6920. Expression.Constant(scheduler, typeof(IScheduler))
  6921. )
  6922. );
  6923. }
  6924. /// <summary>
  6925. /// Generates an observable sequence by running a state-driven and temporal loop producing the sequence's elements.
  6926. /// </summary>
  6927. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6928. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6929. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6930. /// <param name="initialState">Initial state.</param>
  6931. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6932. /// <param name="iterate">Iteration step function.</param>
  6933. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6934. /// <param name="timeSelector">Time selector function to control the speed of values being produced each iteration.</param>
  6935. /// <returns>The generated sequence.</returns>
  6936. /// <exception cref="T:System.ArgumentNullException">
  6937. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> or <paramref name="timeSelector" /> is null.</exception>
  6938. 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)
  6939. {
  6940. if (provider == null)
  6941. throw new ArgumentNullException("provider");
  6942. if (condition == null)
  6943. throw new ArgumentNullException("condition");
  6944. if (iterate == null)
  6945. throw new ArgumentNullException("iterate");
  6946. if (resultSelector == null)
  6947. throw new ArgumentNullException("resultSelector");
  6948. if (timeSelector == null)
  6949. throw new ArgumentNullException("timeSelector");
  6950. return provider.CreateQuery<TResult>(
  6951. Expression.Call(
  6952. null,
  6953. #if CRIPPLED_REFLECTION
  6954. 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>>))),
  6955. #else
  6956. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6957. #endif
  6958. Expression.Constant(provider, typeof(IQbservableProvider)),
  6959. Expression.Constant(initialState, typeof(TState)),
  6960. condition,
  6961. iterate,
  6962. resultSelector,
  6963. timeSelector
  6964. )
  6965. );
  6966. }
  6967. /// <summary>
  6968. /// Generates an observable sequence by running a state-driven and temporal loop producing the sequence's elements.
  6969. /// </summary>
  6970. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6971. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6972. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6973. /// <param name="initialState">Initial state.</param>
  6974. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6975. /// <param name="iterate">Iteration step function.</param>
  6976. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6977. /// <param name="timeSelector">Time selector function to control the speed of values being produced each iteration.</param>
  6978. /// <returns>The generated sequence.</returns>
  6979. /// <exception cref="T:System.ArgumentNullException">
  6980. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> or <paramref name="timeSelector" /> is null.</exception>
  6981. 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)
  6982. {
  6983. if (provider == null)
  6984. throw new ArgumentNullException("provider");
  6985. if (condition == null)
  6986. throw new ArgumentNullException("condition");
  6987. if (iterate == null)
  6988. throw new ArgumentNullException("iterate");
  6989. if (resultSelector == null)
  6990. throw new ArgumentNullException("resultSelector");
  6991. if (timeSelector == null)
  6992. throw new ArgumentNullException("timeSelector");
  6993. return provider.CreateQuery<TResult>(
  6994. Expression.Call(
  6995. null,
  6996. #if CRIPPLED_REFLECTION
  6997. 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>>))),
  6998. #else
  6999. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  7000. #endif
  7001. Expression.Constant(provider, typeof(IQbservableProvider)),
  7002. Expression.Constant(initialState, typeof(TState)),
  7003. condition,
  7004. iterate,
  7005. resultSelector,
  7006. timeSelector
  7007. )
  7008. );
  7009. }
  7010. /// <summary>
  7011. /// 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.
  7012. /// </summary>
  7013. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  7014. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  7015. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  7016. /// <param name="initialState">Initial state.</param>
  7017. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  7018. /// <param name="iterate">Iteration step function.</param>
  7019. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  7020. /// <param name="timeSelector">Time selector function to control the speed of values being produced each iteration.</param>
  7021. /// <param name="scheduler">Scheduler on which to run the generator loop.</param>
  7022. /// <returns>The generated sequence.</returns>
  7023. /// <exception cref="T:System.ArgumentNullException">
  7024. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> or <paramref name="timeSelector" /> or <paramref name="scheduler" /> is null.</exception>
  7025. 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)
  7026. {
  7027. if (provider == null)
  7028. throw new ArgumentNullException("provider");
  7029. if (condition == null)
  7030. throw new ArgumentNullException("condition");
  7031. if (iterate == null)
  7032. throw new ArgumentNullException("iterate");
  7033. if (resultSelector == null)
  7034. throw new ArgumentNullException("resultSelector");
  7035. if (timeSelector == null)
  7036. throw new ArgumentNullException("timeSelector");
  7037. if (scheduler == null)
  7038. throw new ArgumentNullException("scheduler");
  7039. return provider.CreateQuery<TResult>(
  7040. Expression.Call(
  7041. null,
  7042. #if CRIPPLED_REFLECTION
  7043. 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))),
  7044. #else
  7045. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  7046. #endif
  7047. Expression.Constant(provider, typeof(IQbservableProvider)),
  7048. Expression.Constant(initialState, typeof(TState)),
  7049. condition,
  7050. iterate,
  7051. resultSelector,
  7052. timeSelector,
  7053. Expression.Constant(scheduler, typeof(IScheduler))
  7054. )
  7055. );
  7056. }
  7057. /// <summary>
  7058. /// 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.
  7059. /// </summary>
  7060. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  7061. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  7062. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  7063. /// <param name="initialState">Initial state.</param>
  7064. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  7065. /// <param name="iterate">Iteration step function.</param>
  7066. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  7067. /// <param name="timeSelector">Time selector function to control the speed of values being produced each iteration.</param>
  7068. /// <param name="scheduler">Scheduler on which to run the generator loop.</param>
  7069. /// <returns>The generated sequence.</returns>
  7070. /// <exception cref="T:System.ArgumentNullException">
  7071. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> or <paramref name="timeSelector" /> or <paramref name="scheduler" /> is null.</exception>
  7072. 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)
  7073. {
  7074. if (provider == null)
  7075. throw new ArgumentNullException("provider");
  7076. if (condition == null)
  7077. throw new ArgumentNullException("condition");
  7078. if (iterate == null)
  7079. throw new ArgumentNullException("iterate");
  7080. if (resultSelector == null)
  7081. throw new ArgumentNullException("resultSelector");
  7082. if (timeSelector == null)
  7083. throw new ArgumentNullException("timeSelector");
  7084. if (scheduler == null)
  7085. throw new ArgumentNullException("scheduler");
  7086. return provider.CreateQuery<TResult>(
  7087. Expression.Call(
  7088. null,
  7089. #if CRIPPLED_REFLECTION
  7090. 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))),
  7091. #else
  7092. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  7093. #endif
  7094. Expression.Constant(provider, typeof(IQbservableProvider)),
  7095. Expression.Constant(initialState, typeof(TState)),
  7096. condition,
  7097. iterate,
  7098. resultSelector,
  7099. timeSelector,
  7100. Expression.Constant(scheduler, typeof(IScheduler))
  7101. )
  7102. );
  7103. }
  7104. /// <summary>
  7105. /// Groups the elements of an observable sequence according to a specified key selector function.
  7106. /// </summary>
  7107. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7108. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7109. /// <param name="source">An observable sequence whose elements to group.</param>
  7110. /// <param name="keySelector">A function to extract the key for each element.</param>
  7111. /// <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>
  7112. /// <exception cref="T:System.ArgumentNullException">
  7113. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  7114. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  7115. {
  7116. if (source == null)
  7117. throw new ArgumentNullException("source");
  7118. if (keySelector == null)
  7119. throw new ArgumentNullException("keySelector");
  7120. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7121. Expression.Call(
  7122. null,
  7123. #if CRIPPLED_REFLECTION
  7124. InfoOf(() => Qbservable.GroupBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  7125. #else
  7126. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  7127. #endif
  7128. source.Expression,
  7129. keySelector
  7130. )
  7131. );
  7132. }
  7133. /// <summary>
  7134. /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function.
  7135. /// </summary>
  7136. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7137. /// <typeparam name="TKey">The type of the grouping key 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="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7141. /// <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>
  7142. /// <exception cref="T:System.ArgumentNullException">
  7143. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  7144. /// <exception cref="T:System.ArgumentOutOfRangeException">
  7145. /// <paramref name="capacity" /> is less than 0.</exception>
  7146. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, int capacity)
  7147. {
  7148. if (source == null)
  7149. throw new ArgumentNullException("source");
  7150. if (keySelector == null)
  7151. throw new ArgumentNullException("keySelector");
  7152. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7153. Expression.Call(
  7154. null,
  7155. #if CRIPPLED_REFLECTION
  7156. InfoOf(() => Qbservable.GroupBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(int))),
  7157. #else
  7158. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  7159. #endif
  7160. source.Expression,
  7161. keySelector,
  7162. Expression.Constant(capacity, typeof(int))
  7163. )
  7164. );
  7165. }
  7166. /// <summary>
  7167. /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function and comparer.
  7168. /// </summary>
  7169. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7170. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7171. /// <param name="source">An observable sequence whose elements to group.</param>
  7172. /// <param name="keySelector">A function to extract the key for each element.</param>
  7173. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7174. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7175. /// <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>
  7176. /// <exception cref="T:System.ArgumentNullException">
  7177. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  7178. /// <exception cref="T:System.ArgumentOutOfRangeException">
  7179. /// <paramref name="capacity" /> is less than 0.</exception>
  7180. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, int capacity, IEqualityComparer<TKey> comparer)
  7181. {
  7182. if (source == null)
  7183. throw new ArgumentNullException("source");
  7184. if (keySelector == null)
  7185. throw new ArgumentNullException("keySelector");
  7186. if (comparer == null)
  7187. throw new ArgumentNullException("comparer");
  7188. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7189. Expression.Call(
  7190. null,
  7191. #if CRIPPLED_REFLECTION
  7192. InfoOf(() => Qbservable.GroupBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(int), default(IEqualityComparer<TKey>))),
  7193. #else
  7194. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  7195. #endif
  7196. source.Expression,
  7197. keySelector,
  7198. Expression.Constant(capacity, typeof(int)),
  7199. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7200. )
  7201. );
  7202. }
  7203. /// <summary>
  7204. /// Groups the elements of an observable sequence according to a specified key selector function and comparer.
  7205. /// </summary>
  7206. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7207. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7208. /// <param name="source">An observable sequence whose elements to group.</param>
  7209. /// <param name="keySelector">A function to extract the key for each element.</param>
  7210. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7211. /// <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>
  7212. /// <exception cref="T:System.ArgumentNullException">
  7213. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  7214. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  7215. {
  7216. if (source == null)
  7217. throw new ArgumentNullException("source");
  7218. if (keySelector == null)
  7219. throw new ArgumentNullException("keySelector");
  7220. if (comparer == null)
  7221. throw new ArgumentNullException("comparer");
  7222. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7223. Expression.Call(
  7224. null,
  7225. #if CRIPPLED_REFLECTION
  7226. InfoOf(() => Qbservable.GroupBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IEqualityComparer<TKey>))),
  7227. #else
  7228. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  7229. #endif
  7230. source.Expression,
  7231. keySelector,
  7232. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7233. )
  7234. );
  7235. }
  7236. /// <summary>
  7237. /// Groups the elements of an observable sequence and selects the resulting elements by using a specified function.
  7238. /// </summary>
  7239. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7240. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7241. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7242. /// <param name="source">An observable sequence whose elements to group.</param>
  7243. /// <param name="keySelector">A function to extract the key for each element.</param>
  7244. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7245. /// <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>
  7246. /// <exception cref="T:System.ArgumentNullException">
  7247. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> is null.</exception>
  7248. public static IQbservable<IGroupedObservable<TKey, TElement>> GroupBy<TSource, TKey, TElement>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector)
  7249. {
  7250. if (source == null)
  7251. throw new ArgumentNullException("source");
  7252. if (keySelector == null)
  7253. throw new ArgumentNullException("keySelector");
  7254. if (elementSelector == null)
  7255. throw new ArgumentNullException("elementSelector");
  7256. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7257. Expression.Call(
  7258. null,
  7259. #if CRIPPLED_REFLECTION
  7260. InfoOf(() => Qbservable.GroupBy<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>))),
  7261. #else
  7262. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  7263. #endif
  7264. source.Expression,
  7265. keySelector,
  7266. elementSelector
  7267. )
  7268. );
  7269. }
  7270. /// <summary>
  7271. /// Groups the elements of an observable sequence with the specified initial capacity and selects the resulting elements by using a specified function.
  7272. /// </summary>
  7273. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7274. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7275. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7276. /// <param name="source">An observable sequence whose elements to group.</param>
  7277. /// <param name="keySelector">A function to extract the key for each element.</param>
  7278. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7279. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7280. /// <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>
  7281. /// <exception cref="T:System.ArgumentNullException">
  7282. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> is null.</exception>
  7283. /// <exception cref="T:System.ArgumentOutOfRangeException">
  7284. /// <paramref name="capacity" /> is less than 0.</exception>
  7285. 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)
  7286. {
  7287. if (source == null)
  7288. throw new ArgumentNullException("source");
  7289. if (keySelector == null)
  7290. throw new ArgumentNullException("keySelector");
  7291. if (elementSelector == null)
  7292. throw new ArgumentNullException("elementSelector");
  7293. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7294. Expression.Call(
  7295. null,
  7296. #if CRIPPLED_REFLECTION
  7297. InfoOf(() => Qbservable.GroupBy<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(int))),
  7298. #else
  7299. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  7300. #endif
  7301. source.Expression,
  7302. keySelector,
  7303. elementSelector,
  7304. Expression.Constant(capacity, typeof(int))
  7305. )
  7306. );
  7307. }
  7308. /// <summary>
  7309. /// 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.
  7310. /// </summary>
  7311. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7312. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7313. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7314. /// <param name="source">An observable sequence whose elements to group.</param>
  7315. /// <param name="keySelector">A function to extract the key for each element.</param>
  7316. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7317. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7318. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7319. /// <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>
  7320. /// <exception cref="T:System.ArgumentNullException">
  7321. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="comparer" /> is null.</exception>
  7322. /// <exception cref="T:System.ArgumentOutOfRangeException">
  7323. /// <paramref name="capacity" /> is less than 0.</exception>
  7324. 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)
  7325. {
  7326. if (source == null)
  7327. throw new ArgumentNullException("source");
  7328. if (keySelector == null)
  7329. throw new ArgumentNullException("keySelector");
  7330. if (elementSelector == null)
  7331. throw new ArgumentNullException("elementSelector");
  7332. if (comparer == null)
  7333. throw new ArgumentNullException("comparer");
  7334. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7335. Expression.Call(
  7336. null,
  7337. #if CRIPPLED_REFLECTION
  7338. InfoOf(() => Qbservable.GroupBy<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(int), default(IEqualityComparer<TKey>))),
  7339. #else
  7340. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  7341. #endif
  7342. source.Expression,
  7343. keySelector,
  7344. elementSelector,
  7345. Expression.Constant(capacity, typeof(int)),
  7346. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7347. )
  7348. );
  7349. }
  7350. /// <summary>
  7351. /// 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.
  7352. /// </summary>
  7353. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7354. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7355. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7356. /// <param name="source">An observable sequence whose elements to group.</param>
  7357. /// <param name="keySelector">A function to extract the key for each element.</param>
  7358. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7359. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7360. /// <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>
  7361. /// <exception cref="T:System.ArgumentNullException">
  7362. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="comparer" /> is null.</exception>
  7363. 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)
  7364. {
  7365. if (source == null)
  7366. throw new ArgumentNullException("source");
  7367. if (keySelector == null)
  7368. throw new ArgumentNullException("keySelector");
  7369. if (elementSelector == null)
  7370. throw new ArgumentNullException("elementSelector");
  7371. if (comparer == null)
  7372. throw new ArgumentNullException("comparer");
  7373. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7374. Expression.Call(
  7375. null,
  7376. #if CRIPPLED_REFLECTION
  7377. InfoOf(() => Qbservable.GroupBy<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(IEqualityComparer<TKey>))),
  7378. #else
  7379. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  7380. #endif
  7381. source.Expression,
  7382. keySelector,
  7383. elementSelector,
  7384. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7385. )
  7386. );
  7387. }
  7388. /// <summary>
  7389. /// Groups the elements of an observable sequence according to a specified key selector function.
  7390. /// 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
  7391. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7392. /// </summary>
  7393. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7394. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7395. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7396. /// <param name="source">An observable sequence whose elements to group.</param>
  7397. /// <param name="keySelector">A function to extract the key for each element.</param>
  7398. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7399. /// <returns>
  7400. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7401. /// 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.
  7402. /// </returns>
  7403. /// <exception cref="T:System.ArgumentNullException">
  7404. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="durationSelector" /> is null.</exception>
  7405. 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)
  7406. {
  7407. if (source == null)
  7408. throw new ArgumentNullException("source");
  7409. if (keySelector == null)
  7410. throw new ArgumentNullException("keySelector");
  7411. if (durationSelector == null)
  7412. throw new ArgumentNullException("durationSelector");
  7413. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7414. Expression.Call(
  7415. null,
  7416. #if CRIPPLED_REFLECTION
  7417. InfoOf(() => Qbservable.GroupByUntil<TSource, TKey, TDuration>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<IGroupedObservable<TKey, TSource>, IObservable<TDuration>>>))),
  7418. #else
  7419. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TDuration)),
  7420. #endif
  7421. source.Expression,
  7422. keySelector,
  7423. durationSelector
  7424. )
  7425. );
  7426. }
  7427. /// <summary>
  7428. /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function.
  7429. /// 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
  7430. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7431. /// </summary>
  7432. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7433. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7434. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7435. /// <param name="source">An observable sequence whose elements to group.</param>
  7436. /// <param name="keySelector">A function to extract the key for each element.</param>
  7437. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7438. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7439. /// <returns>
  7440. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7441. /// 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.
  7442. /// </returns>
  7443. /// <exception cref="T:System.ArgumentNullException">
  7444. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="durationSelector" /> is null.</exception>
  7445. /// <exception cref="T:System.ArgumentOutOfRangeException">
  7446. /// <paramref name="capacity" /> is less than 0.</exception>
  7447. 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)
  7448. {
  7449. if (source == null)
  7450. throw new ArgumentNullException("source");
  7451. if (keySelector == null)
  7452. throw new ArgumentNullException("keySelector");
  7453. if (durationSelector == null)
  7454. throw new ArgumentNullException("durationSelector");
  7455. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7456. Expression.Call(
  7457. null,
  7458. #if CRIPPLED_REFLECTION
  7459. InfoOf(() => Qbservable.GroupByUntil<TSource, TKey, TDuration>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<IGroupedObservable<TKey, TSource>, IObservable<TDuration>>>), default(int))),
  7460. #else
  7461. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TDuration)),
  7462. #endif
  7463. source.Expression,
  7464. keySelector,
  7465. durationSelector,
  7466. Expression.Constant(capacity, typeof(int))
  7467. )
  7468. );
  7469. }
  7470. /// <summary>
  7471. /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function and comparer.
  7472. /// 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
  7473. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7474. /// </summary>
  7475. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7476. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7477. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7478. /// <param name="source">An observable sequence whose elements to group.</param>
  7479. /// <param name="keySelector">A function to extract the key for each element.</param>
  7480. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7481. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7482. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7483. /// <returns>
  7484. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7485. /// 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.
  7486. /// </returns>
  7487. /// <exception cref="T:System.ArgumentNullException">
  7488. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="durationSelector" /> or <paramref name="comparer" /> is null.</exception>
  7489. /// <exception cref="T:System.ArgumentOutOfRangeException">
  7490. /// <paramref name="capacity" /> is less than 0.</exception>
  7491. 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)
  7492. {
  7493. if (source == null)
  7494. throw new ArgumentNullException("source");
  7495. if (keySelector == null)
  7496. throw new ArgumentNullException("keySelector");
  7497. if (durationSelector == null)
  7498. throw new ArgumentNullException("durationSelector");
  7499. if (comparer == null)
  7500. throw new ArgumentNullException("comparer");
  7501. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7502. Expression.Call(
  7503. null,
  7504. #if CRIPPLED_REFLECTION
  7505. 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>))),
  7506. #else
  7507. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TDuration)),
  7508. #endif
  7509. source.Expression,
  7510. keySelector,
  7511. durationSelector,
  7512. Expression.Constant(capacity, typeof(int)),
  7513. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7514. )
  7515. );
  7516. }
  7517. /// <summary>
  7518. /// Groups the elements of an observable sequence according to a specified key selector function and comparer.
  7519. /// 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
  7520. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7521. /// </summary>
  7522. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7523. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7524. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7525. /// <param name="source">An observable sequence whose elements to group.</param>
  7526. /// <param name="keySelector">A function to extract the key for each element.</param>
  7527. /// <param name="durationSelector">A function to signal the expiration of a group.</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 encoutered.
  7532. /// </returns>
  7533. /// <exception cref="T:System.ArgumentNullException">
  7534. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="durationSelector" /> or <paramref name="comparer" /> is null.</exception>
  7535. 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)
  7536. {
  7537. if (source == null)
  7538. throw new ArgumentNullException("source");
  7539. if (keySelector == null)
  7540. throw new ArgumentNullException("keySelector");
  7541. if (durationSelector == null)
  7542. throw new ArgumentNullException("durationSelector");
  7543. if (comparer == null)
  7544. throw new ArgumentNullException("comparer");
  7545. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7546. Expression.Call(
  7547. null,
  7548. #if CRIPPLED_REFLECTION
  7549. 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>))),
  7550. #else
  7551. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TDuration)),
  7552. #endif
  7553. source.Expression,
  7554. keySelector,
  7555. durationSelector,
  7556. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7557. )
  7558. );
  7559. }
  7560. /// <summary>
  7561. /// Groups the elements of an observable sequence according to a specified key selector function and selects the resulting elements by using a specified function.
  7562. /// 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
  7563. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7564. /// </summary>
  7565. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7566. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7567. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7568. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7569. /// <param name="source">An observable sequence whose elements to group.</param>
  7570. /// <param name="keySelector">A function to extract the key for each element.</param>
  7571. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7572. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7573. /// <returns>
  7574. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7575. /// 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.
  7576. /// </returns>
  7577. /// <exception cref="T:System.ArgumentNullException">
  7578. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="durationSelector" /> is null.</exception>
  7579. 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)
  7580. {
  7581. if (source == null)
  7582. throw new ArgumentNullException("source");
  7583. if (keySelector == null)
  7584. throw new ArgumentNullException("keySelector");
  7585. if (elementSelector == null)
  7586. throw new ArgumentNullException("elementSelector");
  7587. if (durationSelector == null)
  7588. throw new ArgumentNullException("durationSelector");
  7589. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7590. Expression.Call(
  7591. null,
  7592. #if CRIPPLED_REFLECTION
  7593. 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>>>))),
  7594. #else
  7595. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TDuration)),
  7596. #endif
  7597. source.Expression,
  7598. keySelector,
  7599. elementSelector,
  7600. durationSelector
  7601. )
  7602. );
  7603. }
  7604. /// <summary>
  7605. /// 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.
  7606. /// 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
  7607. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7608. /// </summary>
  7609. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7610. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7611. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7612. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7613. /// <param name="source">An observable sequence whose elements to group.</param>
  7614. /// <param name="keySelector">A function to extract the key for each element.</param>
  7615. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7616. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7617. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7618. /// <returns>
  7619. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7620. /// 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.
  7621. /// </returns>
  7622. /// <exception cref="T:System.ArgumentNullException">
  7623. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="durationSelector" /> is null.</exception>
  7624. /// <exception cref="T:System.ArgumentOutOfRangeException">
  7625. /// <paramref name="capacity" /> is less than 0.</exception>
  7626. 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)
  7627. {
  7628. if (source == null)
  7629. throw new ArgumentNullException("source");
  7630. if (keySelector == null)
  7631. throw new ArgumentNullException("keySelector");
  7632. if (elementSelector == null)
  7633. throw new ArgumentNullException("elementSelector");
  7634. if (durationSelector == null)
  7635. throw new ArgumentNullException("durationSelector");
  7636. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7637. Expression.Call(
  7638. null,
  7639. #if CRIPPLED_REFLECTION
  7640. 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))),
  7641. #else
  7642. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TDuration)),
  7643. #endif
  7644. source.Expression,
  7645. keySelector,
  7646. elementSelector,
  7647. durationSelector,
  7648. Expression.Constant(capacity, typeof(int))
  7649. )
  7650. );
  7651. }
  7652. /// <summary>
  7653. /// 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.
  7654. /// 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
  7655. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7656. /// </summary>
  7657. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7658. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7659. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7660. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7661. /// <param name="source">An observable sequence whose elements to group.</param>
  7662. /// <param name="keySelector">A function to extract the key for each element.</param>
  7663. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7664. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7665. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7666. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7667. /// <returns>
  7668. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7669. /// 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.
  7670. /// </returns>
  7671. /// <exception cref="T:System.ArgumentNullException">
  7672. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="durationSelector" /> or <paramref name="comparer" /> is null.</exception>
  7673. /// <exception cref="T:System.ArgumentOutOfRangeException">
  7674. /// <paramref name="capacity" /> is less than 0.</exception>
  7675. 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)
  7676. {
  7677. if (source == null)
  7678. throw new ArgumentNullException("source");
  7679. if (keySelector == null)
  7680. throw new ArgumentNullException("keySelector");
  7681. if (elementSelector == null)
  7682. throw new ArgumentNullException("elementSelector");
  7683. if (durationSelector == null)
  7684. throw new ArgumentNullException("durationSelector");
  7685. if (comparer == null)
  7686. throw new ArgumentNullException("comparer");
  7687. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7688. Expression.Call(
  7689. null,
  7690. #if CRIPPLED_REFLECTION
  7691. 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>))),
  7692. #else
  7693. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TDuration)),
  7694. #endif
  7695. source.Expression,
  7696. keySelector,
  7697. elementSelector,
  7698. durationSelector,
  7699. Expression.Constant(capacity, typeof(int)),
  7700. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7701. )
  7702. );
  7703. }
  7704. /// <summary>
  7705. /// 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.
  7706. /// 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
  7707. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7708. /// </summary>
  7709. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7710. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7711. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7712. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7713. /// <param name="source">An observable sequence whose elements to group.</param>
  7714. /// <param name="keySelector">A function to extract the key for each element.</param>
  7715. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7716. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7717. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7718. /// <returns>
  7719. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7720. /// 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.
  7721. /// </returns>
  7722. /// <exception cref="T:System.ArgumentNullException">
  7723. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="durationSelector" /> or <paramref name="comparer" /> is null.</exception>
  7724. 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)
  7725. {
  7726. if (source == null)
  7727. throw new ArgumentNullException("source");
  7728. if (keySelector == null)
  7729. throw new ArgumentNullException("keySelector");
  7730. if (elementSelector == null)
  7731. throw new ArgumentNullException("elementSelector");
  7732. if (durationSelector == null)
  7733. throw new ArgumentNullException("durationSelector");
  7734. if (comparer == null)
  7735. throw new ArgumentNullException("comparer");
  7736. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7737. Expression.Call(
  7738. null,
  7739. #if CRIPPLED_REFLECTION
  7740. 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>))),
  7741. #else
  7742. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TDuration)),
  7743. #endif
  7744. source.Expression,
  7745. keySelector,
  7746. elementSelector,
  7747. durationSelector,
  7748. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7749. )
  7750. );
  7751. }
  7752. /// <summary>
  7753. /// Correlates the elements of two sequences based on overlapping durations, and groups the results.
  7754. /// </summary>
  7755. /// <typeparam name="TLeft">The type of the elements in the left source sequence.</typeparam>
  7756. /// <typeparam name="TRight">The type of the elements in the right source sequence.</typeparam>
  7757. /// <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>
  7758. /// <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>
  7759. /// <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>
  7760. /// <param name="left">The left observable sequence to join elements for.</param>
  7761. /// <param name="right">The right observable sequence to join elements for.</param>
  7762. /// <param name="leftDurationSelector">A function to select the duration of each element of the left observable sequence, used to determine overlap.</param>
  7763. /// <param name="rightDurationSelector">A function to select the duration of each element of the right observable sequence, used to determine overlap.</param>
  7764. /// <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>
  7765. /// <returns>An observable sequence that contains result elements computed from source elements that have an overlapping duration.</returns>
  7766. /// <exception cref="T:System.ArgumentNullException">
  7767. /// <paramref name="left" /> or <paramref name="right" /> or <paramref name="leftDurationSelector" /> or <paramref name="rightDurationSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  7768. 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)
  7769. {
  7770. if (left == null)
  7771. throw new ArgumentNullException("left");
  7772. if (right == null)
  7773. throw new ArgumentNullException("right");
  7774. if (leftDurationSelector == null)
  7775. throw new ArgumentNullException("leftDurationSelector");
  7776. if (rightDurationSelector == null)
  7777. throw new ArgumentNullException("rightDurationSelector");
  7778. if (resultSelector == null)
  7779. throw new ArgumentNullException("resultSelector");
  7780. return left.Provider.CreateQuery<TResult>(
  7781. Expression.Call(
  7782. null,
  7783. #if CRIPPLED_REFLECTION
  7784. 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>>))),
  7785. #else
  7786. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TLeft), typeof(TRight), typeof(TLeftDuration), typeof(TRightDuration), typeof(TResult)),
  7787. #endif
  7788. left.Expression,
  7789. GetSourceExpression(right),
  7790. leftDurationSelector,
  7791. rightDurationSelector,
  7792. resultSelector
  7793. )
  7794. );
  7795. }
  7796. /// <summary>
  7797. /// If the specified <paramref name="condition" /> evaluates true, select the <paramref name="thenSource" /> sequence. Otherwise, return an empty sequence.
  7798. /// </summary>
  7799. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  7800. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  7801. /// <param name="condition">Condition evaluated to decide which sequence to return.</param>
  7802. /// <param name="thenSource">Sequence returned in case <paramref name="condition" /> evaluates true.</param>
  7803. /// <returns>
  7804. /// <paramref name="thenSource" /> if <paramref name="condition" /> evaluates true; an empty sequence otherwise.</returns>
  7805. /// <exception cref="T:System.ArgumentNullException">
  7806. /// <paramref name="condition" /> or <paramref name="thenSource" /> is null.</exception>
  7807. public static IQbservable<TResult> If<TResult>(this IQbservableProvider provider, Expression<Func<bool>> condition, IObservable<TResult> thenSource)
  7808. {
  7809. if (provider == null)
  7810. throw new ArgumentNullException("provider");
  7811. if (condition == null)
  7812. throw new ArgumentNullException("condition");
  7813. if (thenSource == null)
  7814. throw new ArgumentNullException("thenSource");
  7815. return provider.CreateQuery<TResult>(
  7816. Expression.Call(
  7817. null,
  7818. #if CRIPPLED_REFLECTION
  7819. InfoOf(() => Qbservable.If<TResult>(default(IQbservableProvider), default(Expression<Func<bool>>), default(IObservable<TResult>))),
  7820. #else
  7821. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  7822. #endif
  7823. Expression.Constant(provider, typeof(IQbservableProvider)),
  7824. condition,
  7825. GetSourceExpression(thenSource)
  7826. )
  7827. );
  7828. }
  7829. /// <summary>
  7830. /// If the specified <paramref name="condition" /> evaluates true, select the <paramref name="thenSource" /> sequence. Otherwise, select the <paramref name="elseSource" /> sequence.
  7831. /// </summary>
  7832. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  7833. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  7834. /// <param name="condition">Condition evaluated to decide which sequence to return.</param>
  7835. /// <param name="thenSource">Sequence returned in case <paramref name="condition" /> evaluates true.</param>
  7836. /// <param name="elseSource">Sequence returned in case <paramref name="condition" /> evaluates false.</param>
  7837. /// <returns>
  7838. /// <paramref name="thenSource" /> if <paramref name="condition" /> evaluates true; <paramref name="elseSource" /> otherwise.</returns>
  7839. /// <exception cref="T:System.ArgumentNullException">
  7840. /// <paramref name="condition" /> or <paramref name="thenSource" /> or <paramref name="elseSource" /> is null.</exception>
  7841. public static IQbservable<TResult> If<TResult>(this IQbservableProvider provider, Expression<Func<bool>> condition, IObservable<TResult> thenSource, IObservable<TResult> elseSource)
  7842. {
  7843. if (provider == null)
  7844. throw new ArgumentNullException("provider");
  7845. if (condition == null)
  7846. throw new ArgumentNullException("condition");
  7847. if (thenSource == null)
  7848. throw new ArgumentNullException("thenSource");
  7849. if (elseSource == null)
  7850. throw new ArgumentNullException("elseSource");
  7851. return provider.CreateQuery<TResult>(
  7852. Expression.Call(
  7853. null,
  7854. #if CRIPPLED_REFLECTION
  7855. InfoOf(() => Qbservable.If<TResult>(default(IQbservableProvider), default(Expression<Func<bool>>), default(IObservable<TResult>), default(IObservable<TResult>))),
  7856. #else
  7857. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  7858. #endif
  7859. Expression.Constant(provider, typeof(IQbservableProvider)),
  7860. condition,
  7861. GetSourceExpression(thenSource),
  7862. GetSourceExpression(elseSource)
  7863. )
  7864. );
  7865. }
  7866. /// <summary>
  7867. /// If the specified <paramref name="condition" /> evaluates true, select the <paramref name="thenSource" /> sequence. Otherwise, return an empty sequence generated on the specified scheduler.
  7868. /// </summary>
  7869. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  7870. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  7871. /// <param name="condition">Condition evaluated to decide which sequence to return.</param>
  7872. /// <param name="thenSource">Sequence returned in case <paramref name="condition" /> evaluates true.</param>
  7873. /// <param name="scheduler">Scheduler to generate an empty sequence on in case <paramref name="condition" /> evaluates false.</param>
  7874. /// <returns>
  7875. /// <paramref name="thenSource" /> if <paramref name="condition" /> evaluates true; an empty sequence otherwise.</returns>
  7876. /// <exception cref="T:System.ArgumentNullException">
  7877. /// <paramref name="condition" /> or <paramref name="thenSource" /> or <paramref name="scheduler" /> is null.</exception>
  7878. public static IQbservable<TResult> If<TResult>(this IQbservableProvider provider, Expression<Func<bool>> condition, IObservable<TResult> thenSource, IScheduler scheduler)
  7879. {
  7880. if (provider == null)
  7881. throw new ArgumentNullException("provider");
  7882. if (condition == null)
  7883. throw new ArgumentNullException("condition");
  7884. if (thenSource == null)
  7885. throw new ArgumentNullException("thenSource");
  7886. if (scheduler == null)
  7887. throw new ArgumentNullException("scheduler");
  7888. return provider.CreateQuery<TResult>(
  7889. Expression.Call(
  7890. null,
  7891. #if CRIPPLED_REFLECTION
  7892. InfoOf(() => Qbservable.If<TResult>(default(IQbservableProvider), default(Expression<Func<bool>>), default(IObservable<TResult>), default(IScheduler))),
  7893. #else
  7894. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  7895. #endif
  7896. Expression.Constant(provider, typeof(IQbservableProvider)),
  7897. condition,
  7898. GetSourceExpression(thenSource),
  7899. Expression.Constant(scheduler, typeof(IScheduler))
  7900. )
  7901. );
  7902. }
  7903. /// <summary>
  7904. /// Ignores all elements in an observable sequence leaving only the termination messages.
  7905. /// </summary>
  7906. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7907. /// <param name="source">Source sequence.</param>
  7908. /// <returns>An empty observable sequence that signals termination, successful or exceptional, of the source sequence.</returns>
  7909. /// <exception cref="T:System.ArgumentNullException">
  7910. /// <paramref name="source" /> is null.</exception>
  7911. public static IQbservable<TSource> IgnoreElements<TSource>(this IQbservable<TSource> source)
  7912. {
  7913. if (source == null)
  7914. throw new ArgumentNullException("source");
  7915. return source.Provider.CreateQuery<TSource>(
  7916. Expression.Call(
  7917. null,
  7918. #if CRIPPLED_REFLECTION
  7919. InfoOf(() => Qbservable.IgnoreElements<TSource>(default(IQbservable<TSource>))),
  7920. #else
  7921. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7922. #endif
  7923. source.Expression
  7924. )
  7925. );
  7926. }
  7927. /// <summary>
  7928. /// Returns an observable sequence that produces a value after each period.
  7929. /// </summary>
  7930. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  7931. /// <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>
  7932. /// <returns>An observable sequence that produces a value after each period.</returns>
  7933. /// <exception cref="T:System.ArgumentOutOfRangeException">
  7934. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  7935. /// <remarks>
  7936. /// Intervals are measured between the start of subsequent notifications, not between the end of the previous and the start of the next notification.
  7937. /// If the observer takes longer than the interval period to handle the message, the subsequent notification will be delivered immediately after the
  7938. /// 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
  7939. /// <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})" />
  7940. /// operator instead.
  7941. /// </remarks>
  7942. public static IQbservable<long> Interval(this IQbservableProvider provider, TimeSpan period)
  7943. {
  7944. if (provider == null)
  7945. throw new ArgumentNullException("provider");
  7946. return provider.CreateQuery<long>(
  7947. Expression.Call(
  7948. null,
  7949. #if CRIPPLED_REFLECTION
  7950. InfoOf(() => Qbservable.Interval(default(IQbservableProvider), default(TimeSpan))),
  7951. #else
  7952. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7953. #endif
  7954. Expression.Constant(provider, typeof(IQbservableProvider)),
  7955. Expression.Constant(period, typeof(TimeSpan))
  7956. )
  7957. );
  7958. }
  7959. /// <summary>
  7960. /// Returns an observable sequence that produces a value after each period, using the specified scheduler to run timers and to send out observer messages.
  7961. /// </summary>
  7962. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  7963. /// <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>
  7964. /// <param name="scheduler">Scheduler to run the timer on.</param>
  7965. /// <returns>An observable sequence that produces a value after each period.</returns>
  7966. /// <exception cref="T:System.ArgumentOutOfRangeException">
  7967. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  7968. /// <exception cref="T:System.ArgumentNullException">
  7969. /// <paramref name="scheduler" /> is null.</exception>
  7970. /// <remarks>
  7971. /// Intervals are measured between the start of subsequent notifications, not between the end of the previous and the start of the next notification.
  7972. /// If the observer takes longer than the interval period to handle the message, the subsequent notification will be delivered immediately after the
  7973. /// 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
  7974. /// <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)" />
  7975. /// operator instead.
  7976. /// </remarks>
  7977. public static IQbservable<long> Interval(this IQbservableProvider provider, TimeSpan period, IScheduler scheduler)
  7978. {
  7979. if (provider == null)
  7980. throw new ArgumentNullException("provider");
  7981. if (scheduler == null)
  7982. throw new ArgumentNullException("scheduler");
  7983. return provider.CreateQuery<long>(
  7984. Expression.Call(
  7985. null,
  7986. #if CRIPPLED_REFLECTION
  7987. InfoOf(() => Qbservable.Interval(default(IQbservableProvider), default(TimeSpan), default(IScheduler))),
  7988. #else
  7989. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7990. #endif
  7991. Expression.Constant(provider, typeof(IQbservableProvider)),
  7992. Expression.Constant(period, typeof(TimeSpan)),
  7993. Expression.Constant(scheduler, typeof(IScheduler))
  7994. )
  7995. );
  7996. }
  7997. /// <summary>
  7998. /// Determines whether an observable sequence is empty.
  7999. /// </summary>
  8000. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8001. /// <param name="source">An observable sequence to check for emptiness.</param>
  8002. /// <returns>An observable sequence containing a single element determining whether the source sequence is empty.</returns>
  8003. /// <exception cref="T:System.ArgumentNullException">
  8004. /// <paramref name="source" /> is null.</exception>
  8005. public static IQbservable<bool> IsEmpty<TSource>(this IQbservable<TSource> source)
  8006. {
  8007. if (source == null)
  8008. throw new ArgumentNullException("source");
  8009. return source.Provider.CreateQuery<bool>(
  8010. Expression.Call(
  8011. null,
  8012. #if CRIPPLED_REFLECTION
  8013. InfoOf(() => Qbservable.IsEmpty<TSource>(default(IQbservable<TSource>))),
  8014. #else
  8015. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8016. #endif
  8017. source.Expression
  8018. )
  8019. );
  8020. }
  8021. /// <summary>
  8022. /// Correlates the elements of two sequences based on overlapping durations.
  8023. /// </summary>
  8024. /// <typeparam name="TLeft">The type of the elements in the left source sequence.</typeparam>
  8025. /// <typeparam name="TRight">The type of the elements in the right source sequence.</typeparam>
  8026. /// <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>
  8027. /// <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>
  8028. /// <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>
  8029. /// <param name="left">The left observable sequence to join elements for.</param>
  8030. /// <param name="right">The right observable sequence to join elements for.</param>
  8031. /// <param name="leftDurationSelector">A function to select the duration of each element of the left observable sequence, used to determine overlap.</param>
  8032. /// <param name="rightDurationSelector">A function to select the duration of each element of the right observable sequence, used to determine overlap.</param>
  8033. /// <param name="resultSelector">A function invoked to compute a result element for any two overlapping elements of the left and right observable sequences.</param>
  8034. /// <returns>An observable sequence that contains result elements computed from source elements that have an overlapping duration.</returns>
  8035. /// <exception cref="T:System.ArgumentNullException">
  8036. /// <paramref name="left" /> or <paramref name="right" /> or <paramref name="leftDurationSelector" /> or <paramref name="rightDurationSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  8037. 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)
  8038. {
  8039. if (left == null)
  8040. throw new ArgumentNullException("left");
  8041. if (right == null)
  8042. throw new ArgumentNullException("right");
  8043. if (leftDurationSelector == null)
  8044. throw new ArgumentNullException("leftDurationSelector");
  8045. if (rightDurationSelector == null)
  8046. throw new ArgumentNullException("rightDurationSelector");
  8047. if (resultSelector == null)
  8048. throw new ArgumentNullException("resultSelector");
  8049. return left.Provider.CreateQuery<TResult>(
  8050. Expression.Call(
  8051. null,
  8052. #if CRIPPLED_REFLECTION
  8053. 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>>))),
  8054. #else
  8055. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TLeft), typeof(TRight), typeof(TLeftDuration), typeof(TRightDuration), typeof(TResult)),
  8056. #endif
  8057. left.Expression,
  8058. GetSourceExpression(right),
  8059. leftDurationSelector,
  8060. rightDurationSelector,
  8061. resultSelector
  8062. )
  8063. );
  8064. }
  8065. /// <summary>
  8066. /// Returns the last element of an observable sequence.
  8067. /// </summary>
  8068. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8069. /// <param name="source">Source observable sequence.</param>
  8070. /// <returns>Sequence containing the last element in the observable sequence.</returns>
  8071. /// <exception cref="T:System.ArgumentNullException">
  8072. /// <paramref name="source" /> is null.</exception>
  8073. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  8074. public static IQbservable<TSource> LastAsync<TSource>(this IQbservable<TSource> source)
  8075. {
  8076. if (source == null)
  8077. throw new ArgumentNullException("source");
  8078. return source.Provider.CreateQuery<TSource>(
  8079. Expression.Call(
  8080. null,
  8081. #if CRIPPLED_REFLECTION
  8082. InfoOf(() => Qbservable.LastAsync<TSource>(default(IQbservable<TSource>))),
  8083. #else
  8084. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8085. #endif
  8086. source.Expression
  8087. )
  8088. );
  8089. }
  8090. /// <summary>
  8091. /// Returns the last element of an observable sequence that satisfies the condition in the predicate.
  8092. /// </summary>
  8093. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8094. /// <param name="source">Source observable sequence.</param>
  8095. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  8096. /// <returns>Sequence containing the last element in the observable sequence that satisfies the condition in the predicate.</returns>
  8097. /// <exception cref="T:System.ArgumentNullException">
  8098. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  8099. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) No element satisfies the condition in the predicate. -or- The source sequence is empty.</exception>
  8100. public static IQbservable<TSource> LastAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  8101. {
  8102. if (source == null)
  8103. throw new ArgumentNullException("source");
  8104. if (predicate == null)
  8105. throw new ArgumentNullException("predicate");
  8106. return source.Provider.CreateQuery<TSource>(
  8107. Expression.Call(
  8108. null,
  8109. #if CRIPPLED_REFLECTION
  8110. InfoOf(() => Qbservable.LastAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  8111. #else
  8112. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8113. #endif
  8114. source.Expression,
  8115. predicate
  8116. )
  8117. );
  8118. }
  8119. /// <summary>
  8120. /// Returns the last element of an observable sequence, or a default value if no such element exists.
  8121. /// </summary>
  8122. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8123. /// <param name="source">Source observable sequence.</param>
  8124. /// <returns>Sequence containing the last element in the observable sequence, or a default value if no such element exists.</returns>
  8125. /// <exception cref="T:System.ArgumentNullException">
  8126. /// <paramref name="source" /> is null.</exception>
  8127. public static IQbservable<TSource> LastOrDefaultAsync<TSource>(this IQbservable<TSource> source)
  8128. {
  8129. if (source == null)
  8130. throw new ArgumentNullException("source");
  8131. return source.Provider.CreateQuery<TSource>(
  8132. Expression.Call(
  8133. null,
  8134. #if CRIPPLED_REFLECTION
  8135. InfoOf(() => Qbservable.LastOrDefaultAsync<TSource>(default(IQbservable<TSource>))),
  8136. #else
  8137. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8138. #endif
  8139. source.Expression
  8140. )
  8141. );
  8142. }
  8143. /// <summary>
  8144. /// Returns the last element of an observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.
  8145. /// </summary>
  8146. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8147. /// <param name="source">Source observable sequence.</param>
  8148. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  8149. /// <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>
  8150. /// <exception cref="T:System.ArgumentNullException">
  8151. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  8152. public static IQbservable<TSource> LastOrDefaultAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  8153. {
  8154. if (source == null)
  8155. throw new ArgumentNullException("source");
  8156. if (predicate == null)
  8157. throw new ArgumentNullException("predicate");
  8158. return source.Provider.CreateQuery<TSource>(
  8159. Expression.Call(
  8160. null,
  8161. #if CRIPPLED_REFLECTION
  8162. InfoOf(() => Qbservable.LastOrDefaultAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  8163. #else
  8164. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8165. #endif
  8166. source.Expression,
  8167. predicate
  8168. )
  8169. );
  8170. }
  8171. /// <summary>
  8172. /// Returns an enumerable sequence whose enumeration returns the latest observed element in the source observable sequence.
  8173. /// Enumerators on the resulting sequence will never produce the same element repeatedly, and will block until the next element becomes available.
  8174. /// </summary>
  8175. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8176. /// <param name="source">Source observable sequence.</param>
  8177. /// <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>
  8178. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  8179. public static IQueryable<TSource> Latest<TSource>(this IQbservable<TSource> source)
  8180. {
  8181. if (source == null)
  8182. throw new ArgumentNullException("source");
  8183. return ((IQueryProvider)source.Provider).CreateQuery<TSource>(
  8184. Expression.Call(
  8185. null,
  8186. #if CRIPPLED_REFLECTION
  8187. InfoOf(() => Qbservable.Latest<TSource>(default(IQbservable<TSource>))),
  8188. #else
  8189. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8190. #endif
  8191. source.Expression
  8192. )
  8193. );
  8194. }
  8195. /// <summary>
  8196. /// Returns an observable sequence containing an <see cref="T:System.Int64" /> that represents the total number of elements in an observable sequence.
  8197. /// </summary>
  8198. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8199. /// <param name="source">An observable sequence that contains elements to be counted.</param>
  8200. /// <returns>An observable sequence containing a single element with the number of elements in the input sequence.</returns>
  8201. /// <exception cref="T:System.ArgumentNullException">
  8202. /// <paramref name="source" /> is null.</exception>
  8203. /// <exception cref="T:System.OverflowException">(Asynchronous) The number of elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue" />.</exception>
  8204. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8205. public static IQbservable<long> LongCount<TSource>(this IQbservable<TSource> source)
  8206. {
  8207. if (source == null)
  8208. throw new ArgumentNullException("source");
  8209. return source.Provider.CreateQuery<long>(
  8210. Expression.Call(
  8211. null,
  8212. #if CRIPPLED_REFLECTION
  8213. InfoOf(() => Qbservable.LongCount<TSource>(default(IQbservable<TSource>))),
  8214. #else
  8215. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8216. #endif
  8217. source.Expression
  8218. )
  8219. );
  8220. }
  8221. /// <summary>
  8222. /// Returns an observable sequence containing an <see cref="T:System.Int64" /> that represents how many elements in the specified observable sequence satisfy a condition.
  8223. /// </summary>
  8224. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8225. /// <param name="source">An observable sequence that contains elements to be counted.</param>
  8226. /// <param name="predicate">A function to test each element for a condition.</param>
  8227. /// <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>
  8228. /// <exception cref="T:System.ArgumentNullException">
  8229. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  8230. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8231. public static IQbservable<long> LongCount<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  8232. {
  8233. if (source == null)
  8234. throw new ArgumentNullException("source");
  8235. if (predicate == null)
  8236. throw new ArgumentNullException("predicate");
  8237. return source.Provider.CreateQuery<long>(
  8238. Expression.Call(
  8239. null,
  8240. #if CRIPPLED_REFLECTION
  8241. InfoOf(() => Qbservable.LongCount<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  8242. #else
  8243. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8244. #endif
  8245. source.Expression,
  8246. predicate
  8247. )
  8248. );
  8249. }
  8250. /// <summary>
  8251. /// Materializes the implicit notifications of an observable sequence as explicit notification values.
  8252. /// </summary>
  8253. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8254. /// <param name="source">An observable sequence to get notification values for.</param>
  8255. /// <returns>An observable sequence containing the materialized notification values from the source sequence.</returns>
  8256. /// <exception cref="T:System.ArgumentNullException">
  8257. /// <paramref name="source" /> is null.</exception>
  8258. public static IQbservable<Notification<TSource>> Materialize<TSource>(this IQbservable<TSource> source)
  8259. {
  8260. if (source == null)
  8261. throw new ArgumentNullException("source");
  8262. return source.Provider.CreateQuery<Notification<TSource>>(
  8263. Expression.Call(
  8264. null,
  8265. #if CRIPPLED_REFLECTION
  8266. InfoOf(() => Qbservable.Materialize<TSource>(default(IQbservable<TSource>))),
  8267. #else
  8268. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8269. #endif
  8270. source.Expression
  8271. )
  8272. );
  8273. }
  8274. /// <summary>
  8275. /// Returns the maximum value in an observable sequence of <see cref="T:System.Decimal" /> values.
  8276. /// </summary>
  8277. /// <param name="source">A sequence of <see cref="T:System.Decimal" /> values to determine the maximum value of.</param>
  8278. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8279. /// <exception cref="T:System.ArgumentNullException">
  8280. /// <paramref name="source" /> is null.</exception>
  8281. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8282. public static IQbservable<decimal> Max(this IQbservable<decimal> source)
  8283. {
  8284. if (source == null)
  8285. throw new ArgumentNullException("source");
  8286. return source.Provider.CreateQuery<decimal>(
  8287. Expression.Call(
  8288. null,
  8289. #if CRIPPLED_REFLECTION
  8290. InfoOf(() => Qbservable.Max(default(IQbservable<decimal>))),
  8291. #else
  8292. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8293. #endif
  8294. source.Expression
  8295. )
  8296. );
  8297. }
  8298. /// <summary>
  8299. /// Returns the maximum value in an observable sequence of <see cref="T:System.Double" /> values.
  8300. /// </summary>
  8301. /// <param name="source">A sequence of <see cref="T:System.Double" /> values to determine the maximum value of.</param>
  8302. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8303. /// <exception cref="T:System.ArgumentNullException">
  8304. /// <paramref name="source" /> is null.</exception>
  8305. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8306. public static IQbservable<double> Max(this IQbservable<double> source)
  8307. {
  8308. if (source == null)
  8309. throw new ArgumentNullException("source");
  8310. return source.Provider.CreateQuery<double>(
  8311. Expression.Call(
  8312. null,
  8313. #if CRIPPLED_REFLECTION
  8314. InfoOf(() => Qbservable.Max(default(IQbservable<double>))),
  8315. #else
  8316. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8317. #endif
  8318. source.Expression
  8319. )
  8320. );
  8321. }
  8322. /// <summary>
  8323. /// Returns the maximum value in an observable sequence of <see cref="T:System.Int32" /> values.
  8324. /// </summary>
  8325. /// <param name="source">A sequence of <see cref="T:System.Int32" /> values to determine the maximum value of.</param>
  8326. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8327. /// <exception cref="T:System.ArgumentNullException">
  8328. /// <paramref name="source" /> is null.</exception>
  8329. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8330. public static IQbservable<int> Max(this IQbservable<int> source)
  8331. {
  8332. if (source == null)
  8333. throw new ArgumentNullException("source");
  8334. return source.Provider.CreateQuery<int>(
  8335. Expression.Call(
  8336. null,
  8337. #if CRIPPLED_REFLECTION
  8338. InfoOf(() => Qbservable.Max(default(IQbservable<int>))),
  8339. #else
  8340. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8341. #endif
  8342. source.Expression
  8343. )
  8344. );
  8345. }
  8346. /// <summary>
  8347. /// Returns the maximum value in an observable sequence of <see cref="T:System.Int64" /> values.
  8348. /// </summary>
  8349. /// <param name="source">A sequence of <see cref="T:System.Int64" /> values to determine the maximum value of.</param>
  8350. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8351. /// <exception cref="T:System.ArgumentNullException">
  8352. /// <paramref name="source" /> is null.</exception>
  8353. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8354. public static IQbservable<long> Max(this IQbservable<long> source)
  8355. {
  8356. if (source == null)
  8357. throw new ArgumentNullException("source");
  8358. return source.Provider.CreateQuery<long>(
  8359. Expression.Call(
  8360. null,
  8361. #if CRIPPLED_REFLECTION
  8362. InfoOf(() => Qbservable.Max(default(IQbservable<long>))),
  8363. #else
  8364. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8365. #endif
  8366. source.Expression
  8367. )
  8368. );
  8369. }
  8370. /// <summary>
  8371. /// Returns the maximum value in an observable sequence of nullable <see cref="T:System.Decimal" /> values.
  8372. /// </summary>
  8373. /// <param name="source">A sequence of nullable <see cref="T:System.Decimal" /> values to determine the maximum value of.</param>
  8374. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8375. /// <exception cref="T:System.ArgumentNullException">
  8376. /// <paramref name="source" /> is null.</exception>
  8377. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8378. public static IQbservable<decimal?> Max(this IQbservable<decimal?> source)
  8379. {
  8380. if (source == null)
  8381. throw new ArgumentNullException("source");
  8382. return source.Provider.CreateQuery<decimal?>(
  8383. Expression.Call(
  8384. null,
  8385. #if CRIPPLED_REFLECTION
  8386. InfoOf(() => Qbservable.Max(default(IQbservable<decimal?>))),
  8387. #else
  8388. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8389. #endif
  8390. source.Expression
  8391. )
  8392. );
  8393. }
  8394. /// <summary>
  8395. /// Returns the maximum value in an observable sequence of nullable <see cref="T:System.Double" /> values.
  8396. /// </summary>
  8397. /// <param name="source">A sequence of nullable <see cref="T:System.Double" /> values to determine the maximum value of.</param>
  8398. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8399. /// <exception cref="T:System.ArgumentNullException">
  8400. /// <paramref name="source" /> is null.</exception>
  8401. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8402. public static IQbservable<double?> Max(this IQbservable<double?> source)
  8403. {
  8404. if (source == null)
  8405. throw new ArgumentNullException("source");
  8406. return source.Provider.CreateQuery<double?>(
  8407. Expression.Call(
  8408. null,
  8409. #if CRIPPLED_REFLECTION
  8410. InfoOf(() => Qbservable.Max(default(IQbservable<double?>))),
  8411. #else
  8412. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8413. #endif
  8414. source.Expression
  8415. )
  8416. );
  8417. }
  8418. /// <summary>
  8419. /// Returns the maximum value in an observable sequence of nullable <see cref="T:System.Int32" /> values.
  8420. /// </summary>
  8421. /// <param name="source">A sequence of nullable <see cref="T:System.Int32" /> values to determine the maximum value of.</param>
  8422. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8423. /// <exception cref="T:System.ArgumentNullException">
  8424. /// <paramref name="source" /> is null.</exception>
  8425. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8426. public static IQbservable<int?> Max(this IQbservable<int?> source)
  8427. {
  8428. if (source == null)
  8429. throw new ArgumentNullException("source");
  8430. return source.Provider.CreateQuery<int?>(
  8431. Expression.Call(
  8432. null,
  8433. #if CRIPPLED_REFLECTION
  8434. InfoOf(() => Qbservable.Max(default(IQbservable<int?>))),
  8435. #else
  8436. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8437. #endif
  8438. source.Expression
  8439. )
  8440. );
  8441. }
  8442. /// <summary>
  8443. /// Returns the maximum value in an observable sequence of nullable <see cref="T:System.Int64" /> values.
  8444. /// </summary>
  8445. /// <param name="source">A sequence of nullable <see cref="T:System.Int64" /> values to determine the maximum value of.</param>
  8446. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8447. /// <exception cref="T:System.ArgumentNullException">
  8448. /// <paramref name="source" /> is null.</exception>
  8449. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8450. public static IQbservable<long?> Max(this IQbservable<long?> source)
  8451. {
  8452. if (source == null)
  8453. throw new ArgumentNullException("source");
  8454. return source.Provider.CreateQuery<long?>(
  8455. Expression.Call(
  8456. null,
  8457. #if CRIPPLED_REFLECTION
  8458. InfoOf(() => Qbservable.Max(default(IQbservable<long?>))),
  8459. #else
  8460. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8461. #endif
  8462. source.Expression
  8463. )
  8464. );
  8465. }
  8466. /// <summary>
  8467. /// Returns the maximum value in an observable sequence of nullable <see cref="T:System.Single" /> values.
  8468. /// </summary>
  8469. /// <param name="source">A sequence of nullable <see cref="T:System.Single" /> values to determine the maximum value of.</param>
  8470. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8471. /// <exception cref="T:System.ArgumentNullException">
  8472. /// <paramref name="source" /> is null.</exception>
  8473. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8474. public static IQbservable<float?> Max(this IQbservable<float?> source)
  8475. {
  8476. if (source == null)
  8477. throw new ArgumentNullException("source");
  8478. return source.Provider.CreateQuery<float?>(
  8479. Expression.Call(
  8480. null,
  8481. #if CRIPPLED_REFLECTION
  8482. InfoOf(() => Qbservable.Max(default(IQbservable<float?>))),
  8483. #else
  8484. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8485. #endif
  8486. source.Expression
  8487. )
  8488. );
  8489. }
  8490. /// <summary>
  8491. /// Returns the maximum value in an observable sequence of <see cref="T:System.Single" /> values.
  8492. /// </summary>
  8493. /// <param name="source">A sequence of <see cref="T:System.Single" /> values to determine the maximum value of.</param>
  8494. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8495. /// <exception cref="T:System.ArgumentNullException">
  8496. /// <paramref name="source" /> 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<float> Max(this IQbservable<float> source)
  8499. {
  8500. if (source == null)
  8501. throw new ArgumentNullException("source");
  8502. return source.Provider.CreateQuery<float>(
  8503. Expression.Call(
  8504. null,
  8505. #if CRIPPLED_REFLECTION
  8506. InfoOf(() => Qbservable.Max(default(IQbservable<float>))),
  8507. #else
  8508. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8509. #endif
  8510. source.Expression
  8511. )
  8512. );
  8513. }
  8514. /// <summary>
  8515. /// Returns the maximum element in an observable sequence.
  8516. /// </summary>
  8517. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8518. /// <param name="source">An observable sequence to determine the maximum element of.</param>
  8519. /// <returns>An observable sequence containing a single element with the maximum element in the source sequence.</returns>
  8520. /// <exception cref="T:System.ArgumentNullException">
  8521. /// <paramref name="source" /> is null.</exception>
  8522. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8523. public static IQbservable<TSource> Max<TSource>(this IQbservable<TSource> source)
  8524. {
  8525. if (source == null)
  8526. throw new ArgumentNullException("source");
  8527. return source.Provider.CreateQuery<TSource>(
  8528. Expression.Call(
  8529. null,
  8530. #if CRIPPLED_REFLECTION
  8531. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>))),
  8532. #else
  8533. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8534. #endif
  8535. source.Expression
  8536. )
  8537. );
  8538. }
  8539. /// <summary>
  8540. /// Returns the maximum value in an observable sequence according to the specified comparer.
  8541. /// </summary>
  8542. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8543. /// <param name="source">An observable sequence to determine the maximum element of.</param>
  8544. /// <param name="comparer">Comparer used to compare elements.</param>
  8545. /// <returns>An observable sequence containing a single element with the maximum element in the source sequence.</returns>
  8546. /// <exception cref="T:System.ArgumentNullException">
  8547. /// <paramref name="source" /> or <paramref name="comparer" /> is null.</exception>
  8548. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8549. public static IQbservable<TSource> Max<TSource>(this IQbservable<TSource> source, IComparer<TSource> comparer)
  8550. {
  8551. if (source == null)
  8552. throw new ArgumentNullException("source");
  8553. if (comparer == null)
  8554. throw new ArgumentNullException("comparer");
  8555. return source.Provider.CreateQuery<TSource>(
  8556. Expression.Call(
  8557. null,
  8558. #if CRIPPLED_REFLECTION
  8559. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(IComparer<TSource>))),
  8560. #else
  8561. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8562. #endif
  8563. source.Expression,
  8564. Expression.Constant(comparer, typeof(IComparer<TSource>))
  8565. )
  8566. );
  8567. }
  8568. /// <summary>
  8569. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="T:System.Decimal" /> value.
  8570. /// </summary>
  8571. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8572. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8573. /// <param name="selector">A transform function to apply to each element.</param>
  8574. /// <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>
  8575. /// <exception cref="T:System.ArgumentNullException">
  8576. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8577. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8578. public static IQbservable<decimal> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal>> selector)
  8579. {
  8580. if (source == null)
  8581. throw new ArgumentNullException("source");
  8582. if (selector == null)
  8583. throw new ArgumentNullException("selector");
  8584. return source.Provider.CreateQuery<decimal>(
  8585. Expression.Call(
  8586. null,
  8587. #if CRIPPLED_REFLECTION
  8588. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal>>))),
  8589. #else
  8590. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8591. #endif
  8592. source.Expression,
  8593. selector
  8594. )
  8595. );
  8596. }
  8597. /// <summary>
  8598. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="T:System.Int32" /> value.
  8599. /// </summary>
  8600. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8601. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8602. /// <param name="selector">A transform function to apply to each element.</param>
  8603. /// <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>
  8604. /// <exception cref="T:System.ArgumentNullException">
  8605. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8606. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8607. public static IQbservable<int> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int>> selector)
  8608. {
  8609. if (source == null)
  8610. throw new ArgumentNullException("source");
  8611. if (selector == null)
  8612. throw new ArgumentNullException("selector");
  8613. return source.Provider.CreateQuery<int>(
  8614. Expression.Call(
  8615. null,
  8616. #if CRIPPLED_REFLECTION
  8617. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int>>))),
  8618. #else
  8619. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8620. #endif
  8621. source.Expression,
  8622. selector
  8623. )
  8624. );
  8625. }
  8626. /// <summary>
  8627. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="T:System.Int64" /> value.
  8628. /// </summary>
  8629. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8630. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8631. /// <param name="selector">A transform function to apply to each element.</param>
  8632. /// <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>
  8633. /// <exception cref="T:System.ArgumentNullException">
  8634. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8635. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8636. public static IQbservable<long> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long>> selector)
  8637. {
  8638. if (source == null)
  8639. throw new ArgumentNullException("source");
  8640. if (selector == null)
  8641. throw new ArgumentNullException("selector");
  8642. return source.Provider.CreateQuery<long>(
  8643. Expression.Call(
  8644. null,
  8645. #if CRIPPLED_REFLECTION
  8646. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long>>))),
  8647. #else
  8648. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8649. #endif
  8650. source.Expression,
  8651. selector
  8652. )
  8653. );
  8654. }
  8655. /// <summary>
  8656. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="T:System.Double" /> value.
  8657. /// </summary>
  8658. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8659. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8660. /// <param name="selector">A transform function to apply to each element.</param>
  8661. /// <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>
  8662. /// <exception cref="T:System.ArgumentNullException">
  8663. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8664. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8665. public static IQbservable<double?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double?>> selector)
  8666. {
  8667. if (source == null)
  8668. throw new ArgumentNullException("source");
  8669. if (selector == null)
  8670. throw new ArgumentNullException("selector");
  8671. return source.Provider.CreateQuery<double?>(
  8672. Expression.Call(
  8673. null,
  8674. #if CRIPPLED_REFLECTION
  8675. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double?>>))),
  8676. #else
  8677. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8678. #endif
  8679. source.Expression,
  8680. selector
  8681. )
  8682. );
  8683. }
  8684. /// <summary>
  8685. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="T:System.Single" /> value.
  8686. /// </summary>
  8687. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8688. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8689. /// <param name="selector">A transform function to apply to each element.</param>
  8690. /// <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>
  8691. /// <exception cref="T:System.ArgumentNullException">
  8692. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8693. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8694. public static IQbservable<float?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float?>> selector)
  8695. {
  8696. if (source == null)
  8697. throw new ArgumentNullException("source");
  8698. if (selector == null)
  8699. throw new ArgumentNullException("selector");
  8700. return source.Provider.CreateQuery<float?>(
  8701. Expression.Call(
  8702. null,
  8703. #if CRIPPLED_REFLECTION
  8704. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float?>>))),
  8705. #else
  8706. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8707. #endif
  8708. source.Expression,
  8709. selector
  8710. )
  8711. );
  8712. }
  8713. /// <summary>
  8714. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="T:System.Decimal" /> value.
  8715. /// </summary>
  8716. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8717. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8718. /// <param name="selector">A transform function to apply to each element.</param>
  8719. /// <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>
  8720. /// <exception cref="T:System.ArgumentNullException">
  8721. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8722. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8723. public static IQbservable<decimal?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal?>> selector)
  8724. {
  8725. if (source == null)
  8726. throw new ArgumentNullException("source");
  8727. if (selector == null)
  8728. throw new ArgumentNullException("selector");
  8729. return source.Provider.CreateQuery<decimal?>(
  8730. Expression.Call(
  8731. null,
  8732. #if CRIPPLED_REFLECTION
  8733. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal?>>))),
  8734. #else
  8735. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8736. #endif
  8737. source.Expression,
  8738. selector
  8739. )
  8740. );
  8741. }
  8742. /// <summary>
  8743. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="T:System.Int32" /> value.
  8744. /// </summary>
  8745. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8746. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8747. /// <param name="selector">A transform function to apply to each element.</param>
  8748. /// <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>
  8749. /// <exception cref="T:System.ArgumentNullException">
  8750. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8751. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8752. public static IQbservable<int?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int?>> selector)
  8753. {
  8754. if (source == null)
  8755. throw new ArgumentNullException("source");
  8756. if (selector == null)
  8757. throw new ArgumentNullException("selector");
  8758. return source.Provider.CreateQuery<int?>(
  8759. Expression.Call(
  8760. null,
  8761. #if CRIPPLED_REFLECTION
  8762. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int?>>))),
  8763. #else
  8764. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8765. #endif
  8766. source.Expression,
  8767. selector
  8768. )
  8769. );
  8770. }
  8771. /// <summary>
  8772. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="T:System.Int64" /> value.
  8773. /// </summary>
  8774. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8775. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8776. /// <param name="selector">A transform function to apply to each element.</param>
  8777. /// <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>
  8778. /// <exception cref="T:System.ArgumentNullException">
  8779. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8780. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8781. public static IQbservable<long?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long?>> selector)
  8782. {
  8783. if (source == null)
  8784. throw new ArgumentNullException("source");
  8785. if (selector == null)
  8786. throw new ArgumentNullException("selector");
  8787. return source.Provider.CreateQuery<long?>(
  8788. Expression.Call(
  8789. null,
  8790. #if CRIPPLED_REFLECTION
  8791. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long?>>))),
  8792. #else
  8793. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8794. #endif
  8795. source.Expression,
  8796. selector
  8797. )
  8798. );
  8799. }
  8800. /// <summary>
  8801. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="T:System.Double" /> value.
  8802. /// </summary>
  8803. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8804. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8805. /// <param name="selector">A transform function to apply to each element.</param>
  8806. /// <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>
  8807. /// <exception cref="T:System.ArgumentNullException">
  8808. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8809. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8810. public static IQbservable<double> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double>> selector)
  8811. {
  8812. if (source == null)
  8813. throw new ArgumentNullException("source");
  8814. if (selector == null)
  8815. throw new ArgumentNullException("selector");
  8816. return source.Provider.CreateQuery<double>(
  8817. Expression.Call(
  8818. null,
  8819. #if CRIPPLED_REFLECTION
  8820. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double>>))),
  8821. #else
  8822. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8823. #endif
  8824. source.Expression,
  8825. selector
  8826. )
  8827. );
  8828. }
  8829. /// <summary>
  8830. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="T:System.Single" /> value.
  8831. /// </summary>
  8832. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8833. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8834. /// <param name="selector">A transform function to apply to each element.</param>
  8835. /// <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>
  8836. /// <exception cref="T:System.ArgumentNullException">
  8837. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8838. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8839. public static IQbservable<float> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float>> selector)
  8840. {
  8841. if (source == null)
  8842. throw new ArgumentNullException("source");
  8843. if (selector == null)
  8844. throw new ArgumentNullException("selector");
  8845. return source.Provider.CreateQuery<float>(
  8846. Expression.Call(
  8847. null,
  8848. #if CRIPPLED_REFLECTION
  8849. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float>>))),
  8850. #else
  8851. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8852. #endif
  8853. source.Expression,
  8854. selector
  8855. )
  8856. );
  8857. }
  8858. /// <summary>
  8859. /// Invokes a transform function on each element of a sequence and returns the maximum value.
  8860. /// </summary>
  8861. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8862. /// <typeparam name="TResult">The type of the objects derived from the elements in the source sequence to determine the maximum of.</typeparam>
  8863. /// <param name="source">An observable sequence to determine the mimimum element of.</param>
  8864. /// <param name="selector">A transform function to apply to each element.</param>
  8865. /// <returns>An observable sequence containing a single element with the value that corresponds to the maximum element in the source sequence.</returns>
  8866. /// <exception cref="T:System.ArgumentNullException">
  8867. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8868. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8869. public static IQbservable<TResult> Max<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector)
  8870. {
  8871. if (source == null)
  8872. throw new ArgumentNullException("source");
  8873. if (selector == null)
  8874. throw new ArgumentNullException("selector");
  8875. return source.Provider.CreateQuery<TResult>(
  8876. Expression.Call(
  8877. null,
  8878. #if CRIPPLED_REFLECTION
  8879. InfoOf(() => Qbservable.Max<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>))),
  8880. #else
  8881. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  8882. #endif
  8883. source.Expression,
  8884. selector
  8885. )
  8886. );
  8887. }
  8888. /// <summary>
  8889. /// Invokes a transform function on each element of a sequence and returns the maximum value according to the specified comparer.
  8890. /// </summary>
  8891. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8892. /// <typeparam name="TResult">The type of the objects derived from the elements in the source sequence to determine the maximum of.</typeparam>
  8893. /// <param name="source">An observable sequence to determine the mimimum element of.</param>
  8894. /// <param name="selector">A transform function to apply to each element.</param>
  8895. /// <param name="comparer">Comparer used to compare elements.</param>
  8896. /// <returns>An observable sequence containing a single element with the value that corresponds to the maximum element in the source sequence.</returns>
  8897. /// <exception cref="T:System.ArgumentNullException">
  8898. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="comparer" /> is null.</exception>
  8899. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8900. public static IQbservable<TResult> Max<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector, IComparer<TResult> comparer)
  8901. {
  8902. if (source == null)
  8903. throw new ArgumentNullException("source");
  8904. if (selector == null)
  8905. throw new ArgumentNullException("selector");
  8906. if (comparer == null)
  8907. throw new ArgumentNullException("comparer");
  8908. return source.Provider.CreateQuery<TResult>(
  8909. Expression.Call(
  8910. null,
  8911. #if CRIPPLED_REFLECTION
  8912. InfoOf(() => Qbservable.Max<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>), default(IComparer<TResult>))),
  8913. #else
  8914. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  8915. #endif
  8916. source.Expression,
  8917. selector,
  8918. Expression.Constant(comparer, typeof(IComparer<TResult>))
  8919. )
  8920. );
  8921. }
  8922. /// <summary>
  8923. /// Returns the elements in an observable sequence with the maximum key value.
  8924. /// </summary>
  8925. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8926. /// <typeparam name="TKey">The type of the key computed for each element in the source sequence.</typeparam>
  8927. /// <param name="source">An observable sequence to get the maximum elements for.</param>
  8928. /// <param name="keySelector">Key selector function.</param>
  8929. /// <returns>An observable sequence containing a list of zero or more elements that have a maximum key value.</returns>
  8930. /// <exception cref="T:System.ArgumentNullException">
  8931. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  8932. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8933. public static IQbservable<IList<TSource>> MaxBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  8934. {
  8935. if (source == null)
  8936. throw new ArgumentNullException("source");
  8937. if (keySelector == null)
  8938. throw new ArgumentNullException("keySelector");
  8939. return source.Provider.CreateQuery<IList<TSource>>(
  8940. Expression.Call(
  8941. null,
  8942. #if CRIPPLED_REFLECTION
  8943. InfoOf(() => Qbservable.MaxBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  8944. #else
  8945. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  8946. #endif
  8947. source.Expression,
  8948. keySelector
  8949. )
  8950. );
  8951. }
  8952. /// <summary>
  8953. /// Returns the elements in an observable sequence with the maximum key value according to the specified comparer.
  8954. /// </summary>
  8955. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8956. /// <typeparam name="TKey">The type of the key computed for each element in the source sequence.</typeparam>
  8957. /// <param name="source">An observable sequence to get the maximum elements for.</param>
  8958. /// <param name="keySelector">Key selector function.</param>
  8959. /// <param name="comparer">Comparer used to compare key values.</param>
  8960. /// <returns>An observable sequence containing a list of zero or more elements that have a maximum key value.</returns>
  8961. /// <exception cref="T:System.ArgumentNullException">
  8962. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  8963. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8964. public static IQbservable<IList<TSource>> MaxBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer)
  8965. {
  8966. if (source == null)
  8967. throw new ArgumentNullException("source");
  8968. if (keySelector == null)
  8969. throw new ArgumentNullException("keySelector");
  8970. if (comparer == null)
  8971. throw new ArgumentNullException("comparer");
  8972. return source.Provider.CreateQuery<IList<TSource>>(
  8973. Expression.Call(
  8974. null,
  8975. #if CRIPPLED_REFLECTION
  8976. InfoOf(() => Qbservable.MaxBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IComparer<TKey>))),
  8977. #else
  8978. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  8979. #endif
  8980. source.Expression,
  8981. keySelector,
  8982. Expression.Constant(comparer, typeof(IComparer<TKey>))
  8983. )
  8984. );
  8985. }
  8986. /// <summary>
  8987. /// Merges elements from two observable sequences into a single observable sequence.
  8988. /// </summary>
  8989. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8990. /// <param name="first">First observable sequence.</param>
  8991. /// <param name="second">Second observable sequence.</param>
  8992. /// <returns>The observable sequence that merges the elements of the given sequences.</returns>
  8993. /// <exception cref="T:System.ArgumentNullException">
  8994. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  8995. public static IQbservable<TSource> Merge<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  8996. {
  8997. if (first == null)
  8998. throw new ArgumentNullException("first");
  8999. if (second == null)
  9000. throw new ArgumentNullException("second");
  9001. return first.Provider.CreateQuery<TSource>(
  9002. Expression.Call(
  9003. null,
  9004. #if CRIPPLED_REFLECTION
  9005. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  9006. #else
  9007. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9008. #endif
  9009. first.Expression,
  9010. GetSourceExpression(second)
  9011. )
  9012. );
  9013. }
  9014. /// <summary>
  9015. /// Merges elements from two observable sequences into a single observable sequence, using the specified scheduler for enumeration of and subscription to the sources.
  9016. /// </summary>
  9017. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  9018. /// <param name="first">First observable sequence.</param>
  9019. /// <param name="second">Second observable sequence.</param>
  9020. /// <param name="scheduler">Scheduler used to introduce concurrency for making subscriptions to the given sequences.</param>
  9021. /// <returns>The observable sequence that merges the elements of the given sequences.</returns>
  9022. /// <exception cref="T:System.ArgumentNullException">
  9023. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="scheduler" /> is null.</exception>
  9024. public static IQbservable<TSource> Merge<TSource>(this IQbservable<TSource> first, IObservable<TSource> second, IScheduler scheduler)
  9025. {
  9026. if (first == null)
  9027. throw new ArgumentNullException("first");
  9028. if (second == null)
  9029. throw new ArgumentNullException("second");
  9030. if (scheduler == null)
  9031. throw new ArgumentNullException("scheduler");
  9032. return first.Provider.CreateQuery<TSource>(
  9033. Expression.Call(
  9034. null,
  9035. #if CRIPPLED_REFLECTION
  9036. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>), default(IScheduler))),
  9037. #else
  9038. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9039. #endif
  9040. first.Expression,
  9041. GetSourceExpression(second),
  9042. Expression.Constant(scheduler, typeof(IScheduler))
  9043. )
  9044. );
  9045. }
  9046. /// <summary>
  9047. /// 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.
  9048. /// </summary>
  9049. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  9050. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  9051. /// <param name="sources">Observable sequences.</param>
  9052. /// <param name="scheduler">Scheduler to run the enumeration of the sequence of sources on.</param>
  9053. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  9054. /// <exception cref="T:System.ArgumentNullException">
  9055. /// <paramref name="scheduler" /> or <paramref name="sources" /> is null.</exception>
  9056. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IScheduler scheduler, params IObservable<TSource>[] sources)
  9057. {
  9058. if (provider == null)
  9059. throw new ArgumentNullException("provider");
  9060. if (scheduler == null)
  9061. throw new ArgumentNullException("scheduler");
  9062. if (sources == null)
  9063. throw new ArgumentNullException("sources");
  9064. return provider.CreateQuery<TSource>(
  9065. Expression.Call(
  9066. null,
  9067. #if CRIPPLED_REFLECTION
  9068. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IScheduler), default(IObservable<TSource>[]))),
  9069. #else
  9070. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9071. #endif
  9072. Expression.Constant(provider, typeof(IQbservableProvider)),
  9073. Expression.Constant(scheduler, typeof(IScheduler)),
  9074. GetSourceExpression(sources)
  9075. )
  9076. );
  9077. }
  9078. /// <summary>
  9079. /// Merges elements from all observable sequences in the given enumerable sequence into a single observable sequence.
  9080. /// </summary>
  9081. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  9082. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  9083. /// <param name="sources">Enumerable sequence of observable sequences.</param>
  9084. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  9085. /// <exception cref="T:System.ArgumentNullException">
  9086. /// <paramref name="sources" /> is null.</exception>
  9087. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  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>>))),
  9098. #else
  9099. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9100. #endif
  9101. Expression.Constant(provider, typeof(IQbservableProvider)),
  9102. GetSourceExpression(sources)
  9103. )
  9104. );
  9105. }
  9106. /// <summary>
  9107. /// Merges elements from all inner observable sequences into a single observable sequence.
  9108. /// </summary>
  9109. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  9110. /// <param name="sources">Observable sequence of inner observable sequences.</param>
  9111. /// <returns>The observable sequence that merges the elements of the inner sequences.</returns>
  9112. /// <exception cref="T:System.ArgumentNullException">
  9113. /// <paramref name="sources" /> is null.</exception>
  9114. public static IQbservable<TSource> Merge<TSource>(this IQbservable<IObservable<TSource>> sources)
  9115. {
  9116. if (sources == null)
  9117. throw new ArgumentNullException("sources");
  9118. return sources.Provider.CreateQuery<TSource>(
  9119. Expression.Call(
  9120. null,
  9121. #if CRIPPLED_REFLECTION
  9122. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<IObservable<TSource>>))),
  9123. #else
  9124. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9125. #endif
  9126. sources.Expression
  9127. )
  9128. );
  9129. }
  9130. #if !NO_TPL
  9131. /// <summary>
  9132. /// Merges results from all source tasks into a single observable sequence.
  9133. /// </summary>
  9134. /// <typeparam name="TSource">The type of the results produced by the source tasks.</typeparam>
  9135. /// <param name="sources">Observable sequence of tasks.</param>
  9136. /// <returns>The observable sequence that merges the results of the source tasks.</returns>
  9137. /// <exception cref="T:System.ArgumentNullException">
  9138. /// <paramref name="sources" /> is null.</exception>
  9139. /// <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>
  9140. public static IQbservable<TSource> Merge<TSource>(this IQbservable<Task<TSource>> sources)
  9141. {
  9142. if (sources == null)
  9143. throw new ArgumentNullException("sources");
  9144. return sources.Provider.CreateQuery<TSource>(
  9145. Expression.Call(
  9146. null,
  9147. #if CRIPPLED_REFLECTION
  9148. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<Task<TSource>>))),
  9149. #else
  9150. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9151. #endif
  9152. sources.Expression
  9153. )
  9154. );
  9155. }
  9156. #endif
  9157. /// <summary>
  9158. /// Merges elements from all of the specified observable sequences into a single observable sequence.
  9159. /// </summary>
  9160. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  9161. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  9162. /// <param name="sources">Observable sequences.</param>
  9163. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  9164. /// <exception cref="T:System.ArgumentNullException">
  9165. /// <paramref name="sources" /> is null.</exception>
  9166. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  9167. {
  9168. if (provider == null)
  9169. throw new ArgumentNullException("provider");
  9170. if (sources == null)
  9171. throw new ArgumentNullException("sources");
  9172. return provider.CreateQuery<TSource>(
  9173. Expression.Call(
  9174. null,
  9175. #if CRIPPLED_REFLECTION
  9176. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  9177. #else
  9178. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9179. #endif
  9180. Expression.Constant(provider, typeof(IQbservableProvider)),
  9181. GetSourceExpression(sources)
  9182. )
  9183. );
  9184. }
  9185. /// <summary>
  9186. /// Merges elements from all inner observable sequences into a single observable sequence, limiting the number of concurrent subscriptions to inner sequences.
  9187. /// </summary>
  9188. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  9189. /// <param name="sources">Observable sequence of inner observable sequences.</param>
  9190. /// <param name="maxConcurrent">Maximum number of inner observable sequences being subscribed to concurrently.</param>
  9191. /// <returns>The observable sequence that merges the elements of the inner sequences.</returns>
  9192. /// <exception cref="T:System.ArgumentNullException">
  9193. /// <paramref name="sources" /> is null.</exception>
  9194. /// <exception cref="T:System.ArgumentOutOfRangeException">
  9195. /// <paramref name="maxConcurrent" /> is less than or equal to zero.</exception>
  9196. public static IQbservable<TSource> Merge<TSource>(this IQbservable<IObservable<TSource>> sources, int maxConcurrent)
  9197. {
  9198. if (sources == null)
  9199. throw new ArgumentNullException("sources");
  9200. return sources.Provider.CreateQuery<TSource>(
  9201. Expression.Call(
  9202. null,
  9203. #if CRIPPLED_REFLECTION
  9204. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<IObservable<TSource>>), default(int))),
  9205. #else
  9206. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9207. #endif
  9208. sources.Expression,
  9209. Expression.Constant(maxConcurrent, typeof(int))
  9210. )
  9211. );
  9212. }
  9213. /// <summary>
  9214. /// 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.
  9215. /// </summary>
  9216. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  9217. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  9218. /// <param name="sources">Enumerable sequence of observable sequences.</param>
  9219. /// <param name="maxConcurrent">Maximum number of observable sequences being subscribed to concurrently.</param>
  9220. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  9221. /// <exception cref="T:System.ArgumentNullException">
  9222. /// <paramref name="sources" /> is null.</exception>
  9223. /// <exception cref="T:System.ArgumentOutOfRangeException">
  9224. /// <paramref name="maxConcurrent" /> is less than or equal to zero.</exception>
  9225. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, int maxConcurrent)
  9226. {
  9227. if (provider == null)
  9228. throw new ArgumentNullException("provider");
  9229. if (sources == null)
  9230. throw new ArgumentNullException("sources");
  9231. return provider.CreateQuery<TSource>(
  9232. Expression.Call(
  9233. null,
  9234. #if CRIPPLED_REFLECTION
  9235. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(int))),
  9236. #else
  9237. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9238. #endif
  9239. Expression.Constant(provider, typeof(IQbservableProvider)),
  9240. GetSourceExpression(sources),
  9241. Expression.Constant(maxConcurrent, typeof(int))
  9242. )
  9243. );
  9244. }
  9245. /// <summary>
  9246. /// 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.
  9247. /// </summary>
  9248. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  9249. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  9250. /// <param name="sources">Enumerable sequence of observable sequences.</param>
  9251. /// <param name="maxConcurrent">Maximum number of observable sequences being subscribed to concurrently.</param>
  9252. /// <param name="scheduler">Scheduler to run the enumeration of the sequence of sources on.</param>
  9253. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  9254. /// <exception cref="T:System.ArgumentNullException">
  9255. /// <paramref name="sources" /> or <paramref name="scheduler" /> is null.</exception>
  9256. /// <exception cref="T:System.ArgumentOutOfRangeException">
  9257. /// <paramref name="maxConcurrent" /> is less than or equal to zero.</exception>
  9258. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, int maxConcurrent, IScheduler scheduler)
  9259. {
  9260. if (provider == null)
  9261. throw new ArgumentNullException("provider");
  9262. if (sources == null)
  9263. throw new ArgumentNullException("sources");
  9264. if (scheduler == null)
  9265. throw new ArgumentNullException("scheduler");
  9266. return provider.CreateQuery<TSource>(
  9267. Expression.Call(
  9268. null,
  9269. #if CRIPPLED_REFLECTION
  9270. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(int), default(IScheduler))),
  9271. #else
  9272. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9273. #endif
  9274. Expression.Constant(provider, typeof(IQbservableProvider)),
  9275. GetSourceExpression(sources),
  9276. Expression.Constant(maxConcurrent, typeof(int)),
  9277. Expression.Constant(scheduler, typeof(IScheduler))
  9278. )
  9279. );
  9280. }
  9281. /// <summary>
  9282. /// 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.
  9283. /// </summary>
  9284. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  9285. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  9286. /// <param name="sources">Enumerable sequence of observable sequences.</param>
  9287. /// <param name="scheduler">Scheduler to run the enumeration of the sequence of sources on.</param>
  9288. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  9289. /// <exception cref="T:System.ArgumentNullException">
  9290. /// <paramref name="sources" /> or <paramref name="scheduler" /> is null.</exception>
  9291. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, IScheduler scheduler)
  9292. {
  9293. if (provider == null)
  9294. throw new ArgumentNullException("provider");
  9295. if (sources == null)
  9296. throw new ArgumentNullException("sources");
  9297. if (scheduler == null)
  9298. throw new ArgumentNullException("scheduler");
  9299. return provider.CreateQuery<TSource>(
  9300. Expression.Call(
  9301. null,
  9302. #if CRIPPLED_REFLECTION
  9303. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(IScheduler))),
  9304. #else
  9305. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9306. #endif
  9307. Expression.Constant(provider, typeof(IQbservableProvider)),
  9308. GetSourceExpression(sources),
  9309. Expression.Constant(scheduler, typeof(IScheduler))
  9310. )
  9311. );
  9312. }
  9313. /// <summary>
  9314. /// Returns the minimum value in an observable sequence of <see cref="T:System.Decimal" /> values.
  9315. /// </summary>
  9316. /// <param name="source">A sequence of <see cref="T:System.Decimal" /> values to determine the minimum value of.</param>
  9317. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9318. /// <exception cref="T:System.ArgumentNullException">
  9319. /// <paramref name="source" /> is null.</exception>
  9320. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9321. public static IQbservable<decimal> Min(this IQbservable<decimal> source)
  9322. {
  9323. if (source == null)
  9324. throw new ArgumentNullException("source");
  9325. return source.Provider.CreateQuery<decimal>(
  9326. Expression.Call(
  9327. null,
  9328. #if CRIPPLED_REFLECTION
  9329. InfoOf(() => Qbservable.Min(default(IQbservable<decimal>))),
  9330. #else
  9331. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9332. #endif
  9333. source.Expression
  9334. )
  9335. );
  9336. }
  9337. /// <summary>
  9338. /// Returns the minimum value in an observable sequence of <see cref="T:System.Double" /> values.
  9339. /// </summary>
  9340. /// <param name="source">A sequence of <see cref="T:System.Double" /> values to determine the minimum value of.</param>
  9341. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9342. /// <exception cref="T:System.ArgumentNullException">
  9343. /// <paramref name="source" /> is null.</exception>
  9344. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9345. public static IQbservable<double> Min(this IQbservable<double> source)
  9346. {
  9347. if (source == null)
  9348. throw new ArgumentNullException("source");
  9349. return source.Provider.CreateQuery<double>(
  9350. Expression.Call(
  9351. null,
  9352. #if CRIPPLED_REFLECTION
  9353. InfoOf(() => Qbservable.Min(default(IQbservable<double>))),
  9354. #else
  9355. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9356. #endif
  9357. source.Expression
  9358. )
  9359. );
  9360. }
  9361. /// <summary>
  9362. /// Returns the minimum value in an observable sequence of <see cref="T:System.Int32" /> values.
  9363. /// </summary>
  9364. /// <param name="source">A sequence of <see cref="T:System.Int32" /> values to determine the minimum value of.</param>
  9365. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9366. /// <exception cref="T:System.ArgumentNullException">
  9367. /// <paramref name="source" /> is null.</exception>
  9368. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9369. public static IQbservable<int> Min(this IQbservable<int> source)
  9370. {
  9371. if (source == null)
  9372. throw new ArgumentNullException("source");
  9373. return source.Provider.CreateQuery<int>(
  9374. Expression.Call(
  9375. null,
  9376. #if CRIPPLED_REFLECTION
  9377. InfoOf(() => Qbservable.Min(default(IQbservable<int>))),
  9378. #else
  9379. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9380. #endif
  9381. source.Expression
  9382. )
  9383. );
  9384. }
  9385. /// <summary>
  9386. /// Returns the minimum value in an observable sequence of <see cref="T:System.Int64" /> values.
  9387. /// </summary>
  9388. /// <param name="source">A sequence of <see cref="T:System.Int64" /> values to determine the minimum value of.</param>
  9389. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9390. /// <exception cref="T:System.ArgumentNullException">
  9391. /// <paramref name="source" /> is null.</exception>
  9392. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9393. public static IQbservable<long> Min(this IQbservable<long> source)
  9394. {
  9395. if (source == null)
  9396. throw new ArgumentNullException("source");
  9397. return source.Provider.CreateQuery<long>(
  9398. Expression.Call(
  9399. null,
  9400. #if CRIPPLED_REFLECTION
  9401. InfoOf(() => Qbservable.Min(default(IQbservable<long>))),
  9402. #else
  9403. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9404. #endif
  9405. source.Expression
  9406. )
  9407. );
  9408. }
  9409. /// <summary>
  9410. /// Returns the minimum value in an observable sequence of nullable <see cref="T:System.Decimal" /> values.
  9411. /// </summary>
  9412. /// <param name="source">A sequence of nullable <see cref="T:System.Decimal" /> values to determine the minimum value of.</param>
  9413. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9414. /// <exception cref="T:System.ArgumentNullException">
  9415. /// <paramref name="source" /> is null.</exception>
  9416. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9417. public static IQbservable<decimal?> Min(this IQbservable<decimal?> source)
  9418. {
  9419. if (source == null)
  9420. throw new ArgumentNullException("source");
  9421. return source.Provider.CreateQuery<decimal?>(
  9422. Expression.Call(
  9423. null,
  9424. #if CRIPPLED_REFLECTION
  9425. InfoOf(() => Qbservable.Min(default(IQbservable<decimal?>))),
  9426. #else
  9427. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9428. #endif
  9429. source.Expression
  9430. )
  9431. );
  9432. }
  9433. /// <summary>
  9434. /// Returns the minimum value in an observable sequence of nullable <see cref="T:System.Double" /> values.
  9435. /// </summary>
  9436. /// <param name="source">A sequence of nullable <see cref="T:System.Double" /> values to determine the minimum value of.</param>
  9437. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9438. /// <exception cref="T:System.ArgumentNullException">
  9439. /// <paramref name="source" /> is null.</exception>
  9440. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9441. public static IQbservable<double?> Min(this IQbservable<double?> source)
  9442. {
  9443. if (source == null)
  9444. throw new ArgumentNullException("source");
  9445. return source.Provider.CreateQuery<double?>(
  9446. Expression.Call(
  9447. null,
  9448. #if CRIPPLED_REFLECTION
  9449. InfoOf(() => Qbservable.Min(default(IQbservable<double?>))),
  9450. #else
  9451. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9452. #endif
  9453. source.Expression
  9454. )
  9455. );
  9456. }
  9457. /// <summary>
  9458. /// Returns the minimum value in an observable sequence of nullable <see cref="T:System.Int32" /> values.
  9459. /// </summary>
  9460. /// <param name="source">A sequence of nullable <see cref="T:System.Int32" /> values to determine the minimum value of.</param>
  9461. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9462. /// <exception cref="T:System.ArgumentNullException">
  9463. /// <paramref name="source" /> is null.</exception>
  9464. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9465. public static IQbservable<int?> Min(this IQbservable<int?> source)
  9466. {
  9467. if (source == null)
  9468. throw new ArgumentNullException("source");
  9469. return source.Provider.CreateQuery<int?>(
  9470. Expression.Call(
  9471. null,
  9472. #if CRIPPLED_REFLECTION
  9473. InfoOf(() => Qbservable.Min(default(IQbservable<int?>))),
  9474. #else
  9475. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9476. #endif
  9477. source.Expression
  9478. )
  9479. );
  9480. }
  9481. /// <summary>
  9482. /// Returns the minimum value in an observable sequence of nullable <see cref="T:System.Int64" /> values.
  9483. /// </summary>
  9484. /// <param name="source">A sequence of nullable <see cref="T:System.Int64" /> values to determine the minimum value of.</param>
  9485. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9486. /// <exception cref="T:System.ArgumentNullException">
  9487. /// <paramref name="source" /> is null.</exception>
  9488. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9489. public static IQbservable<long?> Min(this IQbservable<long?> source)
  9490. {
  9491. if (source == null)
  9492. throw new ArgumentNullException("source");
  9493. return source.Provider.CreateQuery<long?>(
  9494. Expression.Call(
  9495. null,
  9496. #if CRIPPLED_REFLECTION
  9497. InfoOf(() => Qbservable.Min(default(IQbservable<long?>))),
  9498. #else
  9499. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9500. #endif
  9501. source.Expression
  9502. )
  9503. );
  9504. }
  9505. /// <summary>
  9506. /// Returns the minimum value in an observable sequence of nullable <see cref="T:System.Single" /> values.
  9507. /// </summary>
  9508. /// <param name="source">A sequence of nullable <see cref="T:System.Single" /> values to determine the minimum value of.</param>
  9509. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9510. /// <exception cref="T:System.ArgumentNullException">
  9511. /// <paramref name="source" /> is null.</exception>
  9512. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9513. public static IQbservable<float?> Min(this IQbservable<float?> source)
  9514. {
  9515. if (source == null)
  9516. throw new ArgumentNullException("source");
  9517. return source.Provider.CreateQuery<float?>(
  9518. Expression.Call(
  9519. null,
  9520. #if CRIPPLED_REFLECTION
  9521. InfoOf(() => Qbservable.Min(default(IQbservable<float?>))),
  9522. #else
  9523. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9524. #endif
  9525. source.Expression
  9526. )
  9527. );
  9528. }
  9529. /// <summary>
  9530. /// Returns the minimum value in an observable sequence of <see cref="T:System.Single" /> values.
  9531. /// </summary>
  9532. /// <param name="source">A sequence of <see cref="T:System.Single" /> values to determine the minimum value of.</param>
  9533. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9534. /// <exception cref="T:System.ArgumentNullException">
  9535. /// <paramref name="source" /> 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<float> Min(this IQbservable<float> source)
  9538. {
  9539. if (source == null)
  9540. throw new ArgumentNullException("source");
  9541. return source.Provider.CreateQuery<float>(
  9542. Expression.Call(
  9543. null,
  9544. #if CRIPPLED_REFLECTION
  9545. InfoOf(() => Qbservable.Min(default(IQbservable<float>))),
  9546. #else
  9547. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9548. #endif
  9549. source.Expression
  9550. )
  9551. );
  9552. }
  9553. /// <summary>
  9554. /// Returns the minimum element in an observable sequence.
  9555. /// </summary>
  9556. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9557. /// <param name="source">An observable sequence to determine the mimimum element of.</param>
  9558. /// <returns>An observable sequence containing a single element with the minimum element in the source sequence.</returns>
  9559. /// <exception cref="T:System.ArgumentNullException">
  9560. /// <paramref name="source" /> is null.</exception>
  9561. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9562. public static IQbservable<TSource> Min<TSource>(this IQbservable<TSource> source)
  9563. {
  9564. if (source == null)
  9565. throw new ArgumentNullException("source");
  9566. return source.Provider.CreateQuery<TSource>(
  9567. Expression.Call(
  9568. null,
  9569. #if CRIPPLED_REFLECTION
  9570. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>))),
  9571. #else
  9572. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9573. #endif
  9574. source.Expression
  9575. )
  9576. );
  9577. }
  9578. /// <summary>
  9579. /// Returns the minimum element in an observable sequence according to the specified comparer.
  9580. /// </summary>
  9581. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9582. /// <param name="source">An observable sequence to determine the mimimum element of.</param>
  9583. /// <param name="comparer">Comparer used to compare elements.</param>
  9584. /// <returns>An observable sequence containing a single element with the minimum element in the source sequence.</returns>
  9585. /// <exception cref="T:System.ArgumentNullException">
  9586. /// <paramref name="source" /> or <paramref name="comparer" /> is null.</exception>
  9587. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9588. public static IQbservable<TSource> Min<TSource>(this IQbservable<TSource> source, IComparer<TSource> comparer)
  9589. {
  9590. if (source == null)
  9591. throw new ArgumentNullException("source");
  9592. if (comparer == null)
  9593. throw new ArgumentNullException("comparer");
  9594. return source.Provider.CreateQuery<TSource>(
  9595. Expression.Call(
  9596. null,
  9597. #if CRIPPLED_REFLECTION
  9598. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(IComparer<TSource>))),
  9599. #else
  9600. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9601. #endif
  9602. source.Expression,
  9603. Expression.Constant(comparer, typeof(IComparer<TSource>))
  9604. )
  9605. );
  9606. }
  9607. /// <summary>
  9608. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="T:System.Double" /> value.
  9609. /// </summary>
  9610. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9611. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9612. /// <param name="selector">A transform function to apply to each element.</param>
  9613. /// <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>
  9614. /// <exception cref="T:System.ArgumentNullException">
  9615. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9616. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9617. public static IQbservable<double> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double>> selector)
  9618. {
  9619. if (source == null)
  9620. throw new ArgumentNullException("source");
  9621. if (selector == null)
  9622. throw new ArgumentNullException("selector");
  9623. return source.Provider.CreateQuery<double>(
  9624. Expression.Call(
  9625. null,
  9626. #if CRIPPLED_REFLECTION
  9627. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double>>))),
  9628. #else
  9629. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9630. #endif
  9631. source.Expression,
  9632. selector
  9633. )
  9634. );
  9635. }
  9636. /// <summary>
  9637. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="T:System.Single" /> value.
  9638. /// </summary>
  9639. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9640. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9641. /// <param name="selector">A transform function to apply to each element.</param>
  9642. /// <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>
  9643. /// <exception cref="T:System.ArgumentNullException">
  9644. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9645. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9646. public static IQbservable<float> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float>> selector)
  9647. {
  9648. if (source == null)
  9649. throw new ArgumentNullException("source");
  9650. if (selector == null)
  9651. throw new ArgumentNullException("selector");
  9652. return source.Provider.CreateQuery<float>(
  9653. Expression.Call(
  9654. null,
  9655. #if CRIPPLED_REFLECTION
  9656. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float>>))),
  9657. #else
  9658. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9659. #endif
  9660. source.Expression,
  9661. selector
  9662. )
  9663. );
  9664. }
  9665. /// <summary>
  9666. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="T:System.Decimal" /> value.
  9667. /// </summary>
  9668. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9669. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9670. /// <param name="selector">A transform function to apply to each element.</param>
  9671. /// <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>
  9672. /// <exception cref="T:System.ArgumentNullException">
  9673. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9674. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9675. public static IQbservable<decimal> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal>> selector)
  9676. {
  9677. if (source == null)
  9678. throw new ArgumentNullException("source");
  9679. if (selector == null)
  9680. throw new ArgumentNullException("selector");
  9681. return source.Provider.CreateQuery<decimal>(
  9682. Expression.Call(
  9683. null,
  9684. #if CRIPPLED_REFLECTION
  9685. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal>>))),
  9686. #else
  9687. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9688. #endif
  9689. source.Expression,
  9690. selector
  9691. )
  9692. );
  9693. }
  9694. /// <summary>
  9695. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="T:System.Int32" /> value.
  9696. /// </summary>
  9697. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9698. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9699. /// <param name="selector">A transform function to apply to each element.</param>
  9700. /// <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>
  9701. /// <exception cref="T:System.ArgumentNullException">
  9702. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9703. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9704. public static IQbservable<int> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int>> selector)
  9705. {
  9706. if (source == null)
  9707. throw new ArgumentNullException("source");
  9708. if (selector == null)
  9709. throw new ArgumentNullException("selector");
  9710. return source.Provider.CreateQuery<int>(
  9711. Expression.Call(
  9712. null,
  9713. #if CRIPPLED_REFLECTION
  9714. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int>>))),
  9715. #else
  9716. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9717. #endif
  9718. source.Expression,
  9719. selector
  9720. )
  9721. );
  9722. }
  9723. /// <summary>
  9724. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="T:System.Int64" /> value.
  9725. /// </summary>
  9726. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9727. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9728. /// <param name="selector">A transform function to apply to each element.</param>
  9729. /// <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>
  9730. /// <exception cref="T:System.ArgumentNullException">
  9731. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9732. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9733. public static IQbservable<long> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long>> selector)
  9734. {
  9735. if (source == null)
  9736. throw new ArgumentNullException("source");
  9737. if (selector == null)
  9738. throw new ArgumentNullException("selector");
  9739. return source.Provider.CreateQuery<long>(
  9740. Expression.Call(
  9741. null,
  9742. #if CRIPPLED_REFLECTION
  9743. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long>>))),
  9744. #else
  9745. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9746. #endif
  9747. source.Expression,
  9748. selector
  9749. )
  9750. );
  9751. }
  9752. /// <summary>
  9753. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="T:System.Double" /> value.
  9754. /// </summary>
  9755. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9756. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9757. /// <param name="selector">A transform function to apply to each element.</param>
  9758. /// <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>
  9759. /// <exception cref="T:System.ArgumentNullException">
  9760. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9761. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9762. public static IQbservable<double?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double?>> selector)
  9763. {
  9764. if (source == null)
  9765. throw new ArgumentNullException("source");
  9766. if (selector == null)
  9767. throw new ArgumentNullException("selector");
  9768. return source.Provider.CreateQuery<double?>(
  9769. Expression.Call(
  9770. null,
  9771. #if CRIPPLED_REFLECTION
  9772. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double?>>))),
  9773. #else
  9774. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9775. #endif
  9776. source.Expression,
  9777. selector
  9778. )
  9779. );
  9780. }
  9781. /// <summary>
  9782. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="T:System.Single" /> value.
  9783. /// </summary>
  9784. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9785. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9786. /// <param name="selector">A transform function to apply to each element.</param>
  9787. /// <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>
  9788. /// <exception cref="T:System.ArgumentNullException">
  9789. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9790. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9791. public static IQbservable<float?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float?>> selector)
  9792. {
  9793. if (source == null)
  9794. throw new ArgumentNullException("source");
  9795. if (selector == null)
  9796. throw new ArgumentNullException("selector");
  9797. return source.Provider.CreateQuery<float?>(
  9798. Expression.Call(
  9799. null,
  9800. #if CRIPPLED_REFLECTION
  9801. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float?>>))),
  9802. #else
  9803. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9804. #endif
  9805. source.Expression,
  9806. selector
  9807. )
  9808. );
  9809. }
  9810. /// <summary>
  9811. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="T:System.Decimal" /> value.
  9812. /// </summary>
  9813. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9814. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9815. /// <param name="selector">A transform function to apply to each element.</param>
  9816. /// <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>
  9817. /// <exception cref="T:System.ArgumentNullException">
  9818. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9819. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9820. public static IQbservable<decimal?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal?>> selector)
  9821. {
  9822. if (source == null)
  9823. throw new ArgumentNullException("source");
  9824. if (selector == null)
  9825. throw new ArgumentNullException("selector");
  9826. return source.Provider.CreateQuery<decimal?>(
  9827. Expression.Call(
  9828. null,
  9829. #if CRIPPLED_REFLECTION
  9830. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal?>>))),
  9831. #else
  9832. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9833. #endif
  9834. source.Expression,
  9835. selector
  9836. )
  9837. );
  9838. }
  9839. /// <summary>
  9840. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="T:System.Int32" /> value.
  9841. /// </summary>
  9842. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9843. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9844. /// <param name="selector">A transform function to apply to each element.</param>
  9845. /// <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>
  9846. /// <exception cref="T:System.ArgumentNullException">
  9847. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9848. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9849. public static IQbservable<int?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int?>> selector)
  9850. {
  9851. if (source == null)
  9852. throw new ArgumentNullException("source");
  9853. if (selector == null)
  9854. throw new ArgumentNullException("selector");
  9855. return source.Provider.CreateQuery<int?>(
  9856. Expression.Call(
  9857. null,
  9858. #if CRIPPLED_REFLECTION
  9859. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int?>>))),
  9860. #else
  9861. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9862. #endif
  9863. source.Expression,
  9864. selector
  9865. )
  9866. );
  9867. }
  9868. /// <summary>
  9869. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="T:System.Int64" /> value.
  9870. /// </summary>
  9871. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9872. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9873. /// <param name="selector">A transform function to apply to each element.</param>
  9874. /// <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>
  9875. /// <exception cref="T:System.ArgumentNullException">
  9876. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9877. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9878. public static IQbservable<long?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long?>> selector)
  9879. {
  9880. if (source == null)
  9881. throw new ArgumentNullException("source");
  9882. if (selector == null)
  9883. throw new ArgumentNullException("selector");
  9884. return source.Provider.CreateQuery<long?>(
  9885. Expression.Call(
  9886. null,
  9887. #if CRIPPLED_REFLECTION
  9888. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long?>>))),
  9889. #else
  9890. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9891. #endif
  9892. source.Expression,
  9893. selector
  9894. )
  9895. );
  9896. }
  9897. /// <summary>
  9898. /// Invokes a transform function on each element of a sequence and returns the minimum value.
  9899. /// </summary>
  9900. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9901. /// <typeparam name="TResult">The type of the objects derived from the elements in the source sequence to determine the minimum of.</typeparam>
  9902. /// <param name="source">An observable sequence to determine the mimimum element of.</param>
  9903. /// <param name="selector">A transform function to apply to each element.</param>
  9904. /// <returns>An observable sequence containing a single element with the value that corresponds to the minimum element in the source sequence.</returns>
  9905. /// <exception cref="T:System.ArgumentNullException">
  9906. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9907. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9908. public static IQbservable<TResult> Min<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector)
  9909. {
  9910. if (source == null)
  9911. throw new ArgumentNullException("source");
  9912. if (selector == null)
  9913. throw new ArgumentNullException("selector");
  9914. return source.Provider.CreateQuery<TResult>(
  9915. Expression.Call(
  9916. null,
  9917. #if CRIPPLED_REFLECTION
  9918. InfoOf(() => Qbservable.Min<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>))),
  9919. #else
  9920. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  9921. #endif
  9922. source.Expression,
  9923. selector
  9924. )
  9925. );
  9926. }
  9927. /// <summary>
  9928. /// Invokes a transform function on each element of a sequence and returns the minimum value according to the specified comparer.
  9929. /// </summary>
  9930. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9931. /// <typeparam name="TResult">The type of the objects derived from the elements in the source sequence to determine the minimum of.</typeparam>
  9932. /// <param name="source">An observable sequence to determine the mimimum element of.</param>
  9933. /// <param name="selector">A transform function to apply to each element.</param>
  9934. /// <param name="comparer">Comparer used to compare elements.</param>
  9935. /// <returns>An observable sequence containing a single element with the value that corresponds to the minimum element in the source sequence.</returns>
  9936. /// <exception cref="T:System.ArgumentNullException">
  9937. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="comparer" /> is null.</exception>
  9938. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9939. public static IQbservable<TResult> Min<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector, IComparer<TResult> comparer)
  9940. {
  9941. if (source == null)
  9942. throw new ArgumentNullException("source");
  9943. if (selector == null)
  9944. throw new ArgumentNullException("selector");
  9945. if (comparer == null)
  9946. throw new ArgumentNullException("comparer");
  9947. return source.Provider.CreateQuery<TResult>(
  9948. Expression.Call(
  9949. null,
  9950. #if CRIPPLED_REFLECTION
  9951. InfoOf(() => Qbservable.Min<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>), default(IComparer<TResult>))),
  9952. #else
  9953. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  9954. #endif
  9955. source.Expression,
  9956. selector,
  9957. Expression.Constant(comparer, typeof(IComparer<TResult>))
  9958. )
  9959. );
  9960. }
  9961. /// <summary>
  9962. /// Returns the elements in an observable sequence with the minimum key value.
  9963. /// </summary>
  9964. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9965. /// <typeparam name="TKey">The type of the key computed for each element in the source sequence.</typeparam>
  9966. /// <param name="source">An observable sequence to get the minimum elements for.</param>
  9967. /// <param name="keySelector">Key selector function.</param>
  9968. /// <returns>An observable sequence containing a list of zero or more elements that have a minimum key value.</returns>
  9969. /// <exception cref="T:System.ArgumentNullException">
  9970. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  9971. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9972. public static IQbservable<IList<TSource>> MinBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  9973. {
  9974. if (source == null)
  9975. throw new ArgumentNullException("source");
  9976. if (keySelector == null)
  9977. throw new ArgumentNullException("keySelector");
  9978. return source.Provider.CreateQuery<IList<TSource>>(
  9979. Expression.Call(
  9980. null,
  9981. #if CRIPPLED_REFLECTION
  9982. InfoOf(() => Qbservable.MinBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  9983. #else
  9984. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  9985. #endif
  9986. source.Expression,
  9987. keySelector
  9988. )
  9989. );
  9990. }
  9991. /// <summary>
  9992. /// Returns the elements in an observable sequence with the minimum key value according to the specified comparer.
  9993. /// </summary>
  9994. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9995. /// <typeparam name="TKey">The type of the key computed for each element in the source sequence.</typeparam>
  9996. /// <param name="source">An observable sequence to get the minimum elements for.</param>
  9997. /// <param name="keySelector">Key selector function.</param>
  9998. /// <param name="comparer">Comparer used to compare key values.</param>
  9999. /// <returns>An observable sequence containing a list of zero or more elements that have a minimum key value.</returns>
  10000. /// <exception cref="T:System.ArgumentNullException">
  10001. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  10002. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  10003. public static IQbservable<IList<TSource>> MinBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer)
  10004. {
  10005. if (source == null)
  10006. throw new ArgumentNullException("source");
  10007. if (keySelector == null)
  10008. throw new ArgumentNullException("keySelector");
  10009. if (comparer == null)
  10010. throw new ArgumentNullException("comparer");
  10011. return source.Provider.CreateQuery<IList<TSource>>(
  10012. Expression.Call(
  10013. null,
  10014. #if CRIPPLED_REFLECTION
  10015. InfoOf(() => Qbservable.MinBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IComparer<TKey>))),
  10016. #else
  10017. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  10018. #endif
  10019. source.Expression,
  10020. keySelector,
  10021. Expression.Constant(comparer, typeof(IComparer<TKey>))
  10022. )
  10023. );
  10024. }
  10025. /// <summary>
  10026. /// 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.
  10027. /// Enumerators on the resulting sequence never block and can produce the same element repeatedly.
  10028. /// </summary>
  10029. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10030. /// <param name="source">Source observable sequence.</param>
  10031. /// <param name="initialValue">Initial value that will be yielded by the enumerable sequence if no element has been sampled yet.</param>
  10032. /// <returns>The enumerable sequence that returns the last sampled element upon each iteration.</returns>
  10033. /// <exception cref="T:System.ArgumentNullException">
  10034. /// <paramref name="source" /> is null.</exception>
  10035. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  10036. public static IQueryable<TSource> MostRecent<TSource>(this IQbservable<TSource> source, TSource initialValue)
  10037. {
  10038. if (source == null)
  10039. throw new ArgumentNullException("source");
  10040. return ((IQueryProvider)source.Provider).CreateQuery<TSource>(
  10041. Expression.Call(
  10042. null,
  10043. #if CRIPPLED_REFLECTION
  10044. InfoOf(() => Qbservable.MostRecent<TSource>(default(IQbservable<TSource>), default(TSource))),
  10045. #else
  10046. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10047. #endif
  10048. source.Expression,
  10049. Expression.Constant(initialValue, typeof(TSource))
  10050. )
  10051. );
  10052. }
  10053. /// <summary>
  10054. /// Multicasts the source sequence notifications through an instantiated subject into all uses of the sequence within a selector function. Each
  10055. /// subscription to the resulting sequence causes a separate multicast invocation, exposing the sequence resulting from the selector function's
  10056. /// invocation. For specializations with fixed subject types, see Publish, PublishLast, and Replay.
  10057. /// </summary>
  10058. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10059. /// <typeparam name="TIntermediate">The type of the elements produced by the intermediate subject.</typeparam>
  10060. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10061. /// <param name="source">Source sequence which will be multicasted in the specified selector function.</param>
  10062. /// <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>
  10063. /// <param name="selector">Selector function which can use the multicasted source sequence subject to the policies enforced by the created subject.</param>
  10064. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10065. /// <exception cref="T:System.ArgumentNullException">
  10066. /// <paramref name="source" /> or <paramref name="subjectSelector" /> or <paramref name="selector" /> is null.</exception>
  10067. 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)
  10068. {
  10069. if (source == null)
  10070. throw new ArgumentNullException("source");
  10071. if (subjectSelector == null)
  10072. throw new ArgumentNullException("subjectSelector");
  10073. if (selector == null)
  10074. throw new ArgumentNullException("selector");
  10075. return source.Provider.CreateQuery<TResult>(
  10076. Expression.Call(
  10077. null,
  10078. #if CRIPPLED_REFLECTION
  10079. InfoOf(() => Qbservable.Multicast<TSource, TIntermediate, TResult>(default(IQbservable<TSource>), default(Expression<Func<ISubject<TSource, TIntermediate>>>), default(Expression<Func<IObservable<TIntermediate>, IObservable<TResult>>>))),
  10080. #else
  10081. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TIntermediate), typeof(TResult)),
  10082. #endif
  10083. source.Expression,
  10084. subjectSelector,
  10085. selector
  10086. )
  10087. );
  10088. }
  10089. /// <summary>
  10090. /// Returns a non-terminating observable sequence, which can be used to denote an infinite duration (e.g. when using reactive joins).
  10091. /// </summary>
  10092. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10093. /// <typeparam name="TResult">The type used for the IObservable&lt;T&gt; type parameter of the resulting sequence.</typeparam>
  10094. /// <returns>An observable sequence whose observers will never get called.</returns>
  10095. public static IQbservable<TResult> Never<TResult>(this IQbservableProvider provider)
  10096. {
  10097. if (provider == null)
  10098. throw new ArgumentNullException("provider");
  10099. return provider.CreateQuery<TResult>(
  10100. Expression.Call(
  10101. null,
  10102. #if CRIPPLED_REFLECTION
  10103. InfoOf(() => Qbservable.Never<TResult>(default(IQbservableProvider))),
  10104. #else
  10105. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10106. #endif
  10107. Expression.Constant(provider, typeof(IQbservableProvider))
  10108. )
  10109. );
  10110. }
  10111. /// <summary>
  10112. /// Returns a non-terminating observable sequence, which can be used to denote an infinite duration (e.g. when using reactive joins).
  10113. /// </summary>
  10114. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10115. /// <typeparam name="TResult">The type used for the IObservable&lt;T&gt; type parameter of the resulting sequence.</typeparam>
  10116. /// <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>
  10117. /// <returns>An observable sequence whose observers will never get called.</returns>
  10118. public static IQbservable<TResult> Never<TResult>(this IQbservableProvider provider, TResult witness)
  10119. {
  10120. if (provider == null)
  10121. throw new ArgumentNullException("provider");
  10122. return provider.CreateQuery<TResult>(
  10123. Expression.Call(
  10124. null,
  10125. #if CRIPPLED_REFLECTION
  10126. InfoOf(() => Qbservable.Never<TResult>(default(IQbservableProvider), default(TResult))),
  10127. #else
  10128. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10129. #endif
  10130. Expression.Constant(provider, typeof(IQbservableProvider)),
  10131. Expression.Constant(witness, typeof(TResult))
  10132. )
  10133. );
  10134. }
  10135. /// <summary>
  10136. /// Returns an enumerable sequence whose enumeration blocks until the next element in the source observable sequence becomes available.
  10137. /// Enumerators on the resulting sequence will block until the next element becomes available.
  10138. /// </summary>
  10139. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10140. /// <param name="source">Source observable sequence.</param>
  10141. /// <returns>The enumerable sequence that blocks upon each iteration until the next element in the observable source sequence becomes available.</returns>
  10142. /// <exception cref="T:System.ArgumentNullException">
  10143. /// <paramref name="source" /> is null.</exception>
  10144. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  10145. public static IQueryable<TSource> Next<TSource>(this IQbservable<TSource> source)
  10146. {
  10147. if (source == null)
  10148. throw new ArgumentNullException("source");
  10149. return ((IQueryProvider)source.Provider).CreateQuery<TSource>(
  10150. Expression.Call(
  10151. null,
  10152. #if CRIPPLED_REFLECTION
  10153. InfoOf(() => Qbservable.Next<TSource>(default(IQbservable<TSource>))),
  10154. #else
  10155. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10156. #endif
  10157. source.Expression
  10158. )
  10159. );
  10160. }
  10161. /// <summary>
  10162. /// Wraps the source sequence in order to run its observer callbacks on the specified synchronization context.
  10163. /// </summary>
  10164. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10165. /// <param name="source">Source sequence.</param>
  10166. /// <param name="context">Synchronization context to notify observers on.</param>
  10167. /// <returns>The source sequence whose observations happen on the specified synchronization context.</returns>
  10168. /// <exception cref="T:System.ArgumentNullException">
  10169. /// <paramref name="source" /> or <paramref name="context" /> is null.</exception>
  10170. /// <remarks>
  10171. /// This only invokes observer callbacks on a synchronization context. In case the subscription and/or unsubscription actions have side-effects
  10172. /// 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)" />.
  10173. /// </remarks>
  10174. public static IQbservable<TSource> ObserveOn<TSource>(this IQbservable<TSource> source, SynchronizationContext context)
  10175. {
  10176. if (source == null)
  10177. throw new ArgumentNullException("source");
  10178. if (context == null)
  10179. throw new ArgumentNullException("context");
  10180. return source.Provider.CreateQuery<TSource>(
  10181. Expression.Call(
  10182. null,
  10183. #if CRIPPLED_REFLECTION
  10184. InfoOf(() => Qbservable.ObserveOn<TSource>(default(IQbservable<TSource>), default(SynchronizationContext))),
  10185. #else
  10186. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10187. #endif
  10188. source.Expression,
  10189. Expression.Constant(context, typeof(SynchronizationContext))
  10190. )
  10191. );
  10192. }
  10193. /// <summary>
  10194. /// Wraps the source sequence in order to run its observer callbacks on the specified scheduler.
  10195. /// </summary>
  10196. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10197. /// <param name="source">Source sequence.</param>
  10198. /// <param name="scheduler">Scheduler to notify observers on.</param>
  10199. /// <returns>The source sequence whose observations happen on the specified scheduler.</returns>
  10200. /// <exception cref="T:System.ArgumentNullException">
  10201. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  10202. /// <remarks>
  10203. /// This only invokes observer callbacks on a scheduler. In case the subscription and/or unsubscription actions have side-effects
  10204. /// 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)" />.
  10205. /// </remarks>
  10206. public static IQbservable<TSource> ObserveOn<TSource>(this IQbservable<TSource> source, IScheduler scheduler)
  10207. {
  10208. if (source == null)
  10209. throw new ArgumentNullException("source");
  10210. if (scheduler == null)
  10211. throw new ArgumentNullException("scheduler");
  10212. return source.Provider.CreateQuery<TSource>(
  10213. Expression.Call(
  10214. null,
  10215. #if CRIPPLED_REFLECTION
  10216. InfoOf(() => Qbservable.ObserveOn<TSource>(default(IQbservable<TSource>), default(IScheduler))),
  10217. #else
  10218. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10219. #endif
  10220. source.Expression,
  10221. Expression.Constant(scheduler, typeof(IScheduler))
  10222. )
  10223. );
  10224. }
  10225. /// <summary>
  10226. /// Filters the elements of an observable sequence based on the specified type.
  10227. /// </summary>
  10228. /// <typeparam name="TResult">The type to filter the elements in the source sequence on.</typeparam>
  10229. /// <param name="source">The observable sequence that contains the elements to be filtered.</param>
  10230. /// <returns>An observable sequence that contains elements from the input sequence of type TResult.</returns>
  10231. /// <exception cref="T:System.ArgumentNullException">
  10232. /// <paramref name="source" /> is null.</exception>
  10233. public static IQbservable<TResult> OfType<TResult>(this IQbservable<object> source)
  10234. {
  10235. if (source == null)
  10236. throw new ArgumentNullException("source");
  10237. return source.Provider.CreateQuery<TResult>(
  10238. Expression.Call(
  10239. null,
  10240. #if CRIPPLED_REFLECTION
  10241. InfoOf(() => Qbservable.OfType<TResult>(default(IQbservable<object>))),
  10242. #else
  10243. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10244. #endif
  10245. source.Expression
  10246. )
  10247. );
  10248. }
  10249. /// <summary>
  10250. /// Concatenates the second observable sequence to the first observable sequence upon successful or exceptional termination of the first.
  10251. /// </summary>
  10252. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  10253. /// <param name="first">First observable sequence whose exception (if any) is caught.</param>
  10254. /// <param name="second">Second observable sequence used to produce results after the first sequence terminates.</param>
  10255. /// <returns>An observable sequence that concatenates the first and second sequence, even if the first sequence terminates exceptionally.</returns>
  10256. /// <exception cref="T:System.ArgumentNullException">
  10257. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  10258. public static IQbservable<TSource> OnErrorResumeNext<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  10259. {
  10260. if (first == null)
  10261. throw new ArgumentNullException("first");
  10262. if (second == null)
  10263. throw new ArgumentNullException("second");
  10264. return first.Provider.CreateQuery<TSource>(
  10265. Expression.Call(
  10266. null,
  10267. #if CRIPPLED_REFLECTION
  10268. InfoOf(() => Qbservable.OnErrorResumeNext<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  10269. #else
  10270. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10271. #endif
  10272. first.Expression,
  10273. GetSourceExpression(second)
  10274. )
  10275. );
  10276. }
  10277. /// <summary>
  10278. /// Concatenates all of the specified observable sequences, even if the previous observable sequence terminated exceptionally.
  10279. /// </summary>
  10280. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10281. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  10282. /// <param name="sources">Observable sequences to concatenate.</param>
  10283. /// <returns>An observable sequence that concatenates the source sequences, even if a sequence terminates exceptionally.</returns>
  10284. /// <exception cref="T:System.ArgumentNullException">
  10285. /// <paramref name="sources" /> is null.</exception>
  10286. public static IQbservable<TSource> OnErrorResumeNext<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  10287. {
  10288. if (provider == null)
  10289. throw new ArgumentNullException("provider");
  10290. if (sources == null)
  10291. throw new ArgumentNullException("sources");
  10292. return provider.CreateQuery<TSource>(
  10293. Expression.Call(
  10294. null,
  10295. #if CRIPPLED_REFLECTION
  10296. InfoOf(() => Qbservable.OnErrorResumeNext<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  10297. #else
  10298. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10299. #endif
  10300. Expression.Constant(provider, typeof(IQbservableProvider)),
  10301. GetSourceExpression(sources)
  10302. )
  10303. );
  10304. }
  10305. /// <summary>
  10306. /// Concatenates all observable sequences in the given enumerable sequence, even if the previous observable sequence terminated exceptionally.
  10307. /// </summary>
  10308. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10309. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  10310. /// <param name="sources">Observable sequences to concatenate.</param>
  10311. /// <returns>An observable sequence that concatenates the source sequences, even if a sequence terminates exceptionally.</returns>
  10312. /// <exception cref="T:System.ArgumentNullException">
  10313. /// <paramref name="sources" /> is null.</exception>
  10314. public static IQbservable<TSource> OnErrorResumeNext<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  10315. {
  10316. if (provider == null)
  10317. throw new ArgumentNullException("provider");
  10318. if (sources == null)
  10319. throw new ArgumentNullException("sources");
  10320. return provider.CreateQuery<TSource>(
  10321. Expression.Call(
  10322. null,
  10323. #if CRIPPLED_REFLECTION
  10324. InfoOf(() => Qbservable.OnErrorResumeNext<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  10325. #else
  10326. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10327. #endif
  10328. Expression.Constant(provider, typeof(IQbservableProvider)),
  10329. GetSourceExpression(sources)
  10330. )
  10331. );
  10332. }
  10333. /// <summary>
  10334. /// 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.
  10335. /// This operator is a specialization of Multicast using a regular <see cref="T:System.Reactive.Subjects.Subject`1" />.
  10336. /// </summary>
  10337. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10338. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10339. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10340. /// <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>
  10341. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10342. /// <exception cref="T:System.ArgumentNullException">
  10343. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10344. /// <seealso cref="T:System.Reactive.Subjects.Subject`1" />
  10345. public static IQbservable<TResult> Publish<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector)
  10346. {
  10347. if (source == null)
  10348. throw new ArgumentNullException("source");
  10349. if (selector == null)
  10350. throw new ArgumentNullException("selector");
  10351. return source.Provider.CreateQuery<TResult>(
  10352. Expression.Call(
  10353. null,
  10354. #if CRIPPLED_REFLECTION
  10355. InfoOf(() => Qbservable.Publish<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>))),
  10356. #else
  10357. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10358. #endif
  10359. source.Expression,
  10360. selector
  10361. )
  10362. );
  10363. }
  10364. /// <summary>
  10365. /// 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.
  10366. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.BehaviorSubject`1" />.
  10367. /// </summary>
  10368. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10369. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10370. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10371. /// <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>
  10372. /// <param name="initialValue">Initial value received by observers upon subscription.</param>
  10373. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10374. /// <exception cref="T:System.ArgumentNullException">
  10375. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10376. /// <seealso cref="T:System.Reactive.Subjects.BehaviorSubject`1" />
  10377. public static IQbservable<TResult> Publish<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, TSource initialValue)
  10378. {
  10379. if (source == null)
  10380. throw new ArgumentNullException("source");
  10381. if (selector == null)
  10382. throw new ArgumentNullException("selector");
  10383. return source.Provider.CreateQuery<TResult>(
  10384. Expression.Call(
  10385. null,
  10386. #if CRIPPLED_REFLECTION
  10387. InfoOf(() => Qbservable.Publish<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(TSource))),
  10388. #else
  10389. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10390. #endif
  10391. source.Expression,
  10392. selector,
  10393. Expression.Constant(initialValue, typeof(TSource))
  10394. )
  10395. );
  10396. }
  10397. /// <summary>
  10398. /// 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.
  10399. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.AsyncSubject`1" />.
  10400. /// </summary>
  10401. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10402. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10403. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10404. /// <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>
  10405. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10406. /// <exception cref="T:System.ArgumentNullException">
  10407. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10408. /// <seealso cref="T:System.Reactive.Subjects.AsyncSubject`1" />
  10409. public static IQbservable<TResult> PublishLast<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector)
  10410. {
  10411. if (source == null)
  10412. throw new ArgumentNullException("source");
  10413. if (selector == null)
  10414. throw new ArgumentNullException("selector");
  10415. return source.Provider.CreateQuery<TResult>(
  10416. Expression.Call(
  10417. null,
  10418. #if CRIPPLED_REFLECTION
  10419. InfoOf(() => Qbservable.PublishLast<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>))),
  10420. #else
  10421. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10422. #endif
  10423. source.Expression,
  10424. selector
  10425. )
  10426. );
  10427. }
  10428. /// <summary>
  10429. /// Generates an observable sequence of integral numbers within a specified range.
  10430. /// </summary>
  10431. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10432. /// <param name="start">The value of the first integer in the sequence.</param>
  10433. /// <param name="count">The number of sequential integers to generate.</param>
  10434. /// <returns>An observable sequence that contains a range of sequential integral numbers.</returns>
  10435. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10436. /// <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>
  10437. public static IQbservable<int> Range(this IQbservableProvider provider, int start, int count)
  10438. {
  10439. if (provider == null)
  10440. throw new ArgumentNullException("provider");
  10441. return provider.CreateQuery<int>(
  10442. Expression.Call(
  10443. null,
  10444. #if CRIPPLED_REFLECTION
  10445. InfoOf(() => Qbservable.Range(default(IQbservableProvider), default(int), default(int))),
  10446. #else
  10447. (MethodInfo)MethodInfo.GetCurrentMethod(),
  10448. #endif
  10449. Expression.Constant(provider, typeof(IQbservableProvider)),
  10450. Expression.Constant(start, typeof(int)),
  10451. Expression.Constant(count, typeof(int))
  10452. )
  10453. );
  10454. }
  10455. /// <summary>
  10456. /// Generates an observable sequence of integral numbers within a specified range, using the specified scheduler to send out observer messages.
  10457. /// </summary>
  10458. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10459. /// <param name="start">The value of the first integer in the sequence.</param>
  10460. /// <param name="count">The number of sequential integers to generate.</param>
  10461. /// <param name="scheduler">Scheduler to run the generator loop on.</param>
  10462. /// <returns>An observable sequence that contains a range of sequential integral numbers.</returns>
  10463. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10464. /// <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>
  10465. /// <exception cref="T:System.ArgumentNullException">
  10466. /// <paramref name="scheduler" /> is null.</exception>
  10467. public static IQbservable<int> Range(this IQbservableProvider provider, int start, int count, IScheduler scheduler)
  10468. {
  10469. if (provider == null)
  10470. throw new ArgumentNullException("provider");
  10471. if (scheduler == null)
  10472. throw new ArgumentNullException("scheduler");
  10473. return provider.CreateQuery<int>(
  10474. Expression.Call(
  10475. null,
  10476. #if CRIPPLED_REFLECTION
  10477. InfoOf(() => Qbservable.Range(default(IQbservableProvider), default(int), default(int), default(IScheduler))),
  10478. #else
  10479. (MethodInfo)MethodInfo.GetCurrentMethod(),
  10480. #endif
  10481. Expression.Constant(provider, typeof(IQbservableProvider)),
  10482. Expression.Constant(start, typeof(int)),
  10483. Expression.Constant(count, typeof(int)),
  10484. Expression.Constant(scheduler, typeof(IScheduler))
  10485. )
  10486. );
  10487. }
  10488. /// <summary>
  10489. /// Returns an observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence.
  10490. /// </summary>
  10491. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10492. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10493. /// <param name="source">Connectable observable sequence.</param>
  10494. /// <returns>An observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence.</returns>
  10495. /// <exception cref="T:System.ArgumentNullException">
  10496. /// <paramref name="source" /> is null.</exception>
  10497. public static IQbservable<TSource> RefCount<TSource>(this IQbservableProvider provider, IConnectableObservable<TSource> source)
  10498. {
  10499. if (provider == null)
  10500. throw new ArgumentNullException("provider");
  10501. if (source == null)
  10502. throw new ArgumentNullException("source");
  10503. return provider.CreateQuery<TSource>(
  10504. Expression.Call(
  10505. null,
  10506. #if CRIPPLED_REFLECTION
  10507. InfoOf(() => Qbservable.RefCount<TSource>(default(IQbservableProvider), default(IConnectableObservable<TSource>))),
  10508. #else
  10509. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10510. #endif
  10511. Expression.Constant(provider, typeof(IQbservableProvider)),
  10512. Expression.Constant(source, typeof(IConnectableObservable<TSource>))
  10513. )
  10514. );
  10515. }
  10516. /// <summary>
  10517. /// Generates an observable sequence that repeats the given element infinitely.
  10518. /// </summary>
  10519. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10520. /// <typeparam name="TResult">The type of the element that will be repeated in the produced sequence.</typeparam>
  10521. /// <param name="value">Element to repeat.</param>
  10522. /// <returns>An observable sequence that repeats the given element infinitely.</returns>
  10523. public static IQbservable<TResult> Repeat<TResult>(this IQbservableProvider provider, TResult value)
  10524. {
  10525. if (provider == null)
  10526. throw new ArgumentNullException("provider");
  10527. return provider.CreateQuery<TResult>(
  10528. Expression.Call(
  10529. null,
  10530. #if CRIPPLED_REFLECTION
  10531. InfoOf(() => Qbservable.Repeat<TResult>(default(IQbservableProvider), default(TResult))),
  10532. #else
  10533. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10534. #endif
  10535. Expression.Constant(provider, typeof(IQbservableProvider)),
  10536. Expression.Constant(value, typeof(TResult))
  10537. )
  10538. );
  10539. }
  10540. /// <summary>
  10541. /// Generates an observable sequence that repeats the given element the specified number of times.
  10542. /// </summary>
  10543. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10544. /// <typeparam name="TResult">The type of the element that will be repeated in the produced sequence.</typeparam>
  10545. /// <param name="value">Element to repeat.</param>
  10546. /// <param name="repeatCount">Number of times to repeat the element.</param>
  10547. /// <returns>An observable sequence that repeats the given element the specified number of times.</returns>
  10548. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10549. /// <paramref name="repeatCount" /> is less than zero.</exception>
  10550. public static IQbservable<TResult> Repeat<TResult>(this IQbservableProvider provider, TResult value, int repeatCount)
  10551. {
  10552. if (provider == null)
  10553. throw new ArgumentNullException("provider");
  10554. return provider.CreateQuery<TResult>(
  10555. Expression.Call(
  10556. null,
  10557. #if CRIPPLED_REFLECTION
  10558. InfoOf(() => Qbservable.Repeat<TResult>(default(IQbservableProvider), default(TResult), default(int))),
  10559. #else
  10560. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10561. #endif
  10562. Expression.Constant(provider, typeof(IQbservableProvider)),
  10563. Expression.Constant(value, typeof(TResult)),
  10564. Expression.Constant(repeatCount, typeof(int))
  10565. )
  10566. );
  10567. }
  10568. /// <summary>
  10569. /// Generates an observable sequence that repeats the given element the specified number of times, using the specified scheduler to send out observer messages.
  10570. /// </summary>
  10571. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10572. /// <typeparam name="TResult">The type of the element that will be repeated in the produced sequence.</typeparam>
  10573. /// <param name="value">Element to repeat.</param>
  10574. /// <param name="repeatCount">Number of times to repeat the element.</param>
  10575. /// <param name="scheduler">Scheduler to run the producer loop on.</param>
  10576. /// <returns>An observable sequence that repeats the given element the specified number of times.</returns>
  10577. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10578. /// <paramref name="repeatCount" /> is less than zero.</exception>
  10579. /// <exception cref="T:System.ArgumentNullException">
  10580. /// <paramref name="scheduler" /> is null.</exception>
  10581. public static IQbservable<TResult> Repeat<TResult>(this IQbservableProvider provider, TResult value, int repeatCount, IScheduler scheduler)
  10582. {
  10583. if (provider == null)
  10584. throw new ArgumentNullException("provider");
  10585. if (scheduler == null)
  10586. throw new ArgumentNullException("scheduler");
  10587. return provider.CreateQuery<TResult>(
  10588. Expression.Call(
  10589. null,
  10590. #if CRIPPLED_REFLECTION
  10591. InfoOf(() => Qbservable.Repeat<TResult>(default(IQbservableProvider), default(TResult), default(int), default(IScheduler))),
  10592. #else
  10593. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10594. #endif
  10595. Expression.Constant(provider, typeof(IQbservableProvider)),
  10596. Expression.Constant(value, typeof(TResult)),
  10597. Expression.Constant(repeatCount, typeof(int)),
  10598. Expression.Constant(scheduler, typeof(IScheduler))
  10599. )
  10600. );
  10601. }
  10602. /// <summary>
  10603. /// Generates an observable sequence that repeats the given element infinitely, using the specified scheduler to send out observer messages.
  10604. /// </summary>
  10605. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10606. /// <typeparam name="TResult">The type of the element that will be repeated in the produced sequence.</typeparam>
  10607. /// <param name="value">Element to repeat.</param>
  10608. /// <param name="scheduler">Scheduler to run the producer loop on.</param>
  10609. /// <returns>An observable sequence that repeats the given element infinitely.</returns>
  10610. /// <exception cref="T:System.ArgumentNullException">
  10611. /// <paramref name="scheduler" /> is null.</exception>
  10612. public static IQbservable<TResult> Repeat<TResult>(this IQbservableProvider provider, TResult value, IScheduler scheduler)
  10613. {
  10614. if (provider == null)
  10615. throw new ArgumentNullException("provider");
  10616. if (scheduler == null)
  10617. throw new ArgumentNullException("scheduler");
  10618. return provider.CreateQuery<TResult>(
  10619. Expression.Call(
  10620. null,
  10621. #if CRIPPLED_REFLECTION
  10622. InfoOf(() => Qbservable.Repeat<TResult>(default(IQbservableProvider), default(TResult), default(IScheduler))),
  10623. #else
  10624. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10625. #endif
  10626. Expression.Constant(provider, typeof(IQbservableProvider)),
  10627. Expression.Constant(value, typeof(TResult)),
  10628. Expression.Constant(scheduler, typeof(IScheduler))
  10629. )
  10630. );
  10631. }
  10632. /// <summary>
  10633. /// Repeats the observable sequence indefinitely.
  10634. /// </summary>
  10635. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10636. /// <param name="source">Observable sequence to repeat.</param>
  10637. /// <returns>The observable sequence producing the elements of the given sequence repeatedly and sequentially.</returns>
  10638. /// <exception cref="T:System.ArgumentNullException">
  10639. /// <paramref name="source" /> is null.</exception>
  10640. public static IQbservable<TSource> Repeat<TSource>(this IQbservable<TSource> source)
  10641. {
  10642. if (source == null)
  10643. throw new ArgumentNullException("source");
  10644. return source.Provider.CreateQuery<TSource>(
  10645. Expression.Call(
  10646. null,
  10647. #if CRIPPLED_REFLECTION
  10648. InfoOf(() => Qbservable.Repeat<TSource>(default(IQbservable<TSource>))),
  10649. #else
  10650. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10651. #endif
  10652. source.Expression
  10653. )
  10654. );
  10655. }
  10656. /// <summary>
  10657. /// Repeats the observable sequence a specified number of times.
  10658. /// </summary>
  10659. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10660. /// <param name="source">Observable sequence to repeat.</param>
  10661. /// <param name="repeatCount">Number of times to repeat the sequence.</param>
  10662. /// <returns>The observable sequence producing the elements of the given sequence repeatedly.</returns>
  10663. /// <exception cref="T:System.ArgumentNullException">
  10664. /// <paramref name="source" /> is null.</exception>
  10665. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10666. /// <paramref name="repeatCount" /> is less than zero.</exception>
  10667. public static IQbservable<TSource> Repeat<TSource>(this IQbservable<TSource> source, int repeatCount)
  10668. {
  10669. if (source == null)
  10670. throw new ArgumentNullException("source");
  10671. return source.Provider.CreateQuery<TSource>(
  10672. Expression.Call(
  10673. null,
  10674. #if CRIPPLED_REFLECTION
  10675. InfoOf(() => Qbservable.Repeat<TSource>(default(IQbservable<TSource>), default(int))),
  10676. #else
  10677. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10678. #endif
  10679. source.Expression,
  10680. Expression.Constant(repeatCount, typeof(int))
  10681. )
  10682. );
  10683. }
  10684. /// <summary>
  10685. /// 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.
  10686. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10687. /// </summary>
  10688. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10689. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10690. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10691. /// <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>
  10692. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10693. /// <exception cref="T:System.ArgumentNullException">
  10694. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10695. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10696. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector)
  10697. {
  10698. if (source == null)
  10699. throw new ArgumentNullException("source");
  10700. if (selector == null)
  10701. throw new ArgumentNullException("selector");
  10702. return source.Provider.CreateQuery<TResult>(
  10703. Expression.Call(
  10704. null,
  10705. #if CRIPPLED_REFLECTION
  10706. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>))),
  10707. #else
  10708. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10709. #endif
  10710. source.Expression,
  10711. selector
  10712. )
  10713. );
  10714. }
  10715. /// <summary>
  10716. /// 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.
  10717. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10718. /// </summary>
  10719. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10720. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10721. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10722. /// <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>
  10723. /// <param name="bufferSize">Maximum element count of the replay buffer.</param>
  10724. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10725. /// <exception cref="T:System.ArgumentNullException">
  10726. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10727. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10728. /// <paramref name="bufferSize" /> is less than zero.</exception>
  10729. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10730. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, int bufferSize)
  10731. {
  10732. if (source == null)
  10733. throw new ArgumentNullException("source");
  10734. if (selector == null)
  10735. throw new ArgumentNullException("selector");
  10736. return source.Provider.CreateQuery<TResult>(
  10737. Expression.Call(
  10738. null,
  10739. #if CRIPPLED_REFLECTION
  10740. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(int))),
  10741. #else
  10742. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10743. #endif
  10744. source.Expression,
  10745. selector,
  10746. Expression.Constant(bufferSize, typeof(int))
  10747. )
  10748. );
  10749. }
  10750. /// <summary>
  10751. /// 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.
  10752. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10753. /// </summary>
  10754. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10755. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10756. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10757. /// <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>
  10758. /// <param name="bufferSize">Maximum element count of the replay buffer.</param>
  10759. /// <param name="scheduler">Scheduler where connected observers within the selector function will be invoked on.</param>
  10760. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10761. /// <exception cref="T:System.ArgumentNullException">
  10762. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="scheduler" /> is null.</exception>
  10763. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10764. /// <paramref name="bufferSize" /> is less than zero.</exception>
  10765. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10766. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, int bufferSize, IScheduler scheduler)
  10767. {
  10768. if (source == null)
  10769. throw new ArgumentNullException("source");
  10770. if (selector == null)
  10771. throw new ArgumentNullException("selector");
  10772. if (scheduler == null)
  10773. throw new ArgumentNullException("scheduler");
  10774. return source.Provider.CreateQuery<TResult>(
  10775. Expression.Call(
  10776. null,
  10777. #if CRIPPLED_REFLECTION
  10778. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(int), default(IScheduler))),
  10779. #else
  10780. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10781. #endif
  10782. source.Expression,
  10783. selector,
  10784. Expression.Constant(bufferSize, typeof(int)),
  10785. Expression.Constant(scheduler, typeof(IScheduler))
  10786. )
  10787. );
  10788. }
  10789. /// <summary>
  10790. /// 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.
  10791. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10792. /// </summary>
  10793. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10794. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10795. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10796. /// <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>
  10797. /// <param name="bufferSize">Maximum element count of the replay buffer.</param>
  10798. /// <param name="window">Maximum time length of the replay buffer.</param>
  10799. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10800. /// <exception cref="T:System.ArgumentNullException">
  10801. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10802. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10803. /// <paramref name="bufferSize" /> is less than zero.</exception>
  10804. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10805. /// <paramref name="window" /> is less than TimeSpan.Zero.</exception>
  10806. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10807. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, int bufferSize, TimeSpan window)
  10808. {
  10809. if (source == null)
  10810. throw new ArgumentNullException("source");
  10811. if (selector == null)
  10812. throw new ArgumentNullException("selector");
  10813. return source.Provider.CreateQuery<TResult>(
  10814. Expression.Call(
  10815. null,
  10816. #if CRIPPLED_REFLECTION
  10817. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(int), default(TimeSpan))),
  10818. #else
  10819. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10820. #endif
  10821. source.Expression,
  10822. selector,
  10823. Expression.Constant(bufferSize, typeof(int)),
  10824. Expression.Constant(window, typeof(TimeSpan))
  10825. )
  10826. );
  10827. }
  10828. /// <summary>
  10829. /// 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.
  10830. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10831. /// </summary>
  10832. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10833. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10834. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10835. /// <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>
  10836. /// <param name="bufferSize">Maximum element count of the replay buffer.</param>
  10837. /// <param name="window">Maximum time length of the replay buffer.</param>
  10838. /// <param name="scheduler">Scheduler where connected observers within the selector function will be invoked on.</param>
  10839. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10840. /// <exception cref="T:System.ArgumentNullException">
  10841. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="scheduler" /> is null.</exception>
  10842. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10843. /// <paramref name="bufferSize" /> is less than zero.</exception>
  10844. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10845. /// <paramref name="window" /> is less than TimeSpan.Zero.</exception>
  10846. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10847. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, int bufferSize, TimeSpan window, IScheduler scheduler)
  10848. {
  10849. if (source == null)
  10850. throw new ArgumentNullException("source");
  10851. if (selector == null)
  10852. throw new ArgumentNullException("selector");
  10853. if (scheduler == null)
  10854. throw new ArgumentNullException("scheduler");
  10855. return source.Provider.CreateQuery<TResult>(
  10856. Expression.Call(
  10857. null,
  10858. #if CRIPPLED_REFLECTION
  10859. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(int), default(TimeSpan), default(IScheduler))),
  10860. #else
  10861. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10862. #endif
  10863. source.Expression,
  10864. selector,
  10865. Expression.Constant(bufferSize, typeof(int)),
  10866. Expression.Constant(window, typeof(TimeSpan)),
  10867. Expression.Constant(scheduler, typeof(IScheduler))
  10868. )
  10869. );
  10870. }
  10871. /// <summary>
  10872. /// 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.
  10873. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10874. /// </summary>
  10875. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10876. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10877. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10878. /// <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>
  10879. /// <param name="scheduler">Scheduler where connected observers within the selector function will be invoked on.</param>
  10880. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10881. /// <exception cref="T:System.ArgumentNullException">
  10882. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="scheduler" /> is null.</exception>
  10883. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10884. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, IScheduler scheduler)
  10885. {
  10886. if (source == null)
  10887. throw new ArgumentNullException("source");
  10888. if (selector == null)
  10889. throw new ArgumentNullException("selector");
  10890. if (scheduler == null)
  10891. throw new ArgumentNullException("scheduler");
  10892. return source.Provider.CreateQuery<TResult>(
  10893. Expression.Call(
  10894. null,
  10895. #if CRIPPLED_REFLECTION
  10896. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(IScheduler))),
  10897. #else
  10898. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10899. #endif
  10900. source.Expression,
  10901. selector,
  10902. Expression.Constant(scheduler, typeof(IScheduler))
  10903. )
  10904. );
  10905. }
  10906. /// <summary>
  10907. /// 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.
  10908. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10909. /// </summary>
  10910. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10911. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10912. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10913. /// <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>
  10914. /// <param name="window">Maximum time length of the replay buffer.</param>
  10915. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10916. /// <exception cref="T:System.ArgumentNullException">
  10917. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10918. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10919. /// <paramref name="window" /> is less than TimeSpan.Zero.</exception>
  10920. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10921. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, TimeSpan window)
  10922. {
  10923. if (source == null)
  10924. throw new ArgumentNullException("source");
  10925. if (selector == null)
  10926. throw new ArgumentNullException("selector");
  10927. return source.Provider.CreateQuery<TResult>(
  10928. Expression.Call(
  10929. null,
  10930. #if CRIPPLED_REFLECTION
  10931. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(TimeSpan))),
  10932. #else
  10933. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10934. #endif
  10935. source.Expression,
  10936. selector,
  10937. Expression.Constant(window, typeof(TimeSpan))
  10938. )
  10939. );
  10940. }
  10941. /// <summary>
  10942. /// 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.
  10943. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10944. /// </summary>
  10945. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10946. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10947. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10948. /// <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>
  10949. /// <param name="window">Maximum time length of the replay buffer.</param>
  10950. /// <param name="scheduler">Scheduler where connected observers within the selector function will be invoked on.</param>
  10951. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10952. /// <exception cref="T:System.ArgumentNullException">
  10953. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="scheduler" /> is null.</exception>
  10954. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10955. /// <paramref name="window" /> is less than TimeSpan.Zero.</exception>
  10956. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10957. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, TimeSpan window, IScheduler scheduler)
  10958. {
  10959. if (source == null)
  10960. throw new ArgumentNullException("source");
  10961. if (selector == null)
  10962. throw new ArgumentNullException("selector");
  10963. if (scheduler == null)
  10964. throw new ArgumentNullException("scheduler");
  10965. return source.Provider.CreateQuery<TResult>(
  10966. Expression.Call(
  10967. null,
  10968. #if CRIPPLED_REFLECTION
  10969. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(TimeSpan), default(IScheduler))),
  10970. #else
  10971. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10972. #endif
  10973. source.Expression,
  10974. selector,
  10975. Expression.Constant(window, typeof(TimeSpan)),
  10976. Expression.Constant(scheduler, typeof(IScheduler))
  10977. )
  10978. );
  10979. }
  10980. /// <summary>
  10981. /// Repeats the source observable sequence until it successfully terminates.
  10982. /// </summary>
  10983. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10984. /// <param name="source">Observable sequence to repeat until it successfully terminates.</param>
  10985. /// <returns>An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.</returns>
  10986. /// <exception cref="T:System.ArgumentNullException">
  10987. /// <paramref name="source" /> is null.</exception>
  10988. public static IQbservable<TSource> Retry<TSource>(this IQbservable<TSource> source)
  10989. {
  10990. if (source == null)
  10991. throw new ArgumentNullException("source");
  10992. return source.Provider.CreateQuery<TSource>(
  10993. Expression.Call(
  10994. null,
  10995. #if CRIPPLED_REFLECTION
  10996. InfoOf(() => Qbservable.Retry<TSource>(default(IQbservable<TSource>))),
  10997. #else
  10998. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10999. #endif
  11000. source.Expression
  11001. )
  11002. );
  11003. }
  11004. /// <summary>
  11005. /// Repeats the source observable sequence the specified number of times or until it successfully terminates.
  11006. /// </summary>
  11007. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11008. /// <param name="source">Observable sequence to repeat until it successfully terminates.</param>
  11009. /// <param name="retryCount">Number of times to repeat the sequence.</param>
  11010. /// <returns>An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.</returns>
  11011. /// <exception cref="T:System.ArgumentNullException">
  11012. /// <paramref name="source" /> is null.</exception>
  11013. /// <exception cref="T:System.ArgumentOutOfRangeException">
  11014. /// <paramref name="retryCount" /> is less than zero.</exception>
  11015. public static IQbservable<TSource> Retry<TSource>(this IQbservable<TSource> source, int retryCount)
  11016. {
  11017. if (source == null)
  11018. throw new ArgumentNullException("source");
  11019. return source.Provider.CreateQuery<TSource>(
  11020. Expression.Call(
  11021. null,
  11022. #if CRIPPLED_REFLECTION
  11023. InfoOf(() => Qbservable.Retry<TSource>(default(IQbservable<TSource>), default(int))),
  11024. #else
  11025. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11026. #endif
  11027. source.Expression,
  11028. Expression.Constant(retryCount, typeof(int))
  11029. )
  11030. );
  11031. }
  11032. /// <summary>
  11033. /// Returns an observable sequence that contains a single element.
  11034. /// </summary>
  11035. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  11036. /// <typeparam name="TResult">The type of the element that will be returned in the produced sequence.</typeparam>
  11037. /// <param name="value">Single element in the resulting observable sequence.</param>
  11038. /// <returns>An observable sequence containing the single specified element.</returns>
  11039. public static IQbservable<TResult> Return<TResult>(this IQbservableProvider provider, TResult value)
  11040. {
  11041. if (provider == null)
  11042. throw new ArgumentNullException("provider");
  11043. return provider.CreateQuery<TResult>(
  11044. Expression.Call(
  11045. null,
  11046. #if CRIPPLED_REFLECTION
  11047. InfoOf(() => Qbservable.Return<TResult>(default(IQbservableProvider), default(TResult))),
  11048. #else
  11049. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  11050. #endif
  11051. Expression.Constant(provider, typeof(IQbservableProvider)),
  11052. Expression.Constant(value, typeof(TResult))
  11053. )
  11054. );
  11055. }
  11056. /// <summary>
  11057. /// Returns an observable sequence that contains a single element, using the specified scheduler to send out observer messages.
  11058. /// </summary>
  11059. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  11060. /// <typeparam name="TResult">The type of the element that will be returned in the produced sequence.</typeparam>
  11061. /// <param name="value">Single element in the resulting observable sequence.</param>
  11062. /// <param name="scheduler">Scheduler to send the single element on.</param>
  11063. /// <returns>An observable sequence containing the single specified element.</returns>
  11064. /// <exception cref="T:System.ArgumentNullException">
  11065. /// <paramref name="scheduler" /> is null.</exception>
  11066. public static IQbservable<TResult> Return<TResult>(this IQbservableProvider provider, TResult value, IScheduler scheduler)
  11067. {
  11068. if (provider == null)
  11069. throw new ArgumentNullException("provider");
  11070. if (scheduler == null)
  11071. throw new ArgumentNullException("scheduler");
  11072. return provider.CreateQuery<TResult>(
  11073. Expression.Call(
  11074. null,
  11075. #if CRIPPLED_REFLECTION
  11076. InfoOf(() => Qbservable.Return<TResult>(default(IQbservableProvider), default(TResult), default(IScheduler))),
  11077. #else
  11078. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  11079. #endif
  11080. Expression.Constant(provider, typeof(IQbservableProvider)),
  11081. Expression.Constant(value, typeof(TResult)),
  11082. Expression.Constant(scheduler, typeof(IScheduler))
  11083. )
  11084. );
  11085. }
  11086. /// <summary>
  11087. /// Samples the observable sequence at each interval.
  11088. /// Upon each sampling tick, the latest element (if any) in the source sequence during the last sampling interval is sent to the resulting sequence.
  11089. /// </summary>
  11090. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11091. /// <param name="source">Source sequence to sample.</param>
  11092. /// <param name="interval">Interval at which to sample. If this value is equal to TimeSpan.Zero, the scheduler will continuously sample the stream.</param>
  11093. /// <returns>Sampled observable sequence.</returns>
  11094. /// <exception cref="T:System.ArgumentNullException">
  11095. /// <paramref name="source" /> is null.</exception>
  11096. /// <exception cref="T:System.ArgumentOutOfRangeException">
  11097. /// <paramref name="interval" /> is less than TimeSpan.Zero.</exception>
  11098. /// <remarks>
  11099. /// Specifying a TimeSpan.Zero value for <paramref name="interval" /> doesn't guarantee all source sequence elements will be preserved. This is a side-effect
  11100. /// of the asynchrony introduced by the scheduler, where the sampling action may not execute immediately, despite the TimeSpan.Zero due time.
  11101. /// </remarks>
  11102. public static IQbservable<TSource> Sample<TSource>(this IQbservable<TSource> source, TimeSpan interval)
  11103. {
  11104. if (source == null)
  11105. throw new ArgumentNullException("source");
  11106. return source.Provider.CreateQuery<TSource>(
  11107. Expression.Call(
  11108. null,
  11109. #if CRIPPLED_REFLECTION
  11110. InfoOf(() => Qbservable.Sample<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  11111. #else
  11112. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11113. #endif
  11114. source.Expression,
  11115. Expression.Constant(interval, typeof(TimeSpan))
  11116. )
  11117. );
  11118. }
  11119. /// <summary>
  11120. /// Samples the observable sequence at each interval, using the specified scheduler to run sampling timers.
  11121. /// Upon each sampling tick, the latest element (if any) in the source sequence during the last sampling interval is sent to the resulting sequence.
  11122. /// </summary>
  11123. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11124. /// <param name="source">Source sequence to sample.</param>
  11125. /// <param name="interval">Interval at which to sample. If this value is equal to TimeSpan.Zero, the scheduler will continuously sample the stream.</param>
  11126. /// <param name="scheduler">Scheduler to run the sampling timer on.</param>
  11127. /// <returns>Sampled observable sequence.</returns>
  11128. /// <exception cref="T:System.ArgumentNullException">
  11129. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  11130. /// <exception cref="T:System.ArgumentOutOfRangeException">
  11131. /// <paramref name="interval" /> is less than TimeSpan.Zero.</exception>
  11132. /// <remarks>
  11133. /// Specifying a TimeSpan.Zero value for <paramref name="interval" /> doesn't guarantee all source sequence elements will be preserved. This is a side-effect
  11134. /// of the asynchrony introduced by the scheduler, where the sampling action may not execute immediately, despite the TimeSpan.Zero due time.
  11135. /// </remarks>
  11136. public static IQbservable<TSource> Sample<TSource>(this IQbservable<TSource> source, TimeSpan interval, IScheduler scheduler)
  11137. {
  11138. if (source == null)
  11139. throw new ArgumentNullException("source");
  11140. if (scheduler == null)
  11141. throw new ArgumentNullException("scheduler");
  11142. return source.Provider.CreateQuery<TSource>(
  11143. Expression.Call(
  11144. null,
  11145. #if CRIPPLED_REFLECTION
  11146. InfoOf(() => Qbservable.Sample<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  11147. #else
  11148. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11149. #endif
  11150. source.Expression,
  11151. Expression.Constant(interval, typeof(TimeSpan)),
  11152. Expression.Constant(scheduler, typeof(IScheduler))
  11153. )
  11154. );
  11155. }
  11156. /// <summary>
  11157. /// Samples the source observable sequence using a samper observable sequence producing sampling ticks.
  11158. /// Upon each sampling tick, the latest element (if any) in the source sequence during the last sampling interval is sent to the resulting sequence.
  11159. /// </summary>
  11160. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11161. /// <typeparam name="TSample">The type of the elements in the sampling sequence.</typeparam>
  11162. /// <param name="source">Source sequence to sample.</param>
  11163. /// <param name="sampler">Sampling tick sequence.</param>
  11164. /// <returns>Sampled observable sequence.</returns>
  11165. /// <exception cref="T:System.ArgumentNullException">
  11166. /// <paramref name="source" /> or <paramref name="sampler" /> is null.</exception>
  11167. public static IQbservable<TSource> Sample<TSource, TSample>(this IQbservable<TSource> source, IObservable<TSample> sampler)
  11168. {
  11169. if (source == null)
  11170. throw new ArgumentNullException("source");
  11171. if (sampler == null)
  11172. throw new ArgumentNullException("sampler");
  11173. return source.Provider.CreateQuery<TSource>(
  11174. Expression.Call(
  11175. null,
  11176. #if CRIPPLED_REFLECTION
  11177. InfoOf(() => Qbservable.Sample<TSource, TSample>(default(IQbservable<TSource>), default(IObservable<TSample>))),
  11178. #else
  11179. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TSample)),
  11180. #endif
  11181. source.Expression,
  11182. GetSourceExpression(sampler)
  11183. )
  11184. );
  11185. }
  11186. /// <summary>
  11187. /// Applies an accumulator function over an observable sequence and returns each intermediate result.
  11188. /// 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})" />.
  11189. /// </summary>
  11190. /// <typeparam name="TSource">The type of the elements in the source sequence and the result of the aggregation.</typeparam>
  11191. /// <param name="source">An observable sequence to accumulate over.</param>
  11192. /// <param name="accumulator">An accumulator function to be invoked on each element.</param>
  11193. /// <returns>An observable sequence containing the accumulated values.</returns>
  11194. /// <exception cref="T:System.ArgumentNullException">
  11195. /// <paramref name="source" /> or <paramref name="accumulator" /> is null.</exception>
  11196. public static IQbservable<TSource> Scan<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, TSource, TSource>> accumulator)
  11197. {
  11198. if (source == null)
  11199. throw new ArgumentNullException("source");
  11200. if (accumulator == null)
  11201. throw new ArgumentNullException("accumulator");
  11202. return source.Provider.CreateQuery<TSource>(
  11203. Expression.Call(
  11204. null,
  11205. #if CRIPPLED_REFLECTION
  11206. InfoOf(() => Qbservable.Scan<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, TSource, TSource>>))),
  11207. #else
  11208. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11209. #endif
  11210. source.Expression,
  11211. accumulator
  11212. )
  11213. );
  11214. }
  11215. /// <summary>
  11216. /// Applies an accumulator function over an observable sequence and returns each intermediate result. The specified seed value is used as the initial accumulator value.
  11217. /// 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})" />.
  11218. /// </summary>
  11219. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11220. /// <typeparam name="TAccumulate">The type of the result of the aggregation.</typeparam>
  11221. /// <param name="source">An observable sequence to accumulate over.</param>
  11222. /// <param name="seed">The initial accumulator value.</param>
  11223. /// <param name="accumulator">An accumulator function to be invoked on each element.</param>
  11224. /// <returns>An observable sequence containing the accumulated values.</returns>
  11225. /// <exception cref="T:System.ArgumentNullException">
  11226. /// <paramref name="source" /> or <paramref name="accumulator" /> is null.</exception>
  11227. public static IQbservable<TAccumulate> Scan<TSource, TAccumulate>(this IQbservable<TSource> source, TAccumulate seed, Expression<Func<TAccumulate, TSource, TAccumulate>> accumulator)
  11228. {
  11229. if (source == null)
  11230. throw new ArgumentNullException("source");
  11231. if (accumulator == null)
  11232. throw new ArgumentNullException("accumulator");
  11233. return source.Provider.CreateQuery<TAccumulate>(
  11234. Expression.Call(
  11235. null,
  11236. #if CRIPPLED_REFLECTION
  11237. InfoOf(() => Qbservable.Scan<TSource, TAccumulate>(default(IQbservable<TSource>), default(TAccumulate), default(Expression<Func<TAccumulate, TSource, TAccumulate>>))),
  11238. #else
  11239. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)),
  11240. #endif
  11241. source.Expression,
  11242. Expression.Constant(seed, typeof(TAccumulate)),
  11243. accumulator
  11244. )
  11245. );
  11246. }
  11247. /// <summary>
  11248. /// Projects each element of an observable sequence into a new form.
  11249. /// </summary>
  11250. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11251. /// <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>
  11252. /// <param name="source">A sequence of elements to invoke a transform function on.</param>
  11253. /// <param name="selector">A transform function to apply to each source element.</param>
  11254. /// <returns>An observable sequence whose elements are the result of invoking the transform function on each element of source.</returns>
  11255. /// <exception cref="T:System.ArgumentNullException">
  11256. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11257. public static IQbservable<TResult> Select<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector)
  11258. {
  11259. if (source == null)
  11260. throw new ArgumentNullException("source");
  11261. if (selector == null)
  11262. throw new ArgumentNullException("selector");
  11263. return source.Provider.CreateQuery<TResult>(
  11264. Expression.Call(
  11265. null,
  11266. #if CRIPPLED_REFLECTION
  11267. InfoOf(() => Qbservable.Select<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>))),
  11268. #else
  11269. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11270. #endif
  11271. source.Expression,
  11272. selector
  11273. )
  11274. );
  11275. }
  11276. /// <summary>
  11277. /// Projects each element of an observable sequence into a new form by incorporating the element's index.
  11278. /// </summary>
  11279. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11280. /// <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>
  11281. /// <param name="source">A sequence of elements to invoke a transform function on.</param>
  11282. /// <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>
  11283. /// <returns>An observable sequence whose elements are the result of invoking the transform function on each element of source.</returns>
  11284. /// <exception cref="T:System.ArgumentNullException">
  11285. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11286. public static IQbservable<TResult> Select<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, TResult>> selector)
  11287. {
  11288. if (source == null)
  11289. throw new ArgumentNullException("source");
  11290. if (selector == null)
  11291. throw new ArgumentNullException("selector");
  11292. return source.Provider.CreateQuery<TResult>(
  11293. Expression.Call(
  11294. null,
  11295. #if CRIPPLED_REFLECTION
  11296. InfoOf(() => Qbservable.Select<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, TResult>>))),
  11297. #else
  11298. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11299. #endif
  11300. source.Expression,
  11301. selector
  11302. )
  11303. );
  11304. }
  11305. /// <summary>
  11306. /// 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.
  11307. /// </summary>
  11308. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11309. /// <typeparam name="TCollection">The type of the elements in the projected intermediate enumerable sequences.</typeparam>
  11310. /// <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>
  11311. /// <param name="source">An observable sequence of elements to project.</param>
  11312. /// <param name="collectionSelector">A transform function to apply to each element.</param>
  11313. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
  11314. /// <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>
  11315. /// <exception cref="T:System.ArgumentNullException">
  11316. /// <paramref name="source" /> or <paramref name="collectionSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11317. /// <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>
  11318. public static IQbservable<TResult> SelectMany<TSource, TCollection, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, IEnumerable<TCollection>>> collectionSelector, Expression<Func<TSource, TCollection, TResult>> resultSelector)
  11319. {
  11320. if (source == null)
  11321. throw new ArgumentNullException("source");
  11322. if (collectionSelector == null)
  11323. throw new ArgumentNullException("collectionSelector");
  11324. if (resultSelector == null)
  11325. throw new ArgumentNullException("resultSelector");
  11326. return source.Provider.CreateQuery<TResult>(
  11327. Expression.Call(
  11328. null,
  11329. #if CRIPPLED_REFLECTION
  11330. InfoOf(() => Qbservable.SelectMany<TSource, TCollection, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, IEnumerable<TCollection>>>), default(Expression<Func<TSource, TCollection, TResult>>))),
  11331. #else
  11332. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)),
  11333. #endif
  11334. source.Expression,
  11335. collectionSelector,
  11336. resultSelector
  11337. )
  11338. );
  11339. }
  11340. /// <summary>
  11341. /// 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.
  11342. /// </summary>
  11343. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11344. /// <typeparam name="TCollection">The type of the elements in the projected intermediate enumerable sequences.</typeparam>
  11345. /// <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>
  11346. /// <param name="source">An observable sequence of elements to project.</param>
  11347. /// <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>
  11348. /// <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>
  11349. /// <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>
  11350. /// <exception cref="T:System.ArgumentNullException">
  11351. /// <paramref name="source" /> or <paramref name="collectionSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11352. /// <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>
  11353. 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)
  11354. {
  11355. if (source == null)
  11356. throw new ArgumentNullException("source");
  11357. if (collectionSelector == null)
  11358. throw new ArgumentNullException("collectionSelector");
  11359. if (resultSelector == null)
  11360. throw new ArgumentNullException("resultSelector");
  11361. return source.Provider.CreateQuery<TResult>(
  11362. Expression.Call(
  11363. null,
  11364. #if CRIPPLED_REFLECTION
  11365. InfoOf(() => Qbservable.SelectMany<TSource, TCollection, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, IEnumerable<TCollection>>>), default(Expression<Func<TSource, int, TCollection, int, TResult>>))),
  11366. #else
  11367. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)),
  11368. #endif
  11369. source.Expression,
  11370. collectionSelector,
  11371. resultSelector
  11372. )
  11373. );
  11374. }
  11375. /// <summary>
  11376. /// 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.
  11377. /// </summary>
  11378. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11379. /// <typeparam name="TCollection">The type of the elements in the projected intermediate sequences.</typeparam>
  11380. /// <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>
  11381. /// <param name="source">An observable sequence of elements to project.</param>
  11382. /// <param name="collectionSelector">A transform function to apply to each element.</param>
  11383. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
  11384. /// <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>
  11385. /// <exception cref="T:System.ArgumentNullException">
  11386. /// <paramref name="source" /> or <paramref name="collectionSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11387. public static IQbservable<TResult> SelectMany<TSource, TCollection, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TCollection>>> collectionSelector, Expression<Func<TSource, TCollection, TResult>> resultSelector)
  11388. {
  11389. if (source == null)
  11390. throw new ArgumentNullException("source");
  11391. if (collectionSelector == null)
  11392. throw new ArgumentNullException("collectionSelector");
  11393. if (resultSelector == null)
  11394. throw new ArgumentNullException("resultSelector");
  11395. return source.Provider.CreateQuery<TResult>(
  11396. Expression.Call(
  11397. null,
  11398. #if CRIPPLED_REFLECTION
  11399. InfoOf(() => Qbservable.SelectMany<TSource, TCollection, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TCollection>>>), default(Expression<Func<TSource, TCollection, TResult>>))),
  11400. #else
  11401. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)),
  11402. #endif
  11403. source.Expression,
  11404. collectionSelector,
  11405. resultSelector
  11406. )
  11407. );
  11408. }
  11409. /// <summary>
  11410. /// 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.
  11411. /// </summary>
  11412. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11413. /// <typeparam name="TCollection">The type of the elements in the projected intermediate sequences.</typeparam>
  11414. /// <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>
  11415. /// <param name="source">An observable sequence of elements to project.</param>
  11416. /// <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>
  11417. /// <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>
  11418. /// <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>
  11419. /// <exception cref="T:System.ArgumentNullException">
  11420. /// <paramref name="source" /> or <paramref name="collectionSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11421. 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)
  11422. {
  11423. if (source == null)
  11424. throw new ArgumentNullException("source");
  11425. if (collectionSelector == null)
  11426. throw new ArgumentNullException("collectionSelector");
  11427. if (resultSelector == null)
  11428. throw new ArgumentNullException("resultSelector");
  11429. return source.Provider.CreateQuery<TResult>(
  11430. Expression.Call(
  11431. null,
  11432. #if CRIPPLED_REFLECTION
  11433. InfoOf(() => Qbservable.SelectMany<TSource, TCollection, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, IObservable<TCollection>>>), default(Expression<Func<TSource, int, TCollection, int, TResult>>))),
  11434. #else
  11435. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)),
  11436. #endif
  11437. source.Expression,
  11438. collectionSelector,
  11439. resultSelector
  11440. )
  11441. );
  11442. }
  11443. /// <summary>
  11444. /// Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
  11445. /// </summary>
  11446. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11447. /// <typeparam name="TOther">The type of the elements in the other sequence and the elements in the result sequence.</typeparam>
  11448. /// <param name="source">An observable sequence of elements to project.</param>
  11449. /// <param name="other">An observable sequence to project each element from the source sequence onto.</param>
  11450. /// <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>
  11451. /// <exception cref="T:System.ArgumentNullException">
  11452. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  11453. public static IQbservable<TOther> SelectMany<TSource, TOther>(this IQbservable<TSource> source, IObservable<TOther> other)
  11454. {
  11455. if (source == null)
  11456. throw new ArgumentNullException("source");
  11457. if (other == null)
  11458. throw new ArgumentNullException("other");
  11459. return source.Provider.CreateQuery<TOther>(
  11460. Expression.Call(
  11461. null,
  11462. #if CRIPPLED_REFLECTION
  11463. InfoOf(() => Qbservable.SelectMany<TSource, TOther>(default(IQbservable<TSource>), default(IObservable<TOther>))),
  11464. #else
  11465. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)),
  11466. #endif
  11467. source.Expression,
  11468. GetSourceExpression(other)
  11469. )
  11470. );
  11471. }
  11472. /// <summary>
  11473. /// Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  11474. /// </summary>
  11475. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11476. /// <typeparam name="TResult">The type of the elements in the projected inner sequences and the elements in the merged result sequence.</typeparam>
  11477. /// <param name="source">An observable sequence of notifications to project.</param>
  11478. /// <param name="onNext">A transform function to apply to each element.</param>
  11479. /// <param name="onError">A transform function to apply when an error occurs in the source sequence.</param>
  11480. /// <param name="onCompleted">A transform function to apply when the end of the source sequence is reached.</param>
  11481. /// <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>
  11482. /// <exception cref="T:System.ArgumentNullException">
  11483. /// <paramref name="source" /> or <paramref name="onNext" /> or <paramref name="onError" /> or <paramref name="onCompleted" /> is null.</exception>
  11484. 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)
  11485. {
  11486. if (source == null)
  11487. throw new ArgumentNullException("source");
  11488. if (onNext == null)
  11489. throw new ArgumentNullException("onNext");
  11490. if (onError == null)
  11491. throw new ArgumentNullException("onError");
  11492. if (onCompleted == null)
  11493. throw new ArgumentNullException("onCompleted");
  11494. return source.Provider.CreateQuery<TResult>(
  11495. Expression.Call(
  11496. null,
  11497. #if CRIPPLED_REFLECTION
  11498. 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>>>))),
  11499. #else
  11500. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11501. #endif
  11502. source.Expression,
  11503. onNext,
  11504. onError,
  11505. onCompleted
  11506. )
  11507. );
  11508. }
  11509. /// <summary>
  11510. /// 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.
  11511. /// </summary>
  11512. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11513. /// <typeparam name="TResult">The type of the elements in the projected inner sequences and the elements in the merged result sequence.</typeparam>
  11514. /// <param name="source">An observable sequence of notifications to project.</param>
  11515. /// <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>
  11516. /// <param name="onError">A transform function to apply when an error occurs in the source sequence.</param>
  11517. /// <param name="onCompleted">A transform function to apply when the end of the source sequence is reached.</param>
  11518. /// <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>
  11519. /// <exception cref="T:System.ArgumentNullException">
  11520. /// <paramref name="source" /> or <paramref name="onNext" /> or <paramref name="onError" /> or <paramref name="onCompleted" /> is null.</exception>
  11521. 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)
  11522. {
  11523. if (source == null)
  11524. throw new ArgumentNullException("source");
  11525. if (onNext == null)
  11526. throw new ArgumentNullException("onNext");
  11527. if (onError == null)
  11528. throw new ArgumentNullException("onError");
  11529. if (onCompleted == null)
  11530. throw new ArgumentNullException("onCompleted");
  11531. return source.Provider.CreateQuery<TResult>(
  11532. Expression.Call(
  11533. null,
  11534. #if CRIPPLED_REFLECTION
  11535. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, IObservable<TResult>>>), default(Expression<Func<Exception, IObservable<TResult>>>), default(Expression<Func<IObservable<TResult>>>))),
  11536. #else
  11537. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11538. #endif
  11539. source.Expression,
  11540. onNext,
  11541. onError,
  11542. onCompleted
  11543. )
  11544. );
  11545. }
  11546. /// <summary>
  11547. /// Projects each element of an observable sequence to an enumerable sequence and concatenates the resulting enumerable sequences into one observable sequence.
  11548. /// </summary>
  11549. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11550. /// <typeparam name="TResult">The type of the elements in the projected inner enumerable sequences and the elements in the merged result sequence.</typeparam>
  11551. /// <param name="source">An observable sequence of elements to project.</param>
  11552. /// <param name="selector">A transform function to apply to each element.</param>
  11553. /// <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>
  11554. /// <exception cref="T:System.ArgumentNullException">
  11555. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11556. /// <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>
  11557. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, IEnumerable<TResult>>> selector)
  11558. {
  11559. if (source == null)
  11560. throw new ArgumentNullException("source");
  11561. if (selector == null)
  11562. throw new ArgumentNullException("selector");
  11563. return source.Provider.CreateQuery<TResult>(
  11564. Expression.Call(
  11565. null,
  11566. #if CRIPPLED_REFLECTION
  11567. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, IEnumerable<TResult>>>))),
  11568. #else
  11569. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11570. #endif
  11571. source.Expression,
  11572. selector
  11573. )
  11574. );
  11575. }
  11576. /// <summary>
  11577. /// 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.
  11578. /// </summary>
  11579. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11580. /// <typeparam name="TResult">The type of the elements in the projected inner enumerable sequences and the elements in the merged result sequence.</typeparam>
  11581. /// <param name="source">An observable sequence of elements to project.</param>
  11582. /// <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>
  11583. /// <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>
  11584. /// <exception cref="T:System.ArgumentNullException">
  11585. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11586. /// <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>
  11587. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, IEnumerable<TResult>>> selector)
  11588. {
  11589. if (source == null)
  11590. throw new ArgumentNullException("source");
  11591. if (selector == null)
  11592. throw new ArgumentNullException("selector");
  11593. return source.Provider.CreateQuery<TResult>(
  11594. Expression.Call(
  11595. null,
  11596. #if CRIPPLED_REFLECTION
  11597. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, IEnumerable<TResult>>>))),
  11598. #else
  11599. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11600. #endif
  11601. source.Expression,
  11602. selector
  11603. )
  11604. );
  11605. }
  11606. /// <summary>
  11607. /// Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  11608. /// </summary>
  11609. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11610. /// <typeparam name="TResult">The type of the elements in the projected inner sequences and the elements in the merged result sequence.</typeparam>
  11611. /// <param name="source">An observable sequence of elements to project.</param>
  11612. /// <param name="selector">A transform function to apply to each element.</param>
  11613. /// <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>
  11614. /// <exception cref="T:System.ArgumentNullException">
  11615. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11616. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TResult>>> selector)
  11617. {
  11618. if (source == null)
  11619. throw new ArgumentNullException("source");
  11620. if (selector == null)
  11621. throw new ArgumentNullException("selector");
  11622. return source.Provider.CreateQuery<TResult>(
  11623. Expression.Call(
  11624. null,
  11625. #if CRIPPLED_REFLECTION
  11626. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TResult>>>))),
  11627. #else
  11628. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11629. #endif
  11630. source.Expression,
  11631. selector
  11632. )
  11633. );
  11634. }
  11635. /// <summary>
  11636. /// 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.
  11637. /// </summary>
  11638. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11639. /// <typeparam name="TResult">The type of the elements in the projected inner sequences and the elements in the merged result sequence.</typeparam>
  11640. /// <param name="source">An observable sequence of elements to project.</param>
  11641. /// <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>
  11642. /// <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>
  11643. /// <exception cref="T:System.ArgumentNullException">
  11644. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11645. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, IObservable<TResult>>> selector)
  11646. {
  11647. if (source == null)
  11648. throw new ArgumentNullException("source");
  11649. if (selector == null)
  11650. throw new ArgumentNullException("selector");
  11651. return source.Provider.CreateQuery<TResult>(
  11652. Expression.Call(
  11653. null,
  11654. #if CRIPPLED_REFLECTION
  11655. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, IObservable<TResult>>>))),
  11656. #else
  11657. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11658. #endif
  11659. source.Expression,
  11660. selector
  11661. )
  11662. );
  11663. }
  11664. #if !NO_TPL
  11665. /// <summary>
  11666. /// Projects each element of an observable sequence to a task and merges all of the task results into one observable sequence.
  11667. /// </summary>
  11668. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11669. /// <typeparam name="TResult">The type of the result produced by the projected tasks and the elements in the merged result sequence.</typeparam>
  11670. /// <param name="source">An observable sequence of elements to project.</param>
  11671. /// <param name="selector">A transform function to apply to each element.</param>
  11672. /// <returns>An observable sequence whose elements are the result of the tasks executed for each element of the input sequence.</returns>
  11673. /// <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>
  11674. /// <exception cref="T:System.ArgumentNullException">
  11675. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11676. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, Task<TResult>>> selector)
  11677. {
  11678. if (source == null)
  11679. throw new ArgumentNullException("source");
  11680. if (selector == null)
  11681. throw new ArgumentNullException("selector");
  11682. return source.Provider.CreateQuery<TResult>(
  11683. Expression.Call(
  11684. null,
  11685. #if CRIPPLED_REFLECTION
  11686. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, Task<TResult>>>))),
  11687. #else
  11688. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11689. #endif
  11690. source.Expression,
  11691. selector
  11692. )
  11693. );
  11694. }
  11695. #endif
  11696. #if !NO_TPL
  11697. /// <summary>
  11698. /// 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.
  11699. /// </summary>
  11700. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11701. /// <typeparam name="TResult">The type of the result produced by the projected tasks and the elements in the merged result sequence.</typeparam>
  11702. /// <param name="source">An observable sequence of elements to project.</param>
  11703. /// <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>
  11704. /// <returns>An observable sequence whose elements are the result of the tasks executed for each element of the input sequence.</returns>
  11705. /// <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>
  11706. /// <exception cref="T:System.ArgumentNullException">
  11707. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11708. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, Task<TResult>>> selector)
  11709. {
  11710. if (source == null)
  11711. throw new ArgumentNullException("source");
  11712. if (selector == null)
  11713. throw new ArgumentNullException("selector");
  11714. return source.Provider.CreateQuery<TResult>(
  11715. Expression.Call(
  11716. null,
  11717. #if CRIPPLED_REFLECTION
  11718. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, Task<TResult>>>))),
  11719. #else
  11720. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11721. #endif
  11722. source.Expression,
  11723. selector
  11724. )
  11725. );
  11726. }
  11727. #endif
  11728. #if !NO_TPL
  11729. /// <summary>
  11730. /// Projects each element of an observable sequence to a task with cancellation support and merges all of the task results into one observable sequence.
  11731. /// </summary>
  11732. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11733. /// <typeparam name="TResult">The type of the result produced by the projected tasks and the elements in the merged result sequence.</typeparam>
  11734. /// <param name="source">An observable sequence of elements to project.</param>
  11735. /// <param name="selector">A transform function to apply to each element.</param>
  11736. /// <returns>An observable sequence whose elements are the result of the tasks executed for each element of the input sequence.</returns>
  11737. /// <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>
  11738. /// <exception cref="T:System.ArgumentNullException">
  11739. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11740. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, CancellationToken, Task<TResult>>> selector)
  11741. {
  11742. if (source == null)
  11743. throw new ArgumentNullException("source");
  11744. if (selector == null)
  11745. throw new ArgumentNullException("selector");
  11746. return source.Provider.CreateQuery<TResult>(
  11747. Expression.Call(
  11748. null,
  11749. #if CRIPPLED_REFLECTION
  11750. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, CancellationToken, Task<TResult>>>))),
  11751. #else
  11752. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11753. #endif
  11754. source.Expression,
  11755. selector
  11756. )
  11757. );
  11758. }
  11759. #endif
  11760. #if !NO_TPL
  11761. /// <summary>
  11762. /// 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.
  11763. /// </summary>
  11764. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11765. /// <typeparam name="TResult">The type of the result produced by the projected tasks and the elements in the merged result sequence.</typeparam>
  11766. /// <param name="source">An observable sequence of elements to project.</param>
  11767. /// <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>
  11768. /// <returns>An observable sequence whose elements are the result of the tasks executed for each element of the input sequence.</returns>
  11769. /// <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>
  11770. /// <exception cref="T:System.ArgumentNullException">
  11771. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11772. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, CancellationToken, Task<TResult>>> selector)
  11773. {
  11774. if (source == null)
  11775. throw new ArgumentNullException("source");
  11776. if (selector == null)
  11777. throw new ArgumentNullException("selector");
  11778. return source.Provider.CreateQuery<TResult>(
  11779. Expression.Call(
  11780. null,
  11781. #if CRIPPLED_REFLECTION
  11782. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, CancellationToken, Task<TResult>>>))),
  11783. #else
  11784. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11785. #endif
  11786. source.Expression,
  11787. selector
  11788. )
  11789. );
  11790. }
  11791. #endif
  11792. #if !NO_TPL
  11793. /// <summary>
  11794. /// 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.
  11795. /// </summary>
  11796. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11797. /// <typeparam name="TTaskResult">The type of the results produced by the projected intermediate tasks.</typeparam>
  11798. /// <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>
  11799. /// <param name="source">An observable sequence of elements to project.</param>
  11800. /// <param name="taskSelector">A transform function to apply to each element.</param>
  11801. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
  11802. /// <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>
  11803. /// <exception cref="T:System.ArgumentNullException">
  11804. /// <paramref name="source" /> or <paramref name="taskSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11805. /// <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>
  11806. public static IQbservable<TResult> SelectMany<TSource, TTaskResult, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, Task<TTaskResult>>> taskSelector, Expression<Func<TSource, TTaskResult, TResult>> resultSelector)
  11807. {
  11808. if (source == null)
  11809. throw new ArgumentNullException("source");
  11810. if (taskSelector == null)
  11811. throw new ArgumentNullException("taskSelector");
  11812. if (resultSelector == null)
  11813. throw new ArgumentNullException("resultSelector");
  11814. return source.Provider.CreateQuery<TResult>(
  11815. Expression.Call(
  11816. null,
  11817. #if CRIPPLED_REFLECTION
  11818. InfoOf(() => Qbservable.SelectMany<TSource, TTaskResult, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, Task<TTaskResult>>>), default(Expression<Func<TSource, TTaskResult, TResult>>))),
  11819. #else
  11820. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTaskResult), typeof(TResult)),
  11821. #endif
  11822. source.Expression,
  11823. taskSelector,
  11824. resultSelector
  11825. )
  11826. );
  11827. }
  11828. #endif
  11829. #if !NO_TPL
  11830. /// <summary>
  11831. /// 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.
  11832. /// </summary>
  11833. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11834. /// <typeparam name="TTaskResult">The type of the results produced by the projected intermediate tasks.</typeparam>
  11835. /// <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>
  11836. /// <param name="source">An observable sequence of elements to project.</param>
  11837. /// <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>
  11838. /// <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>
  11839. /// <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>
  11840. /// <exception cref="T:System.ArgumentNullException">
  11841. /// <paramref name="source" /> or <paramref name="taskSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11842. /// <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>
  11843. 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)
  11844. {
  11845. if (source == null)
  11846. throw new ArgumentNullException("source");
  11847. if (taskSelector == null)
  11848. throw new ArgumentNullException("taskSelector");
  11849. if (resultSelector == null)
  11850. throw new ArgumentNullException("resultSelector");
  11851. return source.Provider.CreateQuery<TResult>(
  11852. Expression.Call(
  11853. null,
  11854. #if CRIPPLED_REFLECTION
  11855. InfoOf(() => Qbservable.SelectMany<TSource, TTaskResult, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, Task<TTaskResult>>>), default(Expression<Func<TSource, int, TTaskResult, TResult>>))),
  11856. #else
  11857. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTaskResult), typeof(TResult)),
  11858. #endif
  11859. source.Expression,
  11860. taskSelector,
  11861. resultSelector
  11862. )
  11863. );
  11864. }
  11865. #endif
  11866. #if !NO_TPL
  11867. /// <summary>
  11868. /// 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.
  11869. /// </summary>
  11870. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11871. /// <typeparam name="TTaskResult">The type of the results produced by the projected intermediate tasks.</typeparam>
  11872. /// <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>
  11873. /// <param name="source">An observable sequence of elements to project.</param>
  11874. /// <param name="taskSelector">A transform function to apply to each element.</param>
  11875. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
  11876. /// <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>
  11877. /// <exception cref="T:System.ArgumentNullException">
  11878. /// <paramref name="source" /> or <paramref name="taskSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11879. /// <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>
  11880. 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)
  11881. {
  11882. if (source == null)
  11883. throw new ArgumentNullException("source");
  11884. if (taskSelector == null)
  11885. throw new ArgumentNullException("taskSelector");
  11886. if (resultSelector == null)
  11887. throw new ArgumentNullException("resultSelector");
  11888. return source.Provider.CreateQuery<TResult>(
  11889. Expression.Call(
  11890. null,
  11891. #if CRIPPLED_REFLECTION
  11892. InfoOf(() => Qbservable.SelectMany<TSource, TTaskResult, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, CancellationToken, Task<TTaskResult>>>), default(Expression<Func<TSource, TTaskResult, TResult>>))),
  11893. #else
  11894. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTaskResult), typeof(TResult)),
  11895. #endif
  11896. source.Expression,
  11897. taskSelector,
  11898. resultSelector
  11899. )
  11900. );
  11901. }
  11902. #endif
  11903. #if !NO_TPL
  11904. /// <summary>
  11905. /// 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.
  11906. /// </summary>
  11907. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11908. /// <typeparam name="TTaskResult">The type of the results produced by the projected intermediate tasks.</typeparam>
  11909. /// <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>
  11910. /// <param name="source">An observable sequence of elements to project.</param>
  11911. /// <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>
  11912. /// <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>
  11913. /// <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>
  11914. /// <exception cref="T:System.ArgumentNullException">
  11915. /// <paramref name="source" /> or <paramref name="taskSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11916. /// <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>
  11917. 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)
  11918. {
  11919. if (source == null)
  11920. throw new ArgumentNullException("source");
  11921. if (taskSelector == null)
  11922. throw new ArgumentNullException("taskSelector");
  11923. if (resultSelector == null)
  11924. throw new ArgumentNullException("resultSelector");
  11925. return source.Provider.CreateQuery<TResult>(
  11926. Expression.Call(
  11927. null,
  11928. #if CRIPPLED_REFLECTION
  11929. InfoOf(() => Qbservable.SelectMany<TSource, TTaskResult, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, CancellationToken, Task<TTaskResult>>>), default(Expression<Func<TSource, int, TTaskResult, TResult>>))),
  11930. #else
  11931. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTaskResult), typeof(TResult)),
  11932. #endif
  11933. source.Expression,
  11934. taskSelector,
  11935. resultSelector
  11936. )
  11937. );
  11938. }
  11939. #endif
  11940. /// <summary>
  11941. /// Determines whether two sequences are equal by comparing the elements pairwise.
  11942. /// </summary>
  11943. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11944. /// <param name="first">First observable sequence to compare.</param>
  11945. /// <param name="second">Second observable sequence to compare.</param>
  11946. /// <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>
  11947. /// <exception cref="T:System.ArgumentNullException">
  11948. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  11949. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  11950. public static IQbservable<bool> SequenceEqual<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  11951. {
  11952. if (first == null)
  11953. throw new ArgumentNullException("first");
  11954. if (second == null)
  11955. throw new ArgumentNullException("second");
  11956. return first.Provider.CreateQuery<bool>(
  11957. Expression.Call(
  11958. null,
  11959. #if CRIPPLED_REFLECTION
  11960. InfoOf(() => Qbservable.SequenceEqual<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  11961. #else
  11962. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11963. #endif
  11964. first.Expression,
  11965. GetSourceExpression(second)
  11966. )
  11967. );
  11968. }
  11969. /// <summary>
  11970. /// Determines whether an observable and enumerable sequence are equal by comparing the elements pairwise.
  11971. /// </summary>
  11972. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11973. /// <param name="first">First observable sequence to compare.</param>
  11974. /// <param name="second">Second observable sequence to compare.</param>
  11975. /// <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>
  11976. /// <exception cref="T:System.ArgumentNullException">
  11977. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  11978. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  11979. public static IQbservable<bool> SequenceEqual<TSource>(this IQbservable<TSource> first, IEnumerable<TSource> second)
  11980. {
  11981. if (first == null)
  11982. throw new ArgumentNullException("first");
  11983. if (second == null)
  11984. throw new ArgumentNullException("second");
  11985. return first.Provider.CreateQuery<bool>(
  11986. Expression.Call(
  11987. null,
  11988. #if CRIPPLED_REFLECTION
  11989. InfoOf(() => Qbservable.SequenceEqual<TSource>(default(IQbservable<TSource>), default(IEnumerable<TSource>))),
  11990. #else
  11991. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11992. #endif
  11993. first.Expression,
  11994. GetSourceExpression(second)
  11995. )
  11996. );
  11997. }
  11998. /// <summary>
  11999. /// Determines whether two sequences are equal by comparing the elements pairwise using a specified equality comparer.
  12000. /// </summary>
  12001. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12002. /// <param name="first">First observable sequence to compare.</param>
  12003. /// <param name="second">Second observable sequence to compare.</param>
  12004. /// <param name="comparer">Comparer used to compare elements of both sequences.</param>
  12005. /// <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>
  12006. /// <exception cref="T:System.ArgumentNullException">
  12007. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="comparer" /> is null.</exception>
  12008. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12009. public static IQbservable<bool> SequenceEqual<TSource>(this IQbservable<TSource> first, IObservable<TSource> second, IEqualityComparer<TSource> comparer)
  12010. {
  12011. if (first == null)
  12012. throw new ArgumentNullException("first");
  12013. if (second == null)
  12014. throw new ArgumentNullException("second");
  12015. if (comparer == null)
  12016. throw new ArgumentNullException("comparer");
  12017. return first.Provider.CreateQuery<bool>(
  12018. Expression.Call(
  12019. null,
  12020. #if CRIPPLED_REFLECTION
  12021. InfoOf(() => Qbservable.SequenceEqual<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>), default(IEqualityComparer<TSource>))),
  12022. #else
  12023. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12024. #endif
  12025. first.Expression,
  12026. GetSourceExpression(second),
  12027. Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))
  12028. )
  12029. );
  12030. }
  12031. /// <summary>
  12032. /// Determines whether an observable and enumerable sequence are equal by comparing the elements pairwise using a specified equality comparer.
  12033. /// </summary>
  12034. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12035. /// <param name="first">First observable sequence to compare.</param>
  12036. /// <param name="second">Second observable sequence to compare.</param>
  12037. /// <param name="comparer">Comparer used to compare elements of both sequences.</param>
  12038. /// <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>
  12039. /// <exception cref="T:System.ArgumentNullException">
  12040. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="comparer" /> is null.</exception>
  12041. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12042. public static IQbservable<bool> SequenceEqual<TSource>(this IQbservable<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
  12043. {
  12044. if (first == null)
  12045. throw new ArgumentNullException("first");
  12046. if (second == null)
  12047. throw new ArgumentNullException("second");
  12048. if (comparer == null)
  12049. throw new ArgumentNullException("comparer");
  12050. return first.Provider.CreateQuery<bool>(
  12051. Expression.Call(
  12052. null,
  12053. #if CRIPPLED_REFLECTION
  12054. InfoOf(() => Qbservable.SequenceEqual<TSource>(default(IQbservable<TSource>), default(IEnumerable<TSource>), default(IEqualityComparer<TSource>))),
  12055. #else
  12056. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12057. #endif
  12058. first.Expression,
  12059. GetSourceExpression(second),
  12060. Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))
  12061. )
  12062. );
  12063. }
  12064. /// <summary>
  12065. /// Returns the only element of an observable sequence, and reports an exception if there is not exactly one element in the observable sequence.
  12066. /// </summary>
  12067. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12068. /// <param name="source">Source observable sequence.</param>
  12069. /// <returns>Sequence containing the single element in the observable sequence.</returns>
  12070. /// <exception cref="T:System.ArgumentNullException">
  12071. /// <paramref name="source" /> is null.</exception>
  12072. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence contains more than one element. -or- The source sequence is empty.</exception>
  12073. public static IQbservable<TSource> SingleAsync<TSource>(this IQbservable<TSource> source)
  12074. {
  12075. if (source == null)
  12076. throw new ArgumentNullException("source");
  12077. return source.Provider.CreateQuery<TSource>(
  12078. Expression.Call(
  12079. null,
  12080. #if CRIPPLED_REFLECTION
  12081. InfoOf(() => Qbservable.SingleAsync<TSource>(default(IQbservable<TSource>))),
  12082. #else
  12083. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12084. #endif
  12085. source.Expression
  12086. )
  12087. );
  12088. }
  12089. /// <summary>
  12090. /// 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.
  12091. /// </summary>
  12092. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12093. /// <param name="source">Source observable sequence.</param>
  12094. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  12095. /// <returns>Sequence containing the single element in the observable sequence that satisfies the condition in the predicate.</returns>
  12096. /// <exception cref="T:System.ArgumentNullException">
  12097. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  12098. /// <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>
  12099. public static IQbservable<TSource> SingleAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  12100. {
  12101. if (source == null)
  12102. throw new ArgumentNullException("source");
  12103. if (predicate == null)
  12104. throw new ArgumentNullException("predicate");
  12105. return source.Provider.CreateQuery<TSource>(
  12106. Expression.Call(
  12107. null,
  12108. #if CRIPPLED_REFLECTION
  12109. InfoOf(() => Qbservable.SingleAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  12110. #else
  12111. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12112. #endif
  12113. source.Expression,
  12114. predicate
  12115. )
  12116. );
  12117. }
  12118. /// <summary>
  12119. /// 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.
  12120. /// </summary>
  12121. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12122. /// <param name="source">Source observable sequence.</param>
  12123. /// <returns>Sequence containing the single element in the observable sequence, or a default value if no such element exists.</returns>
  12124. /// <exception cref="T:System.ArgumentNullException">
  12125. /// <paramref name="source" /> is null.</exception>
  12126. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence contains more than one element.</exception>
  12127. public static IQbservable<TSource> SingleOrDefaultAsync<TSource>(this IQbservable<TSource> source)
  12128. {
  12129. if (source == null)
  12130. throw new ArgumentNullException("source");
  12131. return source.Provider.CreateQuery<TSource>(
  12132. Expression.Call(
  12133. null,
  12134. #if CRIPPLED_REFLECTION
  12135. InfoOf(() => Qbservable.SingleOrDefaultAsync<TSource>(default(IQbservable<TSource>))),
  12136. #else
  12137. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12138. #endif
  12139. source.Expression
  12140. )
  12141. );
  12142. }
  12143. /// <summary>
  12144. /// 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.
  12145. /// </summary>
  12146. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12147. /// <param name="source">Source observable sequence.</param>
  12148. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  12149. /// <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>
  12150. /// <exception cref="T:System.ArgumentNullException">
  12151. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  12152. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The sequence contains more than one element that satisfies the condition in the predicate.</exception>
  12153. public static IQbservable<TSource> SingleOrDefaultAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  12154. {
  12155. if (source == null)
  12156. throw new ArgumentNullException("source");
  12157. if (predicate == null)
  12158. throw new ArgumentNullException("predicate");
  12159. return source.Provider.CreateQuery<TSource>(
  12160. Expression.Call(
  12161. null,
  12162. #if CRIPPLED_REFLECTION
  12163. InfoOf(() => Qbservable.SingleOrDefaultAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  12164. #else
  12165. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12166. #endif
  12167. source.Expression,
  12168. predicate
  12169. )
  12170. );
  12171. }
  12172. /// <summary>
  12173. /// Bypasses a specified number of elements in an observable sequence and then returns the remaining elements.
  12174. /// </summary>
  12175. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12176. /// <param name="source">The sequence to take elements from.</param>
  12177. /// <param name="count">The number of elements to skip before returning the remaining elements.</param>
  12178. /// <returns>An observable sequence that contains the elements that occur after the specified index in the input sequence.</returns>
  12179. /// <exception cref="T:System.ArgumentNullException">
  12180. /// <paramref name="source" /> is null.</exception>
  12181. /// <exception cref="T:System.ArgumentOutOfRangeException">
  12182. /// <paramref name="count" /> is less than zero.</exception>
  12183. public static IQbservable<TSource> Skip<TSource>(this IQbservable<TSource> source, int count)
  12184. {
  12185. if (source == null)
  12186. throw new ArgumentNullException("source");
  12187. return source.Provider.CreateQuery<TSource>(
  12188. Expression.Call(
  12189. null,
  12190. #if CRIPPLED_REFLECTION
  12191. InfoOf(() => Qbservable.Skip<TSource>(default(IQbservable<TSource>), default(int))),
  12192. #else
  12193. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12194. #endif
  12195. source.Expression,
  12196. Expression.Constant(count, typeof(int))
  12197. )
  12198. );
  12199. }
  12200. /// <summary>
  12201. /// Skips elements for the specified duration from the start of the observable source sequence.
  12202. /// </summary>
  12203. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12204. /// <param name="source">Source sequence to skip elements for.</param>
  12205. /// <param name="duration">Duration for skipping elements from the start of the sequence.</param>
  12206. /// <returns>An observable sequence with the elements skipped during the specified duration from the start of the source sequence.</returns>
  12207. /// <exception cref="T:System.ArgumentNullException">
  12208. /// <paramref name="source" /> is null.</exception>
  12209. /// <exception cref="T:System.ArgumentOutOfRangeException">
  12210. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  12211. /// <remarks>
  12212. /// <para>
  12213. /// Specifying a TimeSpan.Zero value for <paramref name="duration" /> doesn't guarantee no elements will be dropped from the start of the source sequence.
  12214. /// 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
  12215. /// may not execute immediately, despite the TimeSpan.Zero due time.
  12216. /// </para>
  12217. /// <para>
  12218. /// Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the <paramref name="duration" />.
  12219. /// </para>
  12220. /// </remarks>
  12221. public static IQbservable<TSource> Skip<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  12222. {
  12223. if (source == null)
  12224. throw new ArgumentNullException("source");
  12225. return source.Provider.CreateQuery<TSource>(
  12226. Expression.Call(
  12227. null,
  12228. #if CRIPPLED_REFLECTION
  12229. InfoOf(() => Qbservable.Skip<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  12230. #else
  12231. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12232. #endif
  12233. source.Expression,
  12234. Expression.Constant(duration, typeof(TimeSpan))
  12235. )
  12236. );
  12237. }
  12238. /// <summary>
  12239. /// Skips elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers.
  12240. /// </summary>
  12241. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12242. /// <param name="source">Source sequence to skip elements for.</param>
  12243. /// <param name="duration">Duration for skipping elements from the start of the sequence.</param>
  12244. /// <param name="scheduler">Scheduler to run the timer on.</param>
  12245. /// <returns>An observable sequence with the elements skipped during the specified duration from the start of the source sequence.</returns>
  12246. /// <exception cref="T:System.ArgumentNullException">
  12247. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  12248. /// <exception cref="T:System.ArgumentOutOfRangeException">
  12249. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  12250. /// <remarks>
  12251. /// <para>
  12252. /// Specifying a TimeSpan.Zero value for <paramref name="duration" /> doesn't guarantee no elements will be dropped from the start of the source sequence.
  12253. /// 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
  12254. /// may not execute immediately, despite the TimeSpan.Zero due time.
  12255. /// </para>
  12256. /// <para>
  12257. /// Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the <paramref name="duration" />.
  12258. /// </para>
  12259. /// </remarks>
  12260. public static IQbservable<TSource> Skip<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  12261. {
  12262. if (source == null)
  12263. throw new ArgumentNullException("source");
  12264. if (scheduler == null)
  12265. throw new ArgumentNullException("scheduler");
  12266. return source.Provider.CreateQuery<TSource>(
  12267. Expression.Call(
  12268. null,
  12269. #if CRIPPLED_REFLECTION
  12270. InfoOf(() => Qbservable.Skip<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  12271. #else
  12272. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12273. #endif
  12274. source.Expression,
  12275. Expression.Constant(duration, typeof(TimeSpan)),
  12276. Expression.Constant(scheduler, typeof(IScheduler))
  12277. )
  12278. );
  12279. }
  12280. /// <summary>
  12281. /// Bypasses a specified number of elements at the end of an observable sequence.
  12282. /// </summary>
  12283. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12284. /// <param name="source">Source sequence.</param>
  12285. /// <param name="count">Number of elements to bypass at the end of the source sequence.</param>
  12286. /// <returns>An observable sequence containing the source sequence elements except for the bypassed ones at the end.</returns>
  12287. /// <exception cref="T:System.ArgumentNullException">
  12288. /// <paramref name="source" /> is null.</exception>
  12289. /// <exception cref="T:System.ArgumentOutOfRangeException">
  12290. /// <paramref name="count" /> is less than zero.</exception>
  12291. /// <remarks>
  12292. /// This operator accumulates a queue with a length enough to store the first <paramref name="count" /> elements. As more elements are
  12293. /// received, elements are taken from the front of the queue and produced on the result sequence. This causes elements to be delayed.
  12294. /// </remarks>
  12295. public static IQbservable<TSource> SkipLast<TSource>(this IQbservable<TSource> source, int count)
  12296. {
  12297. if (source == null)
  12298. throw new ArgumentNullException("source");
  12299. return source.Provider.CreateQuery<TSource>(
  12300. Expression.Call(
  12301. null,
  12302. #if CRIPPLED_REFLECTION
  12303. InfoOf(() => Qbservable.SkipLast<TSource>(default(IQbservable<TSource>), default(int))),
  12304. #else
  12305. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12306. #endif
  12307. source.Expression,
  12308. Expression.Constant(count, typeof(int))
  12309. )
  12310. );
  12311. }
  12312. /// <summary>
  12313. /// Skips elements for the specified duration from the end of the observable source sequence.
  12314. /// </summary>
  12315. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12316. /// <param name="source">Source sequence to skip elements for.</param>
  12317. /// <param name="duration">Duration for skipping elements from the end of the sequence.</param>
  12318. /// <returns>An observable sequence with the elements skipped during the specified duration from the end of the source sequence.</returns>
  12319. /// <exception cref="T:System.ArgumentNullException">
  12320. /// <paramref name="source" /> is null.</exception>
  12321. /// <exception cref="T:System.ArgumentOutOfRangeException">
  12322. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  12323. /// <remarks>
  12324. /// This operator accumulates a queue with a length enough to store elements received during the initial <paramref name="duration" /> window.
  12325. /// As more elements are received, elements older than the specified <paramref name="duration" /> are taken from the queue and produced on the
  12326. /// result sequence. This causes elements to be delayed with <paramref name="duration" />.
  12327. /// </remarks>
  12328. public static IQbservable<TSource> SkipLast<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  12329. {
  12330. if (source == null)
  12331. throw new ArgumentNullException("source");
  12332. return source.Provider.CreateQuery<TSource>(
  12333. Expression.Call(
  12334. null,
  12335. #if CRIPPLED_REFLECTION
  12336. InfoOf(() => Qbservable.SkipLast<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  12337. #else
  12338. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12339. #endif
  12340. source.Expression,
  12341. Expression.Constant(duration, typeof(TimeSpan))
  12342. )
  12343. );
  12344. }
  12345. /// <summary>
  12346. /// Skips elements for the specified duration from the end of the observable source sequence, using the specified scheduler to run timers.
  12347. /// </summary>
  12348. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12349. /// <param name="source">Source sequence to skip elements for.</param>
  12350. /// <param name="duration">Duration for skipping elements from the end of the sequence.</param>
  12351. /// <param name="scheduler">Scheduler to run the timer on.</param>
  12352. /// <returns>An observable sequence with the elements skipped during the specified duration from the end of the source sequence.</returns>
  12353. /// <exception cref="T:System.ArgumentNullException">
  12354. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  12355. /// <exception cref="T:System.ArgumentOutOfRangeException">
  12356. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  12357. /// <remarks>
  12358. /// This operator accumulates a queue with a length enough to store elements received during the initial <paramref name="duration" /> window.
  12359. /// As more elements are received, elements older than the specified <paramref name="duration" /> are taken from the queue and produced on the
  12360. /// result sequence. This causes elements to be delayed with <paramref name="duration" />.
  12361. /// </remarks>
  12362. public static IQbservable<TSource> SkipLast<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  12363. {
  12364. if (source == null)
  12365. throw new ArgumentNullException("source");
  12366. if (scheduler == null)
  12367. throw new ArgumentNullException("scheduler");
  12368. return source.Provider.CreateQuery<TSource>(
  12369. Expression.Call(
  12370. null,
  12371. #if CRIPPLED_REFLECTION
  12372. InfoOf(() => Qbservable.SkipLast<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  12373. #else
  12374. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12375. #endif
  12376. source.Expression,
  12377. Expression.Constant(duration, typeof(TimeSpan)),
  12378. Expression.Constant(scheduler, typeof(IScheduler))
  12379. )
  12380. );
  12381. }
  12382. /// <summary>
  12383. /// Skips elements from the observable source sequence until the specified start time.
  12384. /// </summary>
  12385. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12386. /// <param name="source">Source sequence to skip elements for.</param>
  12387. /// <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>
  12388. /// <returns>An observable sequence with the elements skipped until the specified start time.</returns>
  12389. /// <exception cref="T:System.ArgumentNullException">
  12390. /// <paramref name="source" /> is null.</exception>
  12391. /// <remarks>
  12392. /// Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the <paramref name="startTime" />.
  12393. /// </remarks>
  12394. public static IQbservable<TSource> SkipUntil<TSource>(this IQbservable<TSource> source, DateTimeOffset startTime)
  12395. {
  12396. if (source == null)
  12397. throw new ArgumentNullException("source");
  12398. return source.Provider.CreateQuery<TSource>(
  12399. Expression.Call(
  12400. null,
  12401. #if CRIPPLED_REFLECTION
  12402. InfoOf(() => Qbservable.SkipUntil<TSource>(default(IQbservable<TSource>), default(DateTimeOffset))),
  12403. #else
  12404. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12405. #endif
  12406. source.Expression,
  12407. Expression.Constant(startTime, typeof(DateTimeOffset))
  12408. )
  12409. );
  12410. }
  12411. /// <summary>
  12412. /// Skips elements from the observable source sequence until the specified start time, using the specified scheduler to run timers.
  12413. /// </summary>
  12414. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12415. /// <param name="source">Source sequence to skip elements for.</param>
  12416. /// <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>
  12417. /// <param name="scheduler">Scheduler to run the timer on.</param>
  12418. /// <returns>An observable sequence with the elements skipped until the specified start time.</returns>
  12419. /// <exception cref="T:System.ArgumentNullException">
  12420. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  12421. /// <remarks>
  12422. /// Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the <paramref name="startTime" />.
  12423. /// </remarks>
  12424. public static IQbservable<TSource> SkipUntil<TSource>(this IQbservable<TSource> source, DateTimeOffset startTime, IScheduler scheduler)
  12425. {
  12426. if (source == null)
  12427. throw new ArgumentNullException("source");
  12428. if (scheduler == null)
  12429. throw new ArgumentNullException("scheduler");
  12430. return source.Provider.CreateQuery<TSource>(
  12431. Expression.Call(
  12432. null,
  12433. #if CRIPPLED_REFLECTION
  12434. InfoOf(() => Qbservable.SkipUntil<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IScheduler))),
  12435. #else
  12436. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12437. #endif
  12438. source.Expression,
  12439. Expression.Constant(startTime, typeof(DateTimeOffset)),
  12440. Expression.Constant(scheduler, typeof(IScheduler))
  12441. )
  12442. );
  12443. }
  12444. /// <summary>
  12445. /// Returns the elements from the source observable sequence only after the other observable sequence produces an element.
  12446. /// </summary>
  12447. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12448. /// <typeparam name="TOther">The type of the elements in the other sequence that indicates the end of skip behavior.</typeparam>
  12449. /// <param name="source">Source sequence to propagate elements for.</param>
  12450. /// <param name="other">Observable sequence that triggers propagation of elements of the source sequence.</param>
  12451. /// <returns>An observable sequence containing the elements of the source sequence starting from the point the other sequence triggered propagation.</returns>
  12452. /// <exception cref="T:System.ArgumentNullException">
  12453. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  12454. public static IQbservable<TSource> SkipUntil<TSource, TOther>(this IQbservable<TSource> source, IObservable<TOther> other)
  12455. {
  12456. if (source == null)
  12457. throw new ArgumentNullException("source");
  12458. if (other == null)
  12459. throw new ArgumentNullException("other");
  12460. return source.Provider.CreateQuery<TSource>(
  12461. Expression.Call(
  12462. null,
  12463. #if CRIPPLED_REFLECTION
  12464. InfoOf(() => Qbservable.SkipUntil<TSource, TOther>(default(IQbservable<TSource>), default(IObservable<TOther>))),
  12465. #else
  12466. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)),
  12467. #endif
  12468. source.Expression,
  12469. GetSourceExpression(other)
  12470. )
  12471. );
  12472. }
  12473. /// <summary>
  12474. /// Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements.
  12475. /// </summary>
  12476. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12477. /// <param name="source">An observable sequence to return elements from.</param>
  12478. /// <param name="predicate">A function to test each element for a condition.</param>
  12479. /// <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>
  12480. /// <exception cref="T:System.ArgumentNullException">
  12481. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  12482. public static IQbservable<TSource> SkipWhile<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  12483. {
  12484. if (source == null)
  12485. throw new ArgumentNullException("source");
  12486. if (predicate == null)
  12487. throw new ArgumentNullException("predicate");
  12488. return source.Provider.CreateQuery<TSource>(
  12489. Expression.Call(
  12490. null,
  12491. #if CRIPPLED_REFLECTION
  12492. InfoOf(() => Qbservable.SkipWhile<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  12493. #else
  12494. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12495. #endif
  12496. source.Expression,
  12497. predicate
  12498. )
  12499. );
  12500. }
  12501. /// <summary>
  12502. /// Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements.
  12503. /// The element's index is used in the logic of the predicate function.
  12504. /// </summary>
  12505. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12506. /// <param name="source">An observable sequence to return elements from.</param>
  12507. /// <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>
  12508. /// <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>
  12509. /// <exception cref="T:System.ArgumentNullException">
  12510. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  12511. public static IQbservable<TSource> SkipWhile<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int, bool>> predicate)
  12512. {
  12513. if (source == null)
  12514. throw new ArgumentNullException("source");
  12515. if (predicate == null)
  12516. throw new ArgumentNullException("predicate");
  12517. return source.Provider.CreateQuery<TSource>(
  12518. Expression.Call(
  12519. null,
  12520. #if CRIPPLED_REFLECTION
  12521. InfoOf(() => Qbservable.SkipWhile<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, bool>>))),
  12522. #else
  12523. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12524. #endif
  12525. source.Expression,
  12526. predicate
  12527. )
  12528. );
  12529. }
  12530. /// <summary>
  12531. /// Invokes the action asynchronously, surfacing the result through an observable sequence.
  12532. /// </summary>
  12533. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  12534. /// <param name="action">Action to run asynchronously.</param>
  12535. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12536. /// <exception cref="T:System.ArgumentNullException">
  12537. /// <paramref name="action" /> is null.</exception>
  12538. /// <remarks>
  12539. /// <list type="bullet">
  12540. /// <item>
  12541. /// <description>The action is called immediately, not during the subscription of the resulting sequence.</description>
  12542. /// </item>
  12543. /// <item>
  12544. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12545. /// </item>
  12546. /// </list>
  12547. /// </remarks>
  12548. public static IQbservable<Unit> Start(this IQbservableProvider provider, Expression<Action> action)
  12549. {
  12550. if (provider == null)
  12551. throw new ArgumentNullException("provider");
  12552. if (action == null)
  12553. throw new ArgumentNullException("action");
  12554. return provider.CreateQuery<Unit>(
  12555. Expression.Call(
  12556. null,
  12557. #if CRIPPLED_REFLECTION
  12558. InfoOf(() => Qbservable.Start(default(IQbservableProvider), default(Expression<Action>))),
  12559. #else
  12560. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12561. #endif
  12562. Expression.Constant(provider, typeof(IQbservableProvider)),
  12563. action
  12564. )
  12565. );
  12566. }
  12567. /// <summary>
  12568. /// Invokes the action asynchronously on the specified scheduler, surfacing the result through an observable sequence.
  12569. /// </summary>
  12570. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  12571. /// <param name="action">Action to run asynchronously.</param>
  12572. /// <param name="scheduler">Scheduler to run the action on.</param>
  12573. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12574. /// <exception cref="T:System.ArgumentNullException">
  12575. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  12576. /// <remarks>
  12577. /// <list type="bullet">
  12578. /// <item>
  12579. /// <description>The action is called immediately, not during the subscription of the resulting sequence.</description>
  12580. /// </item>
  12581. /// <item>
  12582. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12583. /// </item>
  12584. /// </list>
  12585. /// </remarks>
  12586. public static IQbservable<Unit> Start(this IQbservableProvider provider, Expression<Action> action, IScheduler scheduler)
  12587. {
  12588. if (provider == null)
  12589. throw new ArgumentNullException("provider");
  12590. if (action == null)
  12591. throw new ArgumentNullException("action");
  12592. if (scheduler == null)
  12593. throw new ArgumentNullException("scheduler");
  12594. return provider.CreateQuery<Unit>(
  12595. Expression.Call(
  12596. null,
  12597. #if CRIPPLED_REFLECTION
  12598. InfoOf(() => Qbservable.Start(default(IQbservableProvider), default(Expression<Action>), default(IScheduler))),
  12599. #else
  12600. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12601. #endif
  12602. Expression.Constant(provider, typeof(IQbservableProvider)),
  12603. action,
  12604. Expression.Constant(scheduler, typeof(IScheduler))
  12605. )
  12606. );
  12607. }
  12608. /// <summary>
  12609. /// Invokes the specified function asynchronously, surfacing the result through an observable sequence.
  12610. /// </summary>
  12611. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  12612. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  12613. /// <param name="function">Function to run asynchronously.</param>
  12614. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12615. /// <exception cref="T:System.ArgumentNullException">
  12616. /// <paramref name="function" /> is null.</exception>
  12617. /// <remarks>
  12618. /// <list type="bullet">
  12619. /// <item>
  12620. /// <description>The function is called immediately, not during the subscription of the resulting sequence.</description>
  12621. /// </item>
  12622. /// <item>
  12623. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12624. /// </item>
  12625. /// </list>
  12626. /// </remarks>
  12627. public static IQbservable<TResult> Start<TResult>(this IQbservableProvider provider, Expression<Func<TResult>> function)
  12628. {
  12629. if (provider == null)
  12630. throw new ArgumentNullException("provider");
  12631. if (function == null)
  12632. throw new ArgumentNullException("function");
  12633. return provider.CreateQuery<TResult>(
  12634. Expression.Call(
  12635. null,
  12636. #if CRIPPLED_REFLECTION
  12637. InfoOf(() => Qbservable.Start<TResult>(default(IQbservableProvider), default(Expression<Func<TResult>>))),
  12638. #else
  12639. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12640. #endif
  12641. Expression.Constant(provider, typeof(IQbservableProvider)),
  12642. function
  12643. )
  12644. );
  12645. }
  12646. /// <summary>
  12647. /// Invokes the specified function asynchronously on the specified scheduler, surfacing the result through an observable sequence
  12648. /// </summary>
  12649. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  12650. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  12651. /// <param name="function">Function to run asynchronously.</param>
  12652. /// <param name="scheduler">Scheduler to run the function on.</param>
  12653. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12654. /// <exception cref="T:System.ArgumentNullException">
  12655. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  12656. /// <remarks>
  12657. /// <list type="bullet">
  12658. /// <item>
  12659. /// <description>The function is called immediately, not during the subscription of the resulting sequence.</description>
  12660. /// </item>
  12661. /// <item>
  12662. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12663. /// </item>
  12664. /// </list>
  12665. /// </remarks>
  12666. public static IQbservable<TResult> Start<TResult>(this IQbservableProvider provider, Expression<Func<TResult>> function, IScheduler scheduler)
  12667. {
  12668. if (provider == null)
  12669. throw new ArgumentNullException("provider");
  12670. if (function == null)
  12671. throw new ArgumentNullException("function");
  12672. if (scheduler == null)
  12673. throw new ArgumentNullException("scheduler");
  12674. return provider.CreateQuery<TResult>(
  12675. Expression.Call(
  12676. null,
  12677. #if CRIPPLED_REFLECTION
  12678. InfoOf(() => Qbservable.Start<TResult>(default(IQbservableProvider), default(Expression<Func<TResult>>), default(IScheduler))),
  12679. #else
  12680. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12681. #endif
  12682. Expression.Constant(provider, typeof(IQbservableProvider)),
  12683. function,
  12684. Expression.Constant(scheduler, typeof(IScheduler))
  12685. )
  12686. );
  12687. }
  12688. #if !NO_TPL
  12689. /// <summary>
  12690. /// Invokes the asynchronous action, surfacing the result through an observable sequence.
  12691. /// </summary>
  12692. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  12693. /// <param name="actionAsync">Asynchronous action to run.</param>
  12694. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12695. /// <exception cref="T:System.ArgumentNullException">
  12696. /// <paramref name="actionAsync" /> is null.</exception>
  12697. /// <remarks>
  12698. /// <list type="bullet">
  12699. /// <item>
  12700. /// <description>The action is started immediately, not during the subscription of the resulting sequence.</description>
  12701. /// </item>
  12702. /// <item>
  12703. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12704. /// </item>
  12705. /// </list>
  12706. /// </remarks>
  12707. public static IQbservable<Unit> StartAsync(this IQbservableProvider provider, Expression<Func<Task>> actionAsync)
  12708. {
  12709. if (provider == null)
  12710. throw new ArgumentNullException("provider");
  12711. if (actionAsync == null)
  12712. throw new ArgumentNullException("actionAsync");
  12713. return provider.CreateQuery<Unit>(
  12714. Expression.Call(
  12715. null,
  12716. #if CRIPPLED_REFLECTION
  12717. InfoOf(() => Qbservable.StartAsync(default(IQbservableProvider), default(Expression<Func<Task>>))),
  12718. #else
  12719. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12720. #endif
  12721. Expression.Constant(provider, typeof(IQbservableProvider)),
  12722. actionAsync
  12723. )
  12724. );
  12725. }
  12726. #endif
  12727. #if !NO_TPL
  12728. /// <summary>
  12729. /// Invokes the asynchronous action, surfacing the result through an observable sequence.
  12730. /// </summary>
  12731. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  12732. /// <param name="actionAsync">Asynchronous action to run.</param>
  12733. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  12734. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12735. /// <exception cref="T:System.ArgumentNullException">
  12736. /// <paramref name="actionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  12737. /// <remarks>
  12738. /// <list type="bullet">
  12739. /// <item>
  12740. /// <description>The action is started immediately, not during the subscription of the resulting sequence.</description>
  12741. /// </item>
  12742. /// <item>
  12743. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12744. /// </item>
  12745. /// </list>
  12746. /// </remarks>
  12747. public static IQbservable<Unit> StartAsync(this IQbservableProvider provider, Expression<Func<Task>> actionAsync, IScheduler scheduler)
  12748. {
  12749. if (provider == null)
  12750. throw new ArgumentNullException("provider");
  12751. if (actionAsync == null)
  12752. throw new ArgumentNullException("actionAsync");
  12753. if (scheduler == null)
  12754. throw new ArgumentNullException("scheduler");
  12755. return provider.CreateQuery<Unit>(
  12756. Expression.Call(
  12757. null,
  12758. #if CRIPPLED_REFLECTION
  12759. InfoOf(() => Qbservable.StartAsync(default(IQbservableProvider), default(Expression<Func<Task>>), default(IScheduler))),
  12760. #else
  12761. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12762. #endif
  12763. Expression.Constant(provider, typeof(IQbservableProvider)),
  12764. actionAsync,
  12765. Expression.Constant(scheduler, typeof(IScheduler))
  12766. )
  12767. );
  12768. }
  12769. #endif
  12770. #if !NO_TPL
  12771. /// <summary>
  12772. /// Invokes the asynchronous action, surfacing the result through an observable sequence.
  12773. /// The CancellationToken is shared by all subscriptions on the resulting observable sequence. See the remarks section for more information.
  12774. /// </summary>
  12775. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  12776. /// <param name="actionAsync">Asynchronous action to run.</param>
  12777. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12778. /// <exception cref="T:System.ArgumentNullException">
  12779. /// <paramref name="actionAsync" /> is null.</exception>
  12780. /// <remarks>
  12781. /// <list type="bullet">
  12782. /// <item>
  12783. /// <description>The action is started immediately, not during the subscription of the resulting sequence.</description>
  12784. /// </item>
  12785. /// <item>
  12786. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12787. /// </item>
  12788. /// <item>
  12789. /// <description>
  12790. /// If any subscription to the resulting sequence is disposed, the CancellationToken is set. The observer associated to the disposed
  12791. /// subscription won't see the TaskCanceledException, but other observers will. You can protect against this using the Catch operator.
  12792. /// Be careful when handing out the resulting sequence because of this behavior. The most common use is to have a single subscription
  12793. /// to the resulting sequence, which controls the CancellationToken state. Alternatively, you can control subscription behavior using
  12794. /// multicast operators.
  12795. /// </description>
  12796. /// </item>
  12797. /// </list>
  12798. /// </remarks>
  12799. public static IQbservable<Unit> StartAsync(this IQbservableProvider provider, Expression<Func<CancellationToken, Task>> actionAsync)
  12800. {
  12801. if (provider == null)
  12802. throw new ArgumentNullException("provider");
  12803. if (actionAsync == null)
  12804. throw new ArgumentNullException("actionAsync");
  12805. return provider.CreateQuery<Unit>(
  12806. Expression.Call(
  12807. null,
  12808. #if CRIPPLED_REFLECTION
  12809. InfoOf(() => Qbservable.StartAsync(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task>>))),
  12810. #else
  12811. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12812. #endif
  12813. Expression.Constant(provider, typeof(IQbservableProvider)),
  12814. actionAsync
  12815. )
  12816. );
  12817. }
  12818. #endif
  12819. #if !NO_TPL
  12820. /// <summary>
  12821. /// Invokes the asynchronous action, surfacing the result through an observable sequence.
  12822. /// The CancellationToken is shared by all subscriptions on the resulting observable sequence. See the remarks section for more information.
  12823. /// </summary>
  12824. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  12825. /// <param name="actionAsync">Asynchronous action to run.</param>
  12826. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  12827. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12828. /// <exception cref="T:System.ArgumentNullException">
  12829. /// <paramref name="actionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  12830. /// <remarks>
  12831. /// <list type="bullet">
  12832. /// <item>
  12833. /// <description>The action is started immediately, not during the subscription of the resulting sequence.</description>
  12834. /// </item>
  12835. /// <item>
  12836. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12837. /// </item>
  12838. /// <item>
  12839. /// <description>
  12840. /// If any subscription to the resulting sequence is disposed, the CancellationToken is set. The observer associated to the disposed
  12841. /// subscription won't see the TaskCanceledException, but other observers will. You can protect against this using the Catch operator.
  12842. /// Be careful when handing out the resulting sequence because of this behavior. The most common use is to have a single subscription
  12843. /// to the resulting sequence, which controls the CancellationToken state. Alternatively, you can control subscription behavior using
  12844. /// multicast operators.
  12845. /// </description>
  12846. /// </item>
  12847. /// </list>
  12848. /// </remarks>
  12849. public static IQbservable<Unit> StartAsync(this IQbservableProvider provider, Expression<Func<CancellationToken, Task>> actionAsync, IScheduler scheduler)
  12850. {
  12851. if (provider == null)
  12852. throw new ArgumentNullException("provider");
  12853. if (actionAsync == null)
  12854. throw new ArgumentNullException("actionAsync");
  12855. if (scheduler == null)
  12856. throw new ArgumentNullException("scheduler");
  12857. return provider.CreateQuery<Unit>(
  12858. Expression.Call(
  12859. null,
  12860. #if CRIPPLED_REFLECTION
  12861. InfoOf(() => Qbservable.StartAsync(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task>>), default(IScheduler))),
  12862. #else
  12863. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12864. #endif
  12865. Expression.Constant(provider, typeof(IQbservableProvider)),
  12866. actionAsync,
  12867. Expression.Constant(scheduler, typeof(IScheduler))
  12868. )
  12869. );
  12870. }
  12871. #endif
  12872. #if !NO_TPL
  12873. /// <summary>
  12874. /// Invokes the asynchronous function, surfacing the result through an observable sequence.
  12875. /// </summary>
  12876. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  12877. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  12878. /// <param name="functionAsync">Asynchronous function to run.</param>
  12879. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12880. /// <exception cref="T:System.ArgumentNullException">
  12881. /// <paramref name="functionAsync" /> is null.</exception>
  12882. /// <remarks>
  12883. /// <list type="bullet">
  12884. /// <item>
  12885. /// <description>The function is started immediately, not during the subscription of the resulting sequence.</description>
  12886. /// </item>
  12887. /// <item>
  12888. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12889. /// </item>
  12890. /// </list>
  12891. /// </remarks>
  12892. public static IQbservable<TResult> StartAsync<TResult>(this IQbservableProvider provider, Expression<Func<Task<TResult>>> functionAsync)
  12893. {
  12894. if (provider == null)
  12895. throw new ArgumentNullException("provider");
  12896. if (functionAsync == null)
  12897. throw new ArgumentNullException("functionAsync");
  12898. return provider.CreateQuery<TResult>(
  12899. Expression.Call(
  12900. null,
  12901. #if CRIPPLED_REFLECTION
  12902. InfoOf(() => Qbservable.StartAsync<TResult>(default(IQbservableProvider), default(Expression<Func<Task<TResult>>>))),
  12903. #else
  12904. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12905. #endif
  12906. Expression.Constant(provider, typeof(IQbservableProvider)),
  12907. functionAsync
  12908. )
  12909. );
  12910. }
  12911. #endif
  12912. #if !NO_TPL
  12913. /// <summary>
  12914. /// Invokes the asynchronous function, surfacing the result through an observable sequence.
  12915. /// The CancellationToken is shared by all subscriptions on the resulting observable sequence. See the remarks section for more information.
  12916. /// </summary>
  12917. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  12918. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  12919. /// <param name="functionAsync">Asynchronous function to run.</param>
  12920. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12921. /// <exception cref="T:System.ArgumentNullException">
  12922. /// <paramref name="functionAsync" /> is null.</exception>
  12923. /// <remarks>
  12924. /// <list type="bullet">
  12925. /// <item>
  12926. /// <description>The function is started immediately, not during the subscription of the resulting sequence.</description>
  12927. /// </item>
  12928. /// <item>
  12929. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12930. /// </item>
  12931. /// <item>
  12932. /// <description>
  12933. /// If any subscription to the resulting sequence is disposed, the CancellationToken is set. The observer associated to the disposed
  12934. /// subscription won't see the TaskCanceledException, but other observers will. You can protect against this using the Catch operator.
  12935. /// Be careful when handing out the resulting sequence because of this behavior. The most common use is to have a single subscription
  12936. /// to the resulting sequence, which controls the CancellationToken state. Alternatively, you can control subscription behavior using
  12937. /// multicast operators.
  12938. /// </description>
  12939. /// </item>
  12940. /// </list>
  12941. /// </remarks>
  12942. public static IQbservable<TResult> StartAsync<TResult>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<TResult>>> functionAsync)
  12943. {
  12944. if (provider == null)
  12945. throw new ArgumentNullException("provider");
  12946. if (functionAsync == null)
  12947. throw new ArgumentNullException("functionAsync");
  12948. return provider.CreateQuery<TResult>(
  12949. Expression.Call(
  12950. null,
  12951. #if CRIPPLED_REFLECTION
  12952. InfoOf(() => Qbservable.StartAsync<TResult>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<TResult>>>))),
  12953. #else
  12954. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12955. #endif
  12956. Expression.Constant(provider, typeof(IQbservableProvider)),
  12957. functionAsync
  12958. )
  12959. );
  12960. }
  12961. #endif
  12962. #if !NO_TPL
  12963. /// <summary>
  12964. /// Invokes the asynchronous function, surfacing the result through an observable sequence.
  12965. /// </summary>
  12966. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  12967. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  12968. /// <param name="functionAsync">Asynchronous function to run.</param>
  12969. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  12970. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12971. /// <exception cref="T:System.ArgumentNullException">
  12972. /// <paramref name="functionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  12973. /// <remarks>
  12974. /// <list type="bullet">
  12975. /// <item>
  12976. /// <description>The function is started immediately, not during the subscription of the resulting sequence.</description>
  12977. /// </item>
  12978. /// <item>
  12979. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12980. /// </item>
  12981. /// </list>
  12982. /// </remarks>
  12983. public static IQbservable<TResult> StartAsync<TResult>(this IQbservableProvider provider, Expression<Func<Task<TResult>>> functionAsync, IScheduler scheduler)
  12984. {
  12985. if (provider == null)
  12986. throw new ArgumentNullException("provider");
  12987. if (functionAsync == null)
  12988. throw new ArgumentNullException("functionAsync");
  12989. if (scheduler == null)
  12990. throw new ArgumentNullException("scheduler");
  12991. return provider.CreateQuery<TResult>(
  12992. Expression.Call(
  12993. null,
  12994. #if CRIPPLED_REFLECTION
  12995. InfoOf(() => Qbservable.StartAsync<TResult>(default(IQbservableProvider), default(Expression<Func<Task<TResult>>>), default(IScheduler))),
  12996. #else
  12997. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12998. #endif
  12999. Expression.Constant(provider, typeof(IQbservableProvider)),
  13000. functionAsync,
  13001. Expression.Constant(scheduler, typeof(IScheduler))
  13002. )
  13003. );
  13004. }
  13005. #endif
  13006. #if !NO_TPL
  13007. /// <summary>
  13008. /// Invokes the asynchronous function, surfacing the result through an observable sequence.
  13009. /// The CancellationToken is shared by all subscriptions on the resulting observable sequence. See the remarks section for more information.
  13010. /// </summary>
  13011. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  13012. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  13013. /// <param name="functionAsync">Asynchronous function to run.</param>
  13014. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  13015. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  13016. /// <exception cref="T:System.ArgumentNullException">
  13017. /// <paramref name="functionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  13018. /// <remarks>
  13019. /// <list type="bullet">
  13020. /// <item>
  13021. /// <description>The function is started immediately, not during the subscription of the resulting sequence.</description>
  13022. /// </item>
  13023. /// <item>
  13024. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  13025. /// </item>
  13026. /// <item>
  13027. /// <description>
  13028. /// If any subscription to the resulting sequence is disposed, the CancellationToken is set. The observer associated to the disposed
  13029. /// subscription won't see the TaskCanceledException, but other observers will. You can protect against this using the Catch operator.
  13030. /// Be careful when handing out the resulting sequence because of this behavior. The most common use is to have a single subscription
  13031. /// to the resulting sequence, which controls the CancellationToken state. Alternatively, you can control subscription behavior using
  13032. /// multicast operators.
  13033. /// </description>
  13034. /// </item>
  13035. /// </list>
  13036. /// </remarks>
  13037. public static IQbservable<TResult> StartAsync<TResult>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<TResult>>> functionAsync, IScheduler scheduler)
  13038. {
  13039. if (provider == null)
  13040. throw new ArgumentNullException("provider");
  13041. if (functionAsync == null)
  13042. throw new ArgumentNullException("functionAsync");
  13043. if (scheduler == null)
  13044. throw new ArgumentNullException("scheduler");
  13045. return provider.CreateQuery<TResult>(
  13046. Expression.Call(
  13047. null,
  13048. #if CRIPPLED_REFLECTION
  13049. InfoOf(() => Qbservable.StartAsync<TResult>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<TResult>>>), default(IScheduler))),
  13050. #else
  13051. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  13052. #endif
  13053. Expression.Constant(provider, typeof(IQbservableProvider)),
  13054. functionAsync,
  13055. Expression.Constant(scheduler, typeof(IScheduler))
  13056. )
  13057. );
  13058. }
  13059. #endif
  13060. /// <summary>
  13061. /// Prepends a sequence of values to an observable sequence.
  13062. /// </summary>
  13063. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13064. /// <param name="source">Source sequence to prepend values to.</param>
  13065. /// <param name="scheduler">Scheduler to emit the prepended values on.</param>
  13066. /// <param name="values">Values to prepend to the specified sequence.</param>
  13067. /// <returns>The source sequence prepended with the specified values.</returns>
  13068. /// <exception cref="T:System.ArgumentNullException">
  13069. /// <paramref name="source" /> or <paramref name="scheduler" /> or <paramref name="values" /> is null.</exception>
  13070. public static IQbservable<TSource> StartWith<TSource>(this IQbservable<TSource> source, IScheduler scheduler, params TSource[] values)
  13071. {
  13072. if (source == null)
  13073. throw new ArgumentNullException("source");
  13074. if (scheduler == null)
  13075. throw new ArgumentNullException("scheduler");
  13076. if (values == null)
  13077. throw new ArgumentNullException("values");
  13078. return source.Provider.CreateQuery<TSource>(
  13079. Expression.Call(
  13080. null,
  13081. #if CRIPPLED_REFLECTION
  13082. InfoOf(() => Qbservable.StartWith<TSource>(default(IQbservable<TSource>), default(IScheduler), default(TSource[]))),
  13083. #else
  13084. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13085. #endif
  13086. source.Expression,
  13087. Expression.Constant(scheduler, typeof(IScheduler)),
  13088. Expression.Constant(values, typeof(TSource[]))
  13089. )
  13090. );
  13091. }
  13092. /// <summary>
  13093. /// Prepends a sequence of values to an observable sequence.
  13094. /// </summary>
  13095. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13096. /// <param name="source">Source sequence to prepend values to.</param>
  13097. /// <param name="scheduler">Scheduler to emit the prepended values on.</param>
  13098. /// <param name="values">Values to prepend to the specified sequence.</param>
  13099. /// <returns>The source sequence prepended with the specified values.</returns>
  13100. /// <exception cref="T:System.ArgumentNullException">
  13101. /// <paramref name="source" /> or <paramref name="scheduler" /> or <paramref name="values" /> is null.</exception>
  13102. public static IQbservable<TSource> StartWith<TSource>(this IQbservable<TSource> source, IScheduler scheduler, IEnumerable<TSource> values)
  13103. {
  13104. if (source == null)
  13105. throw new ArgumentNullException("source");
  13106. if (scheduler == null)
  13107. throw new ArgumentNullException("scheduler");
  13108. if (values == null)
  13109. throw new ArgumentNullException("values");
  13110. return source.Provider.CreateQuery<TSource>(
  13111. Expression.Call(
  13112. null,
  13113. #if CRIPPLED_REFLECTION
  13114. InfoOf(() => Qbservable.StartWith<TSource>(default(IQbservable<TSource>), default(IScheduler), default(IEnumerable<TSource>))),
  13115. #else
  13116. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13117. #endif
  13118. source.Expression,
  13119. Expression.Constant(scheduler, typeof(IScheduler)),
  13120. GetSourceExpression(values)
  13121. )
  13122. );
  13123. }
  13124. /// <summary>
  13125. /// Prepends a sequence of values to an observable sequence.
  13126. /// </summary>
  13127. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13128. /// <param name="source">Source sequence to prepend values to.</param>
  13129. /// <param name="values">Values to prepend to the specified sequence.</param>
  13130. /// <returns>The source sequence prepended with the specified values.</returns>
  13131. /// <exception cref="T:System.ArgumentNullException">
  13132. /// <paramref name="source" /> or <paramref name="values" /> is null.</exception>
  13133. public static IQbservable<TSource> StartWith<TSource>(this IQbservable<TSource> source, params TSource[] values)
  13134. {
  13135. if (source == null)
  13136. throw new ArgumentNullException("source");
  13137. if (values == null)
  13138. throw new ArgumentNullException("values");
  13139. return source.Provider.CreateQuery<TSource>(
  13140. Expression.Call(
  13141. null,
  13142. #if CRIPPLED_REFLECTION
  13143. InfoOf(() => Qbservable.StartWith<TSource>(default(IQbservable<TSource>), default(TSource[]))),
  13144. #else
  13145. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13146. #endif
  13147. source.Expression,
  13148. Expression.Constant(values, typeof(TSource[]))
  13149. )
  13150. );
  13151. }
  13152. /// <summary>
  13153. /// Prepends a sequence of values to an observable sequence.
  13154. /// </summary>
  13155. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13156. /// <param name="source">Source sequence to prepend values to.</param>
  13157. /// <param name="values">Values to prepend to the specified sequence.</param>
  13158. /// <returns>The source sequence prepended with the specified values.</returns>
  13159. /// <exception cref="T:System.ArgumentNullException">
  13160. /// <paramref name="source" /> or <paramref name="values" /> is null.</exception>
  13161. public static IQbservable<TSource> StartWith<TSource>(this IQbservable<TSource> source, IEnumerable<TSource> values)
  13162. {
  13163. if (source == null)
  13164. throw new ArgumentNullException("source");
  13165. if (values == null)
  13166. throw new ArgumentNullException("values");
  13167. return source.Provider.CreateQuery<TSource>(
  13168. Expression.Call(
  13169. null,
  13170. #if CRIPPLED_REFLECTION
  13171. InfoOf(() => Qbservable.StartWith<TSource>(default(IQbservable<TSource>), default(IEnumerable<TSource>))),
  13172. #else
  13173. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13174. #endif
  13175. source.Expression,
  13176. GetSourceExpression(values)
  13177. )
  13178. );
  13179. }
  13180. /// <summary>
  13181. /// Wraps the source sequence in order to run its subscription and unsubscription logic on the specified synchronization context. This operation is not commonly used;
  13182. /// see the remarks section for more information on the distinction between SubscribeOn and ObserveOn.
  13183. /// </summary>
  13184. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13185. /// <param name="source">Source sequence.</param>
  13186. /// <param name="context">Synchronization context to perform subscription and unsubscription actions on.</param>
  13187. /// <returns>The source sequence whose subscriptions and unsubscriptions happen on the specified synchronization context.</returns>
  13188. /// <exception cref="T:System.ArgumentNullException">
  13189. /// <paramref name="source" /> or <paramref name="context" /> is null.</exception>
  13190. /// <remarks>
  13191. /// This only performs the side-effects of subscription and unsubscription on the specified synchronization context. In order to invoke observer
  13192. /// callbacks on a synchronization context, use <see cref="M:System.Reactive.Linq.Observable.ObserveOn``1(System.IObservable{``0},System.Threading.SynchronizationContext)" />.
  13193. /// </remarks>
  13194. public static IQbservable<TSource> SubscribeOn<TSource>(this IQbservable<TSource> source, SynchronizationContext context)
  13195. {
  13196. if (source == null)
  13197. throw new ArgumentNullException("source");
  13198. if (context == null)
  13199. throw new ArgumentNullException("context");
  13200. return source.Provider.CreateQuery<TSource>(
  13201. Expression.Call(
  13202. null,
  13203. #if CRIPPLED_REFLECTION
  13204. InfoOf(() => Qbservable.SubscribeOn<TSource>(default(IQbservable<TSource>), default(SynchronizationContext))),
  13205. #else
  13206. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13207. #endif
  13208. source.Expression,
  13209. Expression.Constant(context, typeof(SynchronizationContext))
  13210. )
  13211. );
  13212. }
  13213. /// <summary>
  13214. /// Wraps the source sequence in order to run its subscription and unsubscription logic on the specified scheduler. This operation is not commonly used;
  13215. /// see the remarks section for more information on the distinction between SubscribeOn and ObserveOn.
  13216. /// </summary>
  13217. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13218. /// <param name="source">Source sequence.</param>
  13219. /// <param name="scheduler">Scheduler to perform subscription and unsubscription actions on.</param>
  13220. /// <returns>The source sequence whose subscriptions and unsubscriptions happen on the specified scheduler.</returns>
  13221. /// <exception cref="T:System.ArgumentNullException">
  13222. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13223. /// <remarks>
  13224. /// This only performs the side-effects of subscription and unsubscription on the specified scheduler. In order to invoke observer
  13225. /// callbacks on a scheduler, use <see cref="M:System.Reactive.Linq.Observable.ObserveOn``1(System.IObservable{``0},System.Reactive.Concurrency.IScheduler)" />.
  13226. /// </remarks>
  13227. public static IQbservable<TSource> SubscribeOn<TSource>(this IQbservable<TSource> source, IScheduler scheduler)
  13228. {
  13229. if (source == null)
  13230. throw new ArgumentNullException("source");
  13231. if (scheduler == null)
  13232. throw new ArgumentNullException("scheduler");
  13233. return source.Provider.CreateQuery<TSource>(
  13234. Expression.Call(
  13235. null,
  13236. #if CRIPPLED_REFLECTION
  13237. InfoOf(() => Qbservable.SubscribeOn<TSource>(default(IQbservable<TSource>), default(IScheduler))),
  13238. #else
  13239. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13240. #endif
  13241. source.Expression,
  13242. Expression.Constant(scheduler, typeof(IScheduler))
  13243. )
  13244. );
  13245. }
  13246. /// <summary>
  13247. /// Computes the sum of a sequence of <see cref="T:System.Decimal" /> values.
  13248. /// </summary>
  13249. /// <param name="source">A sequence of <see cref="T:System.Decimal" /> values to calculate the sum of.</param>
  13250. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13251. /// <exception cref="T:System.ArgumentNullException">
  13252. /// <paramref name="source" /> is null.</exception>
  13253. /// <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>
  13254. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13255. public static IQbservable<decimal> Sum(this IQbservable<decimal> source)
  13256. {
  13257. if (source == null)
  13258. throw new ArgumentNullException("source");
  13259. return source.Provider.CreateQuery<decimal>(
  13260. Expression.Call(
  13261. null,
  13262. #if CRIPPLED_REFLECTION
  13263. InfoOf(() => Qbservable.Sum(default(IQbservable<decimal>))),
  13264. #else
  13265. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13266. #endif
  13267. source.Expression
  13268. )
  13269. );
  13270. }
  13271. /// <summary>
  13272. /// Computes the sum of a sequence of <see cref="T:System.Double" /> values.
  13273. /// </summary>
  13274. /// <param name="source">A sequence of <see cref="T:System.Double" /> values to calculate the sum of.</param>
  13275. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13276. /// <exception cref="T:System.ArgumentNullException">
  13277. /// <paramref name="source" /> is null.</exception>
  13278. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13279. public static IQbservable<double> Sum(this IQbservable<double> source)
  13280. {
  13281. if (source == null)
  13282. throw new ArgumentNullException("source");
  13283. return source.Provider.CreateQuery<double>(
  13284. Expression.Call(
  13285. null,
  13286. #if CRIPPLED_REFLECTION
  13287. InfoOf(() => Qbservable.Sum(default(IQbservable<double>))),
  13288. #else
  13289. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13290. #endif
  13291. source.Expression
  13292. )
  13293. );
  13294. }
  13295. /// <summary>
  13296. /// Computes the sum of a sequence of <see cref="T:System.Int32" /> values.
  13297. /// </summary>
  13298. /// <param name="source">A sequence of <see cref="T:System.Int32" /> values to calculate the sum of.</param>
  13299. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13300. /// <exception cref="T:System.ArgumentNullException">
  13301. /// <paramref name="source" /> is null.</exception>
  13302. /// <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>
  13303. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13304. public static IQbservable<int> Sum(this IQbservable<int> source)
  13305. {
  13306. if (source == null)
  13307. throw new ArgumentNullException("source");
  13308. return source.Provider.CreateQuery<int>(
  13309. Expression.Call(
  13310. null,
  13311. #if CRIPPLED_REFLECTION
  13312. InfoOf(() => Qbservable.Sum(default(IQbservable<int>))),
  13313. #else
  13314. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13315. #endif
  13316. source.Expression
  13317. )
  13318. );
  13319. }
  13320. /// <summary>
  13321. /// Computes the sum of a sequence of <see cref="T:System.Int64" /> values.
  13322. /// </summary>
  13323. /// <param name="source">A sequence of <see cref="T:System.Int64" /> values to calculate the sum of.</param>
  13324. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13325. /// <exception cref="T:System.ArgumentNullException">
  13326. /// <paramref name="source" /> is null.</exception>
  13327. /// <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>
  13328. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13329. public static IQbservable<long> Sum(this IQbservable<long> source)
  13330. {
  13331. if (source == null)
  13332. throw new ArgumentNullException("source");
  13333. return source.Provider.CreateQuery<long>(
  13334. Expression.Call(
  13335. null,
  13336. #if CRIPPLED_REFLECTION
  13337. InfoOf(() => Qbservable.Sum(default(IQbservable<long>))),
  13338. #else
  13339. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13340. #endif
  13341. source.Expression
  13342. )
  13343. );
  13344. }
  13345. /// <summary>
  13346. /// Computes the sum of a sequence of nullable <see cref="T:System.Decimal" /> values.
  13347. /// </summary>
  13348. /// <param name="source">A sequence of nullable <see cref="T:System.Decimal" /> values to calculate the sum of.</param>
  13349. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13350. /// <exception cref="T:System.ArgumentNullException">
  13351. /// <paramref name="source" /> is null.</exception>
  13352. /// <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>
  13353. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13354. public static IQbservable<decimal?> Sum(this IQbservable<decimal?> source)
  13355. {
  13356. if (source == null)
  13357. throw new ArgumentNullException("source");
  13358. return source.Provider.CreateQuery<decimal?>(
  13359. Expression.Call(
  13360. null,
  13361. #if CRIPPLED_REFLECTION
  13362. InfoOf(() => Qbservable.Sum(default(IQbservable<decimal?>))),
  13363. #else
  13364. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13365. #endif
  13366. source.Expression
  13367. )
  13368. );
  13369. }
  13370. /// <summary>
  13371. /// Computes the sum of a sequence of nullable <see cref="T:System.Double" /> values.
  13372. /// </summary>
  13373. /// <param name="source">A sequence of nullable <see cref="T:System.Double" /> values to calculate the sum of.</param>
  13374. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13375. /// <exception cref="T:System.ArgumentNullException">
  13376. /// <paramref name="source" /> is null.</exception>
  13377. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13378. public static IQbservable<double?> Sum(this IQbservable<double?> source)
  13379. {
  13380. if (source == null)
  13381. throw new ArgumentNullException("source");
  13382. return source.Provider.CreateQuery<double?>(
  13383. Expression.Call(
  13384. null,
  13385. #if CRIPPLED_REFLECTION
  13386. InfoOf(() => Qbservable.Sum(default(IQbservable<double?>))),
  13387. #else
  13388. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13389. #endif
  13390. source.Expression
  13391. )
  13392. );
  13393. }
  13394. /// <summary>
  13395. /// Computes the sum of a sequence of nullable <see cref="T:System.Int32" /> values.
  13396. /// </summary>
  13397. /// <param name="source">A sequence of nullable <see cref="T:System.Int32" /> values to calculate the sum of.</param>
  13398. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13399. /// <exception cref="T:System.ArgumentNullException">
  13400. /// <paramref name="source" /> is null.</exception>
  13401. /// <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>
  13402. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13403. public static IQbservable<int?> Sum(this IQbservable<int?> source)
  13404. {
  13405. if (source == null)
  13406. throw new ArgumentNullException("source");
  13407. return source.Provider.CreateQuery<int?>(
  13408. Expression.Call(
  13409. null,
  13410. #if CRIPPLED_REFLECTION
  13411. InfoOf(() => Qbservable.Sum(default(IQbservable<int?>))),
  13412. #else
  13413. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13414. #endif
  13415. source.Expression
  13416. )
  13417. );
  13418. }
  13419. /// <summary>
  13420. /// Computes the sum of a sequence of nullable <see cref="T:System.Int64" /> values.
  13421. /// </summary>
  13422. /// <param name="source">A sequence of nullable <see cref="T:System.Int64" /> values to calculate the sum of.</param>
  13423. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13424. /// <exception cref="T:System.ArgumentNullException">
  13425. /// <paramref name="source" /> is null.</exception>
  13426. /// <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>
  13427. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13428. public static IQbservable<long?> Sum(this IQbservable<long?> source)
  13429. {
  13430. if (source == null)
  13431. throw new ArgumentNullException("source");
  13432. return source.Provider.CreateQuery<long?>(
  13433. Expression.Call(
  13434. null,
  13435. #if CRIPPLED_REFLECTION
  13436. InfoOf(() => Qbservable.Sum(default(IQbservable<long?>))),
  13437. #else
  13438. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13439. #endif
  13440. source.Expression
  13441. )
  13442. );
  13443. }
  13444. /// <summary>
  13445. /// Computes the sum of a sequence of nullable <see cref="T:System.Single" /> values.
  13446. /// </summary>
  13447. /// <param name="source">A sequence of nullable <see cref="T:System.Single" /> values to calculate the sum of.</param>
  13448. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13449. /// <exception cref="T:System.ArgumentNullException">
  13450. /// <paramref name="source" /> is null.</exception>
  13451. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13452. public static IQbservable<float?> Sum(this IQbservable<float?> source)
  13453. {
  13454. if (source == null)
  13455. throw new ArgumentNullException("source");
  13456. return source.Provider.CreateQuery<float?>(
  13457. Expression.Call(
  13458. null,
  13459. #if CRIPPLED_REFLECTION
  13460. InfoOf(() => Qbservable.Sum(default(IQbservable<float?>))),
  13461. #else
  13462. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13463. #endif
  13464. source.Expression
  13465. )
  13466. );
  13467. }
  13468. /// <summary>
  13469. /// Computes the sum of a sequence of <see cref="T:System.Single" /> values.
  13470. /// </summary>
  13471. /// <param name="source">A sequence of <see cref="T:System.Single" /> values to calculate the sum of.</param>
  13472. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13473. /// <exception cref="T:System.ArgumentNullException">
  13474. /// <paramref name="source" /> is null.</exception>
  13475. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13476. public static IQbservable<float> Sum(this IQbservable<float> source)
  13477. {
  13478. if (source == null)
  13479. throw new ArgumentNullException("source");
  13480. return source.Provider.CreateQuery<float>(
  13481. Expression.Call(
  13482. null,
  13483. #if CRIPPLED_REFLECTION
  13484. InfoOf(() => Qbservable.Sum(default(IQbservable<float>))),
  13485. #else
  13486. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13487. #endif
  13488. source.Expression
  13489. )
  13490. );
  13491. }
  13492. /// <summary>
  13493. /// 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.
  13494. /// </summary>
  13495. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13496. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13497. /// <param name="selector">A transform function to apply to each element.</param>
  13498. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13499. /// <exception cref="T:System.ArgumentNullException">
  13500. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13501. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13502. public static IQbservable<double?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double?>> selector)
  13503. {
  13504. if (source == null)
  13505. throw new ArgumentNullException("source");
  13506. if (selector == null)
  13507. throw new ArgumentNullException("selector");
  13508. return source.Provider.CreateQuery<double?>(
  13509. Expression.Call(
  13510. null,
  13511. #if CRIPPLED_REFLECTION
  13512. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double?>>))),
  13513. #else
  13514. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13515. #endif
  13516. source.Expression,
  13517. selector
  13518. )
  13519. );
  13520. }
  13521. /// <summary>
  13522. /// 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.
  13523. /// </summary>
  13524. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13525. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13526. /// <param name="selector">A transform function to apply to each element.</param>
  13527. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13528. /// <exception cref="T:System.ArgumentNullException">
  13529. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13530. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13531. public static IQbservable<float?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float?>> selector)
  13532. {
  13533. if (source == null)
  13534. throw new ArgumentNullException("source");
  13535. if (selector == null)
  13536. throw new ArgumentNullException("selector");
  13537. return source.Provider.CreateQuery<float?>(
  13538. Expression.Call(
  13539. null,
  13540. #if CRIPPLED_REFLECTION
  13541. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float?>>))),
  13542. #else
  13543. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13544. #endif
  13545. source.Expression,
  13546. selector
  13547. )
  13548. );
  13549. }
  13550. /// <summary>
  13551. /// 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.
  13552. /// </summary>
  13553. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13554. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13555. /// <param name="selector">A transform function to apply to each element.</param>
  13556. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13557. /// <exception cref="T:System.ArgumentNullException">
  13558. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13559. /// <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>
  13560. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13561. public static IQbservable<decimal?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal?>> selector)
  13562. {
  13563. if (source == null)
  13564. throw new ArgumentNullException("source");
  13565. if (selector == null)
  13566. throw new ArgumentNullException("selector");
  13567. return source.Provider.CreateQuery<decimal?>(
  13568. Expression.Call(
  13569. null,
  13570. #if CRIPPLED_REFLECTION
  13571. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal?>>))),
  13572. #else
  13573. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13574. #endif
  13575. source.Expression,
  13576. selector
  13577. )
  13578. );
  13579. }
  13580. /// <summary>
  13581. /// 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.
  13582. /// </summary>
  13583. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13584. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13585. /// <param name="selector">A transform function to apply to each element.</param>
  13586. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13587. /// <exception cref="T:System.ArgumentNullException">
  13588. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13589. /// <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>
  13590. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13591. public static IQbservable<int?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int?>> selector)
  13592. {
  13593. if (source == null)
  13594. throw new ArgumentNullException("source");
  13595. if (selector == null)
  13596. throw new ArgumentNullException("selector");
  13597. return source.Provider.CreateQuery<int?>(
  13598. Expression.Call(
  13599. null,
  13600. #if CRIPPLED_REFLECTION
  13601. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int?>>))),
  13602. #else
  13603. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13604. #endif
  13605. source.Expression,
  13606. selector
  13607. )
  13608. );
  13609. }
  13610. /// <summary>
  13611. /// 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.
  13612. /// </summary>
  13613. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13614. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13615. /// <param name="selector">A transform function to apply to each element.</param>
  13616. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13617. /// <exception cref="T:System.ArgumentNullException">
  13618. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13619. /// <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>
  13620. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13621. public static IQbservable<long?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long?>> selector)
  13622. {
  13623. if (source == null)
  13624. throw new ArgumentNullException("source");
  13625. if (selector == null)
  13626. throw new ArgumentNullException("selector");
  13627. return source.Provider.CreateQuery<long?>(
  13628. Expression.Call(
  13629. null,
  13630. #if CRIPPLED_REFLECTION
  13631. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long?>>))),
  13632. #else
  13633. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13634. #endif
  13635. source.Expression,
  13636. selector
  13637. )
  13638. );
  13639. }
  13640. /// <summary>
  13641. /// 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.
  13642. /// </summary>
  13643. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13644. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13645. /// <param name="selector">A transform function to apply to each element.</param>
  13646. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13647. /// <exception cref="T:System.ArgumentNullException">
  13648. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13649. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13650. public static IQbservable<double> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double>> selector)
  13651. {
  13652. if (source == null)
  13653. throw new ArgumentNullException("source");
  13654. if (selector == null)
  13655. throw new ArgumentNullException("selector");
  13656. return source.Provider.CreateQuery<double>(
  13657. Expression.Call(
  13658. null,
  13659. #if CRIPPLED_REFLECTION
  13660. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double>>))),
  13661. #else
  13662. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13663. #endif
  13664. source.Expression,
  13665. selector
  13666. )
  13667. );
  13668. }
  13669. /// <summary>
  13670. /// 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.
  13671. /// </summary>
  13672. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13673. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13674. /// <param name="selector">A transform function to apply to each element.</param>
  13675. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13676. /// <exception cref="T:System.ArgumentNullException">
  13677. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13678. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13679. public static IQbservable<float> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float>> selector)
  13680. {
  13681. if (source == null)
  13682. throw new ArgumentNullException("source");
  13683. if (selector == null)
  13684. throw new ArgumentNullException("selector");
  13685. return source.Provider.CreateQuery<float>(
  13686. Expression.Call(
  13687. null,
  13688. #if CRIPPLED_REFLECTION
  13689. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float>>))),
  13690. #else
  13691. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13692. #endif
  13693. source.Expression,
  13694. selector
  13695. )
  13696. );
  13697. }
  13698. /// <summary>
  13699. /// 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.
  13700. /// </summary>
  13701. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13702. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13703. /// <param name="selector">A transform function to apply to each element.</param>
  13704. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13705. /// <exception cref="T:System.ArgumentNullException">
  13706. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13707. /// <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>
  13708. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13709. public static IQbservable<decimal> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal>> selector)
  13710. {
  13711. if (source == null)
  13712. throw new ArgumentNullException("source");
  13713. if (selector == null)
  13714. throw new ArgumentNullException("selector");
  13715. return source.Provider.CreateQuery<decimal>(
  13716. Expression.Call(
  13717. null,
  13718. #if CRIPPLED_REFLECTION
  13719. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal>>))),
  13720. #else
  13721. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13722. #endif
  13723. source.Expression,
  13724. selector
  13725. )
  13726. );
  13727. }
  13728. /// <summary>
  13729. /// 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.
  13730. /// </summary>
  13731. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13732. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13733. /// <param name="selector">A transform function to apply to each element.</param>
  13734. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13735. /// <exception cref="T:System.ArgumentNullException">
  13736. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13737. /// <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>
  13738. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13739. public static IQbservable<int> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int>> selector)
  13740. {
  13741. if (source == null)
  13742. throw new ArgumentNullException("source");
  13743. if (selector == null)
  13744. throw new ArgumentNullException("selector");
  13745. return source.Provider.CreateQuery<int>(
  13746. Expression.Call(
  13747. null,
  13748. #if CRIPPLED_REFLECTION
  13749. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int>>))),
  13750. #else
  13751. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13752. #endif
  13753. source.Expression,
  13754. selector
  13755. )
  13756. );
  13757. }
  13758. /// <summary>
  13759. /// 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.
  13760. /// </summary>
  13761. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13762. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13763. /// <param name="selector">A transform function to apply to each element.</param>
  13764. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13765. /// <exception cref="T:System.ArgumentNullException">
  13766. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13767. /// <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>
  13768. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13769. public static IQbservable<long> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long>> selector)
  13770. {
  13771. if (source == null)
  13772. throw new ArgumentNullException("source");
  13773. if (selector == null)
  13774. throw new ArgumentNullException("selector");
  13775. return source.Provider.CreateQuery<long>(
  13776. Expression.Call(
  13777. null,
  13778. #if CRIPPLED_REFLECTION
  13779. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long>>))),
  13780. #else
  13781. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13782. #endif
  13783. source.Expression,
  13784. selector
  13785. )
  13786. );
  13787. }
  13788. /// <summary>
  13789. /// Transforms an observable sequence of observable sequences into an observable sequence
  13790. /// producing values only from the most recent observable sequence.
  13791. /// Each time a new inner observable sequence is received, unsubscribe from the
  13792. /// previous inner observable sequence.
  13793. /// </summary>
  13794. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  13795. /// <param name="sources">Observable sequence of inner observable sequences.</param>
  13796. /// <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>
  13797. /// <exception cref="T:System.ArgumentNullException">
  13798. /// <paramref name="sources" /> is null.</exception>
  13799. public static IQbservable<TSource> Switch<TSource>(this IQbservable<IObservable<TSource>> sources)
  13800. {
  13801. if (sources == null)
  13802. throw new ArgumentNullException("sources");
  13803. return sources.Provider.CreateQuery<TSource>(
  13804. Expression.Call(
  13805. null,
  13806. #if CRIPPLED_REFLECTION
  13807. InfoOf(() => Qbservable.Switch<TSource>(default(IQbservable<IObservable<TSource>>))),
  13808. #else
  13809. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13810. #endif
  13811. sources.Expression
  13812. )
  13813. );
  13814. }
  13815. #if !NO_TPL
  13816. /// <summary>
  13817. /// Transforms an observable sequence of tasks into an observable sequence
  13818. /// producing values only from the most recent observable sequence.
  13819. /// Each time a new task is received, the previous task's result is ignored.
  13820. /// </summary>
  13821. /// <typeparam name="TSource">The type of the results produced by the source tasks.</typeparam>
  13822. /// <param name="sources">Observable sequence of tasks.</param>
  13823. /// <returns>The observable sequence that at any point in time produces the result of the most recent task that has been received.</returns>
  13824. /// <exception cref="T:System.ArgumentNullException">
  13825. /// <paramref name="sources" /> is null.</exception>
  13826. /// <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>
  13827. public static IQbservable<TSource> Switch<TSource>(this IQbservable<Task<TSource>> sources)
  13828. {
  13829. if (sources == null)
  13830. throw new ArgumentNullException("sources");
  13831. return sources.Provider.CreateQuery<TSource>(
  13832. Expression.Call(
  13833. null,
  13834. #if CRIPPLED_REFLECTION
  13835. InfoOf(() => Qbservable.Switch<TSource>(default(IQbservable<Task<TSource>>))),
  13836. #else
  13837. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13838. #endif
  13839. sources.Expression
  13840. )
  13841. );
  13842. }
  13843. #endif
  13844. /// <summary>
  13845. /// Synchronizes the observable sequence such that observer notifications cannot be delivered concurrently.
  13846. /// This overload is useful to "fix" an observable sequence that exhibits concurrent callbacks on individual observers, which is invalid behavior for the query processor.
  13847. /// </summary>
  13848. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13849. /// <param name="source">Source sequence.</param>
  13850. /// <returns>The source sequence whose outgoing calls to observers are synchronized.</returns>
  13851. /// <exception cref="T:System.ArgumentNullException">
  13852. /// <paramref name="source" /> is null.</exception>
  13853. /// <remarks>
  13854. /// It's invalid behavior - according to the observer grammar - for a sequence to exhibit concurrent callbacks on a given observer.
  13855. /// This operator can be used to "fix" a source that doesn't conform to this rule.
  13856. /// </remarks>
  13857. public static IQbservable<TSource> Synchronize<TSource>(this IQbservable<TSource> source)
  13858. {
  13859. if (source == null)
  13860. throw new ArgumentNullException("source");
  13861. return source.Provider.CreateQuery<TSource>(
  13862. Expression.Call(
  13863. null,
  13864. #if CRIPPLED_REFLECTION
  13865. InfoOf(() => Qbservable.Synchronize<TSource>(default(IQbservable<TSource>))),
  13866. #else
  13867. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13868. #endif
  13869. source.Expression
  13870. )
  13871. );
  13872. }
  13873. /// <summary>
  13874. /// Synchronizes the observable sequence such that observer notifications cannot be delivered concurrently, using the specified gate object.
  13875. /// 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.
  13876. /// </summary>
  13877. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13878. /// <param name="source">Source sequence.</param>
  13879. /// <param name="gate">Gate object to synchronize each observer call on.</param>
  13880. /// <returns>The source sequence whose outgoing calls to observers are synchronized on the given gate object.</returns>
  13881. /// <exception cref="T:System.ArgumentNullException">
  13882. /// <paramref name="source" /> or <paramref name="gate" /> is null.</exception>
  13883. public static IQbservable<TSource> Synchronize<TSource>(this IQbservable<TSource> source, object gate)
  13884. {
  13885. if (source == null)
  13886. throw new ArgumentNullException("source");
  13887. if (gate == null)
  13888. throw new ArgumentNullException("gate");
  13889. return source.Provider.CreateQuery<TSource>(
  13890. Expression.Call(
  13891. null,
  13892. #if CRIPPLED_REFLECTION
  13893. InfoOf(() => Qbservable.Synchronize<TSource>(default(IQbservable<TSource>), default(object))),
  13894. #else
  13895. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13896. #endif
  13897. source.Expression,
  13898. Expression.Constant(gate, typeof(object))
  13899. )
  13900. );
  13901. }
  13902. /// <summary>
  13903. /// Returns a specified number of contiguous elements from the start of an observable sequence.
  13904. /// </summary>
  13905. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13906. /// <param name="source">The sequence to take elements from.</param>
  13907. /// <param name="count">The number of elements to return.</param>
  13908. /// <returns>An observable sequence that contains the specified number of elements from the start of the input sequence.</returns>
  13909. /// <exception cref="T:System.ArgumentNullException">
  13910. /// <paramref name="source" /> is null.</exception>
  13911. /// <exception cref="T:System.ArgumentOutOfRangeException">
  13912. /// <paramref name="count" /> is less than zero.</exception>
  13913. public static IQbservable<TSource> Take<TSource>(this IQbservable<TSource> source, int count)
  13914. {
  13915. if (source == null)
  13916. throw new ArgumentNullException("source");
  13917. return source.Provider.CreateQuery<TSource>(
  13918. Expression.Call(
  13919. null,
  13920. #if CRIPPLED_REFLECTION
  13921. InfoOf(() => Qbservable.Take<TSource>(default(IQbservable<TSource>), default(int))),
  13922. #else
  13923. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13924. #endif
  13925. source.Expression,
  13926. Expression.Constant(count, typeof(int))
  13927. )
  13928. );
  13929. }
  13930. /// <summary>
  13931. /// 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).
  13932. /// </summary>
  13933. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13934. /// <param name="source">The sequence to take elements from.</param>
  13935. /// <param name="count">The number of elements to return.</param>
  13936. /// <param name="scheduler">Scheduler used to produce an OnCompleted message in case <paramref name="count">count</paramref> is set to 0.</param>
  13937. /// <returns>An observable sequence that contains the specified number of elements from the start of the input sequence.</returns>
  13938. /// <exception cref="T:System.ArgumentNullException">
  13939. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13940. /// <exception cref="T:System.ArgumentOutOfRangeException">
  13941. /// <paramref name="count" /> is less than zero.</exception>
  13942. public static IQbservable<TSource> Take<TSource>(this IQbservable<TSource> source, int count, IScheduler scheduler)
  13943. {
  13944. if (source == null)
  13945. throw new ArgumentNullException("source");
  13946. if (scheduler == null)
  13947. throw new ArgumentNullException("scheduler");
  13948. return source.Provider.CreateQuery<TSource>(
  13949. Expression.Call(
  13950. null,
  13951. #if CRIPPLED_REFLECTION
  13952. InfoOf(() => Qbservable.Take<TSource>(default(IQbservable<TSource>), default(int), default(IScheduler))),
  13953. #else
  13954. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13955. #endif
  13956. source.Expression,
  13957. Expression.Constant(count, typeof(int)),
  13958. Expression.Constant(scheduler, typeof(IScheduler))
  13959. )
  13960. );
  13961. }
  13962. /// <summary>
  13963. /// Takes elements for the specified duration from the start of the observable source sequence.
  13964. /// </summary>
  13965. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13966. /// <param name="source">Source sequence to take elements from.</param>
  13967. /// <param name="duration">Duration for taking elements from the start of the sequence.</param>
  13968. /// <returns>An observable sequence with the elements taken during the specified duration from the start of the source sequence.</returns>
  13969. /// <exception cref="T:System.ArgumentNullException">
  13970. /// <paramref name="source" /> is null.</exception>
  13971. /// <exception cref="T:System.ArgumentOutOfRangeException">
  13972. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  13973. /// <remarks>
  13974. /// Specifying a TimeSpan.Zero value for <paramref name="duration" /> doesn't guarantee an empty sequence will be returned. This is a side-effect
  13975. /// of the asynchrony introduced by the scheduler, where the action that stops forwarding callbacks from the source sequence may not execute
  13976. /// immediately, despite the TimeSpan.Zero due time.
  13977. /// </remarks>
  13978. public static IQbservable<TSource> Take<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  13979. {
  13980. if (source == null)
  13981. throw new ArgumentNullException("source");
  13982. return source.Provider.CreateQuery<TSource>(
  13983. Expression.Call(
  13984. null,
  13985. #if CRIPPLED_REFLECTION
  13986. InfoOf(() => Qbservable.Take<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  13987. #else
  13988. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13989. #endif
  13990. source.Expression,
  13991. Expression.Constant(duration, typeof(TimeSpan))
  13992. )
  13993. );
  13994. }
  13995. /// <summary>
  13996. /// Takes elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers.
  13997. /// </summary>
  13998. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13999. /// <param name="source">Source sequence to take elements from.</param>
  14000. /// <param name="duration">Duration for taking elements from the start of the sequence.</param>
  14001. /// <param name="scheduler">Scheduler to run the timer on.</param>
  14002. /// <returns>An observable sequence with the elements taken during the specified duration from the start of the source sequence.</returns>
  14003. /// <exception cref="T:System.ArgumentNullException">
  14004. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14005. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14006. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  14007. /// <remarks>
  14008. /// Specifying a TimeSpan.Zero value for <paramref name="duration" /> doesn't guarantee an empty sequence will be returned. This is a side-effect
  14009. /// of the asynchrony introduced by the scheduler, where the action that stops forwarding callbacks from the source sequence may not execute
  14010. /// immediately, despite the TimeSpan.Zero due time.
  14011. /// </remarks>
  14012. public static IQbservable<TSource> Take<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  14013. {
  14014. if (source == null)
  14015. throw new ArgumentNullException("source");
  14016. if (scheduler == null)
  14017. throw new ArgumentNullException("scheduler");
  14018. return source.Provider.CreateQuery<TSource>(
  14019. Expression.Call(
  14020. null,
  14021. #if CRIPPLED_REFLECTION
  14022. InfoOf(() => Qbservable.Take<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  14023. #else
  14024. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14025. #endif
  14026. source.Expression,
  14027. Expression.Constant(duration, typeof(TimeSpan)),
  14028. Expression.Constant(scheduler, typeof(IScheduler))
  14029. )
  14030. );
  14031. }
  14032. /// <summary>
  14033. /// Returns a specified number of contiguous elements from the end of an observable sequence.
  14034. /// </summary>
  14035. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14036. /// <param name="source">Source sequence.</param>
  14037. /// <param name="count">Number of elements to take from the end of the source sequence.</param>
  14038. /// <returns>An observable sequence containing the specified number of elements from the end of the source sequence.</returns>
  14039. /// <exception cref="T:System.ArgumentNullException">
  14040. /// <paramref name="source" /> is null.</exception>
  14041. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14042. /// <paramref name="count" /> is less than zero.</exception>
  14043. /// <remarks>
  14044. /// This operator accumulates a buffer with a length enough to store elements <paramref name="count" /> elements. Upon completion of
  14045. /// the source sequence, this buffer is drained on the result sequence. This causes the elements to be delayed.
  14046. /// </remarks>
  14047. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, int count)
  14048. {
  14049. if (source == null)
  14050. throw new ArgumentNullException("source");
  14051. return source.Provider.CreateQuery<TSource>(
  14052. Expression.Call(
  14053. null,
  14054. #if CRIPPLED_REFLECTION
  14055. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(int))),
  14056. #else
  14057. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14058. #endif
  14059. source.Expression,
  14060. Expression.Constant(count, typeof(int))
  14061. )
  14062. );
  14063. }
  14064. /// <summary>
  14065. /// Returns a specified number of contiguous elements from the end of an observable sequence, using the specified scheduler to drain the queue.
  14066. /// </summary>
  14067. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14068. /// <param name="source">Source sequence.</param>
  14069. /// <param name="count">Number of elements to take from the end of the source sequence.</param>
  14070. /// <param name="scheduler">Scheduler used to drain the queue upon completion of the source sequence.</param>
  14071. /// <returns>An observable sequence containing the specified number of elements from the end of the source sequence.</returns>
  14072. /// <exception cref="T:System.ArgumentNullException">
  14073. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14074. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14075. /// <paramref name="count" /> is less than zero.</exception>
  14076. /// <remarks>
  14077. /// This operator accumulates a buffer with a length enough to store elements <paramref name="count" /> elements. Upon completion of
  14078. /// the source sequence, this buffer is drained on the result sequence. This causes the elements to be delayed.
  14079. /// </remarks>
  14080. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, int count, IScheduler scheduler)
  14081. {
  14082. if (source == null)
  14083. throw new ArgumentNullException("source");
  14084. if (scheduler == null)
  14085. throw new ArgumentNullException("scheduler");
  14086. return source.Provider.CreateQuery<TSource>(
  14087. Expression.Call(
  14088. null,
  14089. #if CRIPPLED_REFLECTION
  14090. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(int), default(IScheduler))),
  14091. #else
  14092. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14093. #endif
  14094. source.Expression,
  14095. Expression.Constant(count, typeof(int)),
  14096. Expression.Constant(scheduler, typeof(IScheduler))
  14097. )
  14098. );
  14099. }
  14100. /// <summary>
  14101. /// Returns elements within the specified duration from the end of the observable source sequence.
  14102. /// </summary>
  14103. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14104. /// <param name="source">Source sequence to take elements from.</param>
  14105. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  14106. /// <returns>An observable sequence with the elements taken during the specified duration from the end of the source sequence.</returns>
  14107. /// <exception cref="T:System.ArgumentNullException">
  14108. /// <paramref name="source" /> is null.</exception>
  14109. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14110. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  14111. /// <remarks>
  14112. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  14113. /// the source sequence. Upon completion of the source sequence, this buffer is drained on the result sequence. This causes the result elements
  14114. /// to be delayed with <paramref name="duration" />.
  14115. /// </remarks>
  14116. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  14117. {
  14118. if (source == null)
  14119. throw new ArgumentNullException("source");
  14120. return source.Provider.CreateQuery<TSource>(
  14121. Expression.Call(
  14122. null,
  14123. #if CRIPPLED_REFLECTION
  14124. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  14125. #else
  14126. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14127. #endif
  14128. source.Expression,
  14129. Expression.Constant(duration, typeof(TimeSpan))
  14130. )
  14131. );
  14132. }
  14133. /// <summary>
  14134. /// Returns elements within the specified duration from the end of the observable source sequence, using the specified scheduler to run timers.
  14135. /// </summary>
  14136. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14137. /// <param name="source">Source sequence to take elements from.</param>
  14138. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  14139. /// <param name="scheduler">Scheduler to run the timer on.</param>
  14140. /// <returns>An observable sequence with the elements taken during the specified duration from the end of the source sequence.</returns>
  14141. /// <exception cref="T:System.ArgumentNullException">
  14142. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14143. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14144. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  14145. /// <remarks>
  14146. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  14147. /// the source sequence. Upon completion of the source sequence, this buffer is drained on the result sequence. This causes the result elements
  14148. /// to be delayed with <paramref name="duration" />.
  14149. /// </remarks>
  14150. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  14151. {
  14152. if (source == null)
  14153. throw new ArgumentNullException("source");
  14154. if (scheduler == null)
  14155. throw new ArgumentNullException("scheduler");
  14156. return source.Provider.CreateQuery<TSource>(
  14157. Expression.Call(
  14158. null,
  14159. #if CRIPPLED_REFLECTION
  14160. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  14161. #else
  14162. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14163. #endif
  14164. source.Expression,
  14165. Expression.Constant(duration, typeof(TimeSpan)),
  14166. Expression.Constant(scheduler, typeof(IScheduler))
  14167. )
  14168. );
  14169. }
  14170. /// <summary>
  14171. /// 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.
  14172. /// </summary>
  14173. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14174. /// <param name="source">Source sequence to take elements from.</param>
  14175. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  14176. /// <param name="timerScheduler">Scheduler to run the timer on.</param>
  14177. /// <param name="loopScheduler">Scheduler to drain the collected elements.</param>
  14178. /// <returns>An observable sequence with the elements taken during the specified duration from the end of the source sequence.</returns>
  14179. /// <exception cref="T:System.ArgumentNullException">
  14180. /// <paramref name="source" /> or <paramref name="timerScheduler" /> or <paramref name="loopScheduler" /> is null.</exception>
  14181. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14182. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  14183. /// <remarks>
  14184. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  14185. /// the source sequence. Upon completion of the source sequence, this buffer is drained on the result sequence. This causes the result elements
  14186. /// to be delayed with <paramref name="duration" />.
  14187. /// </remarks>
  14188. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler timerScheduler, IScheduler loopScheduler)
  14189. {
  14190. if (source == null)
  14191. throw new ArgumentNullException("source");
  14192. if (timerScheduler == null)
  14193. throw new ArgumentNullException("timerScheduler");
  14194. if (loopScheduler == null)
  14195. throw new ArgumentNullException("loopScheduler");
  14196. return source.Provider.CreateQuery<TSource>(
  14197. Expression.Call(
  14198. null,
  14199. #if CRIPPLED_REFLECTION
  14200. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler), default(IScheduler))),
  14201. #else
  14202. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14203. #endif
  14204. source.Expression,
  14205. Expression.Constant(duration, typeof(TimeSpan)),
  14206. Expression.Constant(timerScheduler, typeof(IScheduler)),
  14207. Expression.Constant(loopScheduler, typeof(IScheduler))
  14208. )
  14209. );
  14210. }
  14211. /// <summary>
  14212. /// Returns a list with the specified number of contiguous elements from the end of an observable sequence.
  14213. /// </summary>
  14214. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14215. /// <param name="source">Source sequence.</param>
  14216. /// <param name="count">Number of elements to take from the end of the source sequence.</param>
  14217. /// <returns>An observable sequence containing a single list with the specified number of elements from the end of the source sequence.</returns>
  14218. /// <exception cref="T:System.ArgumentNullException">
  14219. /// <paramref name="source" /> is null.</exception>
  14220. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14221. /// <paramref name="count" /> is less than zero.</exception>
  14222. /// <remarks>
  14223. /// This operator accumulates a buffer with a length enough to store <paramref name="count" /> elements. Upon completion of the
  14224. /// source sequence, this buffer is produced on the result sequence.
  14225. /// </remarks>
  14226. public static IQbservable<IList<TSource>> TakeLastBuffer<TSource>(this IQbservable<TSource> source, int count)
  14227. {
  14228. if (source == null)
  14229. throw new ArgumentNullException("source");
  14230. return source.Provider.CreateQuery<IList<TSource>>(
  14231. Expression.Call(
  14232. null,
  14233. #if CRIPPLED_REFLECTION
  14234. InfoOf(() => Qbservable.TakeLastBuffer<TSource>(default(IQbservable<TSource>), default(int))),
  14235. #else
  14236. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14237. #endif
  14238. source.Expression,
  14239. Expression.Constant(count, typeof(int))
  14240. )
  14241. );
  14242. }
  14243. /// <summary>
  14244. /// Returns a list with the elements within the specified duration from the end of the observable source sequence.
  14245. /// </summary>
  14246. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14247. /// <param name="source">Source sequence to take elements from.</param>
  14248. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  14249. /// <returns>An observable sequence containing a single list with the elements taken during the specified duration from the end of the source sequence.</returns>
  14250. /// <exception cref="T:System.ArgumentNullException">
  14251. /// <paramref name="source" /> is null.</exception>
  14252. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14253. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  14254. /// <remarks>
  14255. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  14256. /// the source sequence. Upon completion of the source sequence, this buffer is produced on the result sequence.
  14257. /// </remarks>
  14258. public static IQbservable<IList<TSource>> TakeLastBuffer<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  14259. {
  14260. if (source == null)
  14261. throw new ArgumentNullException("source");
  14262. return source.Provider.CreateQuery<IList<TSource>>(
  14263. Expression.Call(
  14264. null,
  14265. #if CRIPPLED_REFLECTION
  14266. InfoOf(() => Qbservable.TakeLastBuffer<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  14267. #else
  14268. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14269. #endif
  14270. source.Expression,
  14271. Expression.Constant(duration, typeof(TimeSpan))
  14272. )
  14273. );
  14274. }
  14275. /// <summary>
  14276. /// 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.
  14277. /// </summary>
  14278. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14279. /// <param name="source">Source sequence to take elements from.</param>
  14280. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  14281. /// <param name="scheduler">Scheduler to run the timer on.</param>
  14282. /// <returns>An observable sequence containing a single list with the elements taken during the specified duration from the end of the source sequence.</returns>
  14283. /// <exception cref="T:System.ArgumentNullException">
  14284. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14285. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14286. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  14287. /// <remarks>
  14288. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  14289. /// the source sequence. Upon completion of the source sequence, this buffer is produced on the result sequence.
  14290. /// </remarks>
  14291. public static IQbservable<IList<TSource>> TakeLastBuffer<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  14292. {
  14293. if (source == null)
  14294. throw new ArgumentNullException("source");
  14295. if (scheduler == null)
  14296. throw new ArgumentNullException("scheduler");
  14297. return source.Provider.CreateQuery<IList<TSource>>(
  14298. Expression.Call(
  14299. null,
  14300. #if CRIPPLED_REFLECTION
  14301. InfoOf(() => Qbservable.TakeLastBuffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  14302. #else
  14303. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14304. #endif
  14305. source.Expression,
  14306. Expression.Constant(duration, typeof(TimeSpan)),
  14307. Expression.Constant(scheduler, typeof(IScheduler))
  14308. )
  14309. );
  14310. }
  14311. /// <summary>
  14312. /// Takes elements for the specified duration until the specified end time.
  14313. /// </summary>
  14314. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14315. /// <param name="source">Source sequence to take elements from.</param>
  14316. /// <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>
  14317. /// <returns>An observable sequence with the elements taken until the specified end time.</returns>
  14318. /// <exception cref="T:System.ArgumentNullException">
  14319. /// <paramref name="source" /> is null.</exception>
  14320. public static IQbservable<TSource> TakeUntil<TSource>(this IQbservable<TSource> source, DateTimeOffset endTime)
  14321. {
  14322. if (source == null)
  14323. throw new ArgumentNullException("source");
  14324. return source.Provider.CreateQuery<TSource>(
  14325. Expression.Call(
  14326. null,
  14327. #if CRIPPLED_REFLECTION
  14328. InfoOf(() => Qbservable.TakeUntil<TSource>(default(IQbservable<TSource>), default(DateTimeOffset))),
  14329. #else
  14330. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14331. #endif
  14332. source.Expression,
  14333. Expression.Constant(endTime, typeof(DateTimeOffset))
  14334. )
  14335. );
  14336. }
  14337. /// <summary>
  14338. /// Takes elements for the specified duration until the specified end time, using the specified scheduler to run timers.
  14339. /// </summary>
  14340. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14341. /// <param name="source">Source sequence to take elements from.</param>
  14342. /// <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>
  14343. /// <param name="scheduler">Scheduler to run the timer on.</param>
  14344. /// <returns>An observable sequence with the elements taken until the specified end time.</returns>
  14345. /// <exception cref="T:System.ArgumentNullException">
  14346. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14347. public static IQbservable<TSource> TakeUntil<TSource>(this IQbservable<TSource> source, DateTimeOffset endTime, IScheduler scheduler)
  14348. {
  14349. if (source == null)
  14350. throw new ArgumentNullException("source");
  14351. if (scheduler == null)
  14352. throw new ArgumentNullException("scheduler");
  14353. return source.Provider.CreateQuery<TSource>(
  14354. Expression.Call(
  14355. null,
  14356. #if CRIPPLED_REFLECTION
  14357. InfoOf(() => Qbservable.TakeUntil<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IScheduler))),
  14358. #else
  14359. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14360. #endif
  14361. source.Expression,
  14362. Expression.Constant(endTime, typeof(DateTimeOffset)),
  14363. Expression.Constant(scheduler, typeof(IScheduler))
  14364. )
  14365. );
  14366. }
  14367. /// <summary>
  14368. /// Returns the elements from the source observable sequence until the other observable sequence produces an element.
  14369. /// </summary>
  14370. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14371. /// <typeparam name="TOther">The type of the elements in the other sequence that indicates the end of take behavior.</typeparam>
  14372. /// <param name="source">Source sequence to propagate elements for.</param>
  14373. /// <param name="other">Observable sequence that terminates propagation of elements of the source sequence.</param>
  14374. /// <returns>An observable sequence containing the elements of the source sequence up to the point the other sequence interrupted further propagation.</returns>
  14375. /// <exception cref="T:System.ArgumentNullException">
  14376. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  14377. public static IQbservable<TSource> TakeUntil<TSource, TOther>(this IQbservable<TSource> source, IObservable<TOther> other)
  14378. {
  14379. if (source == null)
  14380. throw new ArgumentNullException("source");
  14381. if (other == null)
  14382. throw new ArgumentNullException("other");
  14383. return source.Provider.CreateQuery<TSource>(
  14384. Expression.Call(
  14385. null,
  14386. #if CRIPPLED_REFLECTION
  14387. InfoOf(() => Qbservable.TakeUntil<TSource, TOther>(default(IQbservable<TSource>), default(IObservable<TOther>))),
  14388. #else
  14389. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)),
  14390. #endif
  14391. source.Expression,
  14392. GetSourceExpression(other)
  14393. )
  14394. );
  14395. }
  14396. /// <summary>
  14397. /// Returns elements from an observable sequence as long as a specified condition is true.
  14398. /// </summary>
  14399. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14400. /// <param name="source">A sequence to return elements from.</param>
  14401. /// <param name="predicate">A function to test each element for a condition.</param>
  14402. /// <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>
  14403. /// <exception cref="T:System.ArgumentNullException">
  14404. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  14405. public static IQbservable<TSource> TakeWhile<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  14406. {
  14407. if (source == null)
  14408. throw new ArgumentNullException("source");
  14409. if (predicate == null)
  14410. throw new ArgumentNullException("predicate");
  14411. return source.Provider.CreateQuery<TSource>(
  14412. Expression.Call(
  14413. null,
  14414. #if CRIPPLED_REFLECTION
  14415. InfoOf(() => Qbservable.TakeWhile<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  14416. #else
  14417. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14418. #endif
  14419. source.Expression,
  14420. predicate
  14421. )
  14422. );
  14423. }
  14424. /// <summary>
  14425. /// Returns elements from an observable sequence as long as a specified condition is true.
  14426. /// The element's index is used in the logic of the predicate function.
  14427. /// </summary>
  14428. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14429. /// <param name="source">A sequence to return elements from.</param>
  14430. /// <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>
  14431. /// <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>
  14432. /// <exception cref="T:System.ArgumentNullException">
  14433. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  14434. public static IQbservable<TSource> TakeWhile<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int, bool>> predicate)
  14435. {
  14436. if (source == null)
  14437. throw new ArgumentNullException("source");
  14438. if (predicate == null)
  14439. throw new ArgumentNullException("predicate");
  14440. return source.Provider.CreateQuery<TSource>(
  14441. Expression.Call(
  14442. null,
  14443. #if CRIPPLED_REFLECTION
  14444. InfoOf(() => Qbservable.TakeWhile<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, bool>>))),
  14445. #else
  14446. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14447. #endif
  14448. source.Expression,
  14449. predicate
  14450. )
  14451. );
  14452. }
  14453. /// <summary>
  14454. /// Ignores elements from an observable sequence which are followed by another element within a specified relative time duration.
  14455. /// </summary>
  14456. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14457. /// <param name="source">Source sequence to throttle.</param>
  14458. /// <param name="dueTime">Throttling duration for each element.</param>
  14459. /// <returns>The throttled sequence.</returns>
  14460. /// <exception cref="T:System.ArgumentNullException">
  14461. /// <paramref name="source" /> is null.</exception>
  14462. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14463. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14464. /// <remarks>
  14465. /// <para>
  14466. /// This operator throttles the source sequence by holding on to each element for the duration specified in <paramref name="dueTime" />. If another
  14467. /// element is produced within this time window, the element is dropped and a new timer is started for the current element, repeating this whole
  14468. /// process. For streams that never have gaps larger than or equal to <paramref name="dueTime" /> between elements, the resulting stream won't
  14469. /// produce any elements. In order to reduce the volume of a stream whilst guaranteeing the periodic production of elements, consider using the
  14470. /// Observable.Sample set of operators.
  14471. /// </para>
  14472. /// <para>
  14473. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing throttling timers to be scheduled
  14474. /// 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
  14475. /// asynchrony introduced by the scheduler, where the action to forward the current element may not execute immediately, despite the TimeSpan.Zero
  14476. /// due time. In such cases, the next element may arrive before the scheduler gets a chance to run the throttling action.
  14477. /// </para>
  14478. /// </remarks>
  14479. public static IQbservable<TSource> Throttle<TSource>(this IQbservable<TSource> source, TimeSpan dueTime)
  14480. {
  14481. if (source == null)
  14482. throw new ArgumentNullException("source");
  14483. return source.Provider.CreateQuery<TSource>(
  14484. Expression.Call(
  14485. null,
  14486. #if CRIPPLED_REFLECTION
  14487. InfoOf(() => Qbservable.Throttle<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  14488. #else
  14489. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14490. #endif
  14491. source.Expression,
  14492. Expression.Constant(dueTime, typeof(TimeSpan))
  14493. )
  14494. );
  14495. }
  14496. /// <summary>
  14497. /// 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.
  14498. /// </summary>
  14499. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14500. /// <param name="source">Source sequence to throttle.</param>
  14501. /// <param name="dueTime">Throttling duration for each element.</param>
  14502. /// <param name="scheduler">Scheduler to run the throttle timers on.</param>
  14503. /// <returns>The throttled sequence.</returns>
  14504. /// <exception cref="T:System.ArgumentNullException">
  14505. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14506. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14507. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14508. /// <remarks>
  14509. /// <para>
  14510. /// This operator throttles the source sequence by holding on to each element for the duration specified in <paramref name="dueTime" />. If another
  14511. /// element is produced within this time window, the element is dropped and a new timer is started for the current element, repeating this whole
  14512. /// process. For streams that never have gaps larger than or equal to <paramref name="dueTime" /> between elements, the resulting stream won't
  14513. /// produce any elements. In order to reduce the volume of a stream whilst guaranteeing the periodic production of elements, consider using the
  14514. /// Observable.Sample set of operators.
  14515. /// </para>
  14516. /// <para>
  14517. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing throttling timers to be scheduled
  14518. /// 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
  14519. /// asynchrony introduced by the scheduler, where the action to forward the current element may not execute immediately, despite the TimeSpan.Zero
  14520. /// due time. In such cases, the next element may arrive before the scheduler gets a chance to run the throttling action.
  14521. /// </para>
  14522. /// </remarks>
  14523. public static IQbservable<TSource> Throttle<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IScheduler scheduler)
  14524. {
  14525. if (source == null)
  14526. throw new ArgumentNullException("source");
  14527. if (scheduler == null)
  14528. throw new ArgumentNullException("scheduler");
  14529. return source.Provider.CreateQuery<TSource>(
  14530. Expression.Call(
  14531. null,
  14532. #if CRIPPLED_REFLECTION
  14533. InfoOf(() => Qbservable.Throttle<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  14534. #else
  14535. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14536. #endif
  14537. source.Expression,
  14538. Expression.Constant(dueTime, typeof(TimeSpan)),
  14539. Expression.Constant(scheduler, typeof(IScheduler))
  14540. )
  14541. );
  14542. }
  14543. /// <summary>
  14544. /// Ignores elements from an observable sequence which are followed by another value within a computed throttle duration.
  14545. /// </summary>
  14546. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14547. /// <typeparam name="TThrottle">The type of the elements in the throttle sequences selected for each element in the source sequence.</typeparam>
  14548. /// <param name="source">Source sequence to throttle.</param>
  14549. /// <param name="throttleDurationSelector">Selector function to retrieve a sequence indicating the throttle duration for each given element.</param>
  14550. /// <returns>The throttled sequence.</returns>
  14551. /// <exception cref="T:System.ArgumentNullException">
  14552. /// <paramref name="source" /> or <paramref name="throttleDurationSelector" /> is null.</exception>
  14553. /// <remarks>
  14554. /// This operator throttles the source sequence by holding on to each element for the duration denoted by <paramref name="throttleDurationSelector" />.
  14555. /// 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
  14556. /// whole process. For streams where the duration computed by applying the <paramref name="throttleDurationSelector" /> to each element overlaps with
  14557. /// the occurrence of the successor element, the resulting stream won't produce any elements. In order to reduce the volume of a stream whilst
  14558. /// guaranteeing the periodic production of elements, consider using the Observable.Sample set of operators.
  14559. /// </remarks>
  14560. public static IQbservable<TSource> Throttle<TSource, TThrottle>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TThrottle>>> throttleDurationSelector)
  14561. {
  14562. if (source == null)
  14563. throw new ArgumentNullException("source");
  14564. if (throttleDurationSelector == null)
  14565. throw new ArgumentNullException("throttleDurationSelector");
  14566. return source.Provider.CreateQuery<TSource>(
  14567. Expression.Call(
  14568. null,
  14569. #if CRIPPLED_REFLECTION
  14570. InfoOf(() => Qbservable.Throttle<TSource, TThrottle>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TThrottle>>>))),
  14571. #else
  14572. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TThrottle)),
  14573. #endif
  14574. source.Expression,
  14575. throttleDurationSelector
  14576. )
  14577. );
  14578. }
  14579. /// <summary>
  14580. /// Returns an observable sequence that terminates with an exception.
  14581. /// </summary>
  14582. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  14583. /// <typeparam name="TResult">The type used for the IObservable&lt;T&gt; type parameter of the resulting sequence.</typeparam>
  14584. /// <param name="exception">Exception object used for the sequence's termination.</param>
  14585. /// <returns>The observable sequence that terminates exceptionally with the specified exception object.</returns>
  14586. /// <exception cref="T:System.ArgumentNullException">
  14587. /// <paramref name="exception" /> is null.</exception>
  14588. public static IQbservable<TResult> Throw<TResult>(this IQbservableProvider provider, Exception exception)
  14589. {
  14590. if (provider == null)
  14591. throw new ArgumentNullException("provider");
  14592. if (exception == null)
  14593. throw new ArgumentNullException("exception");
  14594. return provider.CreateQuery<TResult>(
  14595. Expression.Call(
  14596. null,
  14597. #if CRIPPLED_REFLECTION
  14598. InfoOf(() => Qbservable.Throw<TResult>(default(IQbservableProvider), default(Exception))),
  14599. #else
  14600. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  14601. #endif
  14602. Expression.Constant(provider, typeof(IQbservableProvider)),
  14603. Expression.Constant(exception, typeof(Exception))
  14604. )
  14605. );
  14606. }
  14607. /// <summary>
  14608. /// Returns an observable sequence that terminates with an exception, using the specified scheduler to send out the single OnError message.
  14609. /// </summary>
  14610. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  14611. /// <typeparam name="TResult">The type used for the IObservable&lt;T&gt; type parameter of the resulting sequence.</typeparam>
  14612. /// <param name="exception">Exception object used for the sequence's termination.</param>
  14613. /// <param name="scheduler">Scheduler to send the exceptional termination call on.</param>
  14614. /// <returns>The observable sequence that terminates exceptionally with the specified exception object.</returns>
  14615. /// <exception cref="T:System.ArgumentNullException">
  14616. /// <paramref name="exception" /> or <paramref name="scheduler" /> is null.</exception>
  14617. public static IQbservable<TResult> Throw<TResult>(this IQbservableProvider provider, Exception exception, IScheduler scheduler)
  14618. {
  14619. if (provider == null)
  14620. throw new ArgumentNullException("provider");
  14621. if (exception == null)
  14622. throw new ArgumentNullException("exception");
  14623. if (scheduler == null)
  14624. throw new ArgumentNullException("scheduler");
  14625. return provider.CreateQuery<TResult>(
  14626. Expression.Call(
  14627. null,
  14628. #if CRIPPLED_REFLECTION
  14629. InfoOf(() => Qbservable.Throw<TResult>(default(IQbservableProvider), default(Exception), default(IScheduler))),
  14630. #else
  14631. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  14632. #endif
  14633. Expression.Constant(provider, typeof(IQbservableProvider)),
  14634. Expression.Constant(exception, typeof(Exception)),
  14635. Expression.Constant(scheduler, typeof(IScheduler))
  14636. )
  14637. );
  14638. }
  14639. /// <summary>
  14640. /// Returns an observable sequence that terminates with an exception, using the specified scheduler to send out the single OnError message.
  14641. /// </summary>
  14642. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  14643. /// <typeparam name="TResult">The type used for the IObservable&lt;T&gt; type parameter of the resulting sequence.</typeparam>
  14644. /// <param name="exception">Exception object used for the sequence's termination.</param>
  14645. /// <param name="scheduler">Scheduler to send the exceptional termination call on.</param>
  14646. /// <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>
  14647. /// <returns>The observable sequence that terminates exceptionally with the specified exception object.</returns>
  14648. /// <exception cref="T:System.ArgumentNullException">
  14649. /// <paramref name="exception" /> or <paramref name="scheduler" /> is null.</exception>
  14650. public static IQbservable<TResult> Throw<TResult>(this IQbservableProvider provider, Exception exception, IScheduler scheduler, TResult witness)
  14651. {
  14652. if (provider == null)
  14653. throw new ArgumentNullException("provider");
  14654. if (exception == null)
  14655. throw new ArgumentNullException("exception");
  14656. if (scheduler == null)
  14657. throw new ArgumentNullException("scheduler");
  14658. return provider.CreateQuery<TResult>(
  14659. Expression.Call(
  14660. null,
  14661. #if CRIPPLED_REFLECTION
  14662. InfoOf(() => Qbservable.Throw<TResult>(default(IQbservableProvider), default(Exception), default(IScheduler), default(TResult))),
  14663. #else
  14664. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  14665. #endif
  14666. Expression.Constant(provider, typeof(IQbservableProvider)),
  14667. Expression.Constant(exception, typeof(Exception)),
  14668. Expression.Constant(scheduler, typeof(IScheduler)),
  14669. Expression.Constant(witness, typeof(TResult))
  14670. )
  14671. );
  14672. }
  14673. /// <summary>
  14674. /// Returns an observable sequence that terminates with an exception.
  14675. /// </summary>
  14676. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  14677. /// <typeparam name="TResult">The type used for the IObservable&lt;T&gt; type parameter of the resulting sequence.</typeparam>
  14678. /// <param name="exception">Exception object used for the sequence's termination.</param>
  14679. /// <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>
  14680. /// <returns>The observable sequence that terminates exceptionally with the specified exception object.</returns>
  14681. /// <exception cref="T:System.ArgumentNullException">
  14682. /// <paramref name="exception" /> is null.</exception>
  14683. public static IQbservable<TResult> Throw<TResult>(this IQbservableProvider provider, Exception exception, TResult witness)
  14684. {
  14685. if (provider == null)
  14686. throw new ArgumentNullException("provider");
  14687. if (exception == null)
  14688. throw new ArgumentNullException("exception");
  14689. return provider.CreateQuery<TResult>(
  14690. Expression.Call(
  14691. null,
  14692. #if CRIPPLED_REFLECTION
  14693. InfoOf(() => Qbservable.Throw<TResult>(default(IQbservableProvider), default(Exception), default(TResult))),
  14694. #else
  14695. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  14696. #endif
  14697. Expression.Constant(provider, typeof(IQbservableProvider)),
  14698. Expression.Constant(exception, typeof(Exception)),
  14699. Expression.Constant(witness, typeof(TResult))
  14700. )
  14701. );
  14702. }
  14703. /// <summary>
  14704. /// Records the time interval between consecutive elements in an observable sequence.
  14705. /// </summary>
  14706. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14707. /// <param name="source">Source sequence to record time intervals for.</param>
  14708. /// <returns>An observable sequence with time interval information on elements.</returns>
  14709. /// <exception cref="T:System.ArgumentNullException">
  14710. /// <paramref name="source" /> is null.</exception>
  14711. public static IQbservable<TimeInterval<TSource>> TimeInterval<TSource>(this IQbservable<TSource> source)
  14712. {
  14713. if (source == null)
  14714. throw new ArgumentNullException("source");
  14715. return source.Provider.CreateQuery<TimeInterval<TSource>>(
  14716. Expression.Call(
  14717. null,
  14718. #if CRIPPLED_REFLECTION
  14719. InfoOf(() => Qbservable.TimeInterval<TSource>(default(IQbservable<TSource>))),
  14720. #else
  14721. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14722. #endif
  14723. source.Expression
  14724. )
  14725. );
  14726. }
  14727. /// <summary>
  14728. /// Records the time interval between consecutive elements in an observable sequence, using the specified scheduler to compute time intervals.
  14729. /// </summary>
  14730. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14731. /// <param name="source">Source sequence to record time intervals for.</param>
  14732. /// <param name="scheduler">Scheduler used to compute time intervals.</param>
  14733. /// <returns>An observable sequence with time interval information on elements.</returns>
  14734. /// <exception cref="T:System.ArgumentNullException">
  14735. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14736. public static IQbservable<TimeInterval<TSource>> TimeInterval<TSource>(this IQbservable<TSource> source, IScheduler scheduler)
  14737. {
  14738. if (source == null)
  14739. throw new ArgumentNullException("source");
  14740. if (scheduler == null)
  14741. throw new ArgumentNullException("scheduler");
  14742. return source.Provider.CreateQuery<TimeInterval<TSource>>(
  14743. Expression.Call(
  14744. null,
  14745. #if CRIPPLED_REFLECTION
  14746. InfoOf(() => Qbservable.TimeInterval<TSource>(default(IQbservable<TSource>), default(IScheduler))),
  14747. #else
  14748. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14749. #endif
  14750. source.Expression,
  14751. Expression.Constant(scheduler, typeof(IScheduler))
  14752. )
  14753. );
  14754. }
  14755. /// <summary>
  14756. /// Applies a timeout policy to the observable sequence based on an absolute time.
  14757. /// If the sequence doesn't terminate before the specified absolute due time, a TimeoutException is propagated to the observer.
  14758. /// </summary>
  14759. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14760. /// <param name="source">Source sequence to perform a timeout for.</param>
  14761. /// <param name="dueTime">Time when a timeout occurs. If this value is less than or equal to DateTimeOffset.UtcNow, the timeout occurs immediately.</param>
  14762. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  14763. /// <exception cref="T:System.ArgumentNullException">
  14764. /// <paramref name="source" /> is null.</exception>
  14765. /// <exception cref="T:System.TimeoutException">(Asynchronous) If the sequence hasn't terminated before <paramref name="dueTime" />.</exception>
  14766. /// <remarks>
  14767. /// 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})" />
  14768. /// 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
  14769. /// 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.
  14770. /// </remarks>
  14771. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime)
  14772. {
  14773. if (source == null)
  14774. throw new ArgumentNullException("source");
  14775. return source.Provider.CreateQuery<TSource>(
  14776. Expression.Call(
  14777. null,
  14778. #if CRIPPLED_REFLECTION
  14779. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(DateTimeOffset))),
  14780. #else
  14781. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14782. #endif
  14783. source.Expression,
  14784. Expression.Constant(dueTime, typeof(DateTimeOffset))
  14785. )
  14786. );
  14787. }
  14788. /// <summary>
  14789. /// Applies a timeout policy to the observable sequence based on an absolute time.
  14790. /// 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.
  14791. /// </summary>
  14792. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  14793. /// <param name="source">Source sequence to perform a timeout for.</param>
  14794. /// <param name="dueTime">Time when a timeout occurs. If this value is less than or equal to DateTimeOffset.UtcNow, the timeout occurs immediately.</param>
  14795. /// <param name="other">Sequence to return in case of a timeout.</param>
  14796. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  14797. /// <exception cref="T:System.ArgumentNullException">
  14798. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  14799. /// <remarks>
  14800. /// 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})" />
  14801. /// 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
  14802. /// 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.
  14803. /// </remarks>
  14804. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime, IObservable<TSource> other)
  14805. {
  14806. if (source == null)
  14807. throw new ArgumentNullException("source");
  14808. if (other == null)
  14809. throw new ArgumentNullException("other");
  14810. return source.Provider.CreateQuery<TSource>(
  14811. Expression.Call(
  14812. null,
  14813. #if CRIPPLED_REFLECTION
  14814. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IObservable<TSource>))),
  14815. #else
  14816. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14817. #endif
  14818. source.Expression,
  14819. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  14820. GetSourceExpression(other)
  14821. )
  14822. );
  14823. }
  14824. /// <summary>
  14825. /// Applies a timeout policy to the observable sequence based on an absolute time, using the specified scheduler to run timeout timers.
  14826. /// 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.
  14827. /// </summary>
  14828. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  14829. /// <param name="source">Source sequence to perform a timeout for.</param>
  14830. /// <param name="dueTime">Time when a timeout occurs. If this value is less than or equal to DateTimeOffset.UtcNow, the timeout occurs immediately.</param>
  14831. /// <param name="other">Sequence to return in case of a timeout.</param>
  14832. /// <param name="scheduler">Scheduler to run the timeout timers on.</param>
  14833. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  14834. /// <exception cref="T:System.ArgumentNullException">
  14835. /// <paramref name="source" /> or <paramref name="other" /> or <paramref name="scheduler" /> is null.</exception>
  14836. /// <remarks>
  14837. /// 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})" />
  14838. /// 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
  14839. /// 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.
  14840. /// </remarks>
  14841. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime, IObservable<TSource> other, IScheduler scheduler)
  14842. {
  14843. if (source == null)
  14844. throw new ArgumentNullException("source");
  14845. if (other == null)
  14846. throw new ArgumentNullException("other");
  14847. if (scheduler == null)
  14848. throw new ArgumentNullException("scheduler");
  14849. return source.Provider.CreateQuery<TSource>(
  14850. Expression.Call(
  14851. null,
  14852. #if CRIPPLED_REFLECTION
  14853. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IObservable<TSource>), default(IScheduler))),
  14854. #else
  14855. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14856. #endif
  14857. source.Expression,
  14858. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  14859. GetSourceExpression(other),
  14860. Expression.Constant(scheduler, typeof(IScheduler))
  14861. )
  14862. );
  14863. }
  14864. /// <summary>
  14865. /// Applies a timeout policy to the observable sequence based on an absolute time, using the specified scheduler to run timeout timers.
  14866. /// If the sequence doesn't terminate before the specified absolute due time, a TimeoutException is propagated to the observer.
  14867. /// </summary>
  14868. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14869. /// <param name="source">Source sequence to perform a timeout for.</param>
  14870. /// <param name="dueTime">Time when a timeout occurs. If this value is less than or equal to DateTimeOffset.UtcNow, the timeout occurs immediately.</param>
  14871. /// <param name="scheduler">Scheduler to run the timeout timers on.</param>
  14872. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  14873. /// <exception cref="T:System.ArgumentNullException">
  14874. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14875. /// <exception cref="T:System.TimeoutException">(Asynchronous) If the sequence hasn't terminated before <paramref name="dueTime" />.</exception>
  14876. /// <remarks>
  14877. /// 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})" />
  14878. /// 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
  14879. /// 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.
  14880. /// </remarks>
  14881. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime, IScheduler scheduler)
  14882. {
  14883. if (source == null)
  14884. throw new ArgumentNullException("source");
  14885. if (scheduler == null)
  14886. throw new ArgumentNullException("scheduler");
  14887. return source.Provider.CreateQuery<TSource>(
  14888. Expression.Call(
  14889. null,
  14890. #if CRIPPLED_REFLECTION
  14891. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IScheduler))),
  14892. #else
  14893. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14894. #endif
  14895. source.Expression,
  14896. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  14897. Expression.Constant(scheduler, typeof(IScheduler))
  14898. )
  14899. );
  14900. }
  14901. /// <summary>
  14902. /// Applies a timeout policy for each element in the observable sequence.
  14903. /// If the next element isn't received within the specified timeout duration starting from its predecessor, a TimeoutException is propagated to the observer.
  14904. /// </summary>
  14905. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14906. /// <param name="source">Source sequence to perform a timeout for.</param>
  14907. /// <param name="dueTime">Maximum duration between values before a timeout occurs.</param>
  14908. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  14909. /// <exception cref="T:System.ArgumentNullException">
  14910. /// <paramref name="source" /> is null.</exception>
  14911. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14912. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14913. /// <exception cref="T:System.TimeoutException">(Asynchronous) If no element is produced within <paramref name="dueTime" /> from the previous element.</exception>
  14914. /// <remarks>
  14915. /// <para>
  14916. /// In case you only want to timeout on the first element, consider using the <see cref="M:System.Reactive.Linq.Observable.Amb``1(System.IObservable{``0},System.IObservable{``0})" />
  14917. /// operator applied to the source sequence and a delayed <see cref="M:System.Reactive.Linq.Observable.Throw``1(System.Exception)" /> sequence. Alternatively, the general-purpose overload
  14918. /// of Timeout, <see cref="M:System.Reactive.Linq.Observable.Timeout``2(System.IObservable{``0},System.IObservable{``1},System.Func{``0,System.IObservable{``1}})" /> can be used.
  14919. /// </para>
  14920. /// <para>
  14921. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing timeout timers to be scheduled that are due
  14922. /// immediately. However, this doesn't guarantee a timeout will occur, even for the first element. This is a side-effect of the asynchrony introduced by the
  14923. /// scheduler, where the action to propagate a timeout may not execute immediately, despite the TimeSpan.Zero due time. In such cases, the next element may
  14924. /// arrive before the scheduler gets a chance to run the timeout action.
  14925. /// </para>
  14926. /// </remarks>
  14927. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, TimeSpan dueTime)
  14928. {
  14929. if (source == null)
  14930. throw new ArgumentNullException("source");
  14931. return source.Provider.CreateQuery<TSource>(
  14932. Expression.Call(
  14933. null,
  14934. #if CRIPPLED_REFLECTION
  14935. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  14936. #else
  14937. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14938. #endif
  14939. source.Expression,
  14940. Expression.Constant(dueTime, typeof(TimeSpan))
  14941. )
  14942. );
  14943. }
  14944. /// <summary>
  14945. /// Applies a timeout policy for each element in the observable sequence.
  14946. /// 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.
  14947. /// </summary>
  14948. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  14949. /// <param name="source">Source sequence to perform a timeout for.</param>
  14950. /// <param name="dueTime">Maximum duration between values before a timeout occurs.</param>
  14951. /// <param name="other">Sequence to return in case of a timeout.</param>
  14952. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  14953. /// <exception cref="T:System.ArgumentNullException">
  14954. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  14955. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14956. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14957. /// <remarks>
  14958. /// <para>
  14959. /// 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})" />
  14960. /// 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
  14961. /// 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.
  14962. /// </para>
  14963. /// <para>
  14964. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing timeout timers to be scheduled that are due
  14965. /// 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
  14966. /// 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
  14967. /// arrive before the scheduler gets a chance to run the timeout action.
  14968. /// </para>
  14969. /// </remarks>
  14970. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IObservable<TSource> other)
  14971. {
  14972. if (source == null)
  14973. throw new ArgumentNullException("source");
  14974. if (other == null)
  14975. throw new ArgumentNullException("other");
  14976. return source.Provider.CreateQuery<TSource>(
  14977. Expression.Call(
  14978. null,
  14979. #if CRIPPLED_REFLECTION
  14980. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IObservable<TSource>))),
  14981. #else
  14982. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14983. #endif
  14984. source.Expression,
  14985. Expression.Constant(dueTime, typeof(TimeSpan)),
  14986. GetSourceExpression(other)
  14987. )
  14988. );
  14989. }
  14990. /// <summary>
  14991. /// Applies a timeout policy for each element in the observable sequence, using the specified scheduler to run timeout timers.
  14992. /// 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.
  14993. /// </summary>
  14994. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  14995. /// <param name="source">Source sequence to perform a timeout for.</param>
  14996. /// <param name="dueTime">Maximum duration between values before a timeout occurs.</param>
  14997. /// <param name="other">Sequence to return in case of a timeout.</param>
  14998. /// <param name="scheduler">Scheduler to run the timeout timers on.</param>
  14999. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  15000. /// <exception cref="T:System.ArgumentNullException">
  15001. /// <paramref name="source" /> or <paramref name="other" /> or <paramref name="scheduler" /> is null.</exception>
  15002. /// <exception cref="T:System.ArgumentOutOfRangeException">
  15003. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  15004. /// <remarks>
  15005. /// <para>
  15006. /// 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})" />
  15007. /// 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
  15008. /// 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.
  15009. /// </para>
  15010. /// <para>
  15011. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing timeout timers to be scheduled that are due
  15012. /// 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
  15013. /// 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
  15014. /// arrive before the scheduler gets a chance to run the timeout action.
  15015. /// </para>
  15016. /// </remarks>
  15017. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IObservable<TSource> other, IScheduler scheduler)
  15018. {
  15019. if (source == null)
  15020. throw new ArgumentNullException("source");
  15021. if (other == null)
  15022. throw new ArgumentNullException("other");
  15023. if (scheduler == null)
  15024. throw new ArgumentNullException("scheduler");
  15025. return source.Provider.CreateQuery<TSource>(
  15026. Expression.Call(
  15027. null,
  15028. #if CRIPPLED_REFLECTION
  15029. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IObservable<TSource>), default(IScheduler))),
  15030. #else
  15031. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15032. #endif
  15033. source.Expression,
  15034. Expression.Constant(dueTime, typeof(TimeSpan)),
  15035. GetSourceExpression(other),
  15036. Expression.Constant(scheduler, typeof(IScheduler))
  15037. )
  15038. );
  15039. }
  15040. /// <summary>
  15041. /// Applies a timeout policy for each element in the observable sequence, using the specified scheduler to run timeout timers.
  15042. /// If the next element isn't received within the specified timeout duration starting from its predecessor, a TimeoutException is propagated to the observer.
  15043. /// </summary>
  15044. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15045. /// <param name="source">Source sequence to perform a timeout for.</param>
  15046. /// <param name="dueTime">Maximum duration between values before a timeout occurs.</param>
  15047. /// <param name="scheduler">Scheduler to run the timeout timers on.</param>
  15048. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  15049. /// <exception cref="T:System.ArgumentNullException">
  15050. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  15051. /// <exception cref="T:System.ArgumentOutOfRangeException">
  15052. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  15053. /// <exception cref="T:System.TimeoutException">(Asynchronous) If no element is produced within <paramref name="dueTime" /> from the previous element.</exception>
  15054. /// <remarks>
  15055. /// <para>
  15056. /// 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})" />
  15057. /// 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
  15058. /// 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.
  15059. /// </para>
  15060. /// <para>
  15061. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing timeout timers to be scheduled that are due
  15062. /// 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
  15063. /// 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
  15064. /// arrive before the scheduler gets a chance to run the timeout action.
  15065. /// </para>
  15066. /// </remarks>
  15067. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IScheduler scheduler)
  15068. {
  15069. if (source == null)
  15070. throw new ArgumentNullException("source");
  15071. if (scheduler == null)
  15072. throw new ArgumentNullException("scheduler");
  15073. return source.Provider.CreateQuery<TSource>(
  15074. Expression.Call(
  15075. null,
  15076. #if CRIPPLED_REFLECTION
  15077. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  15078. #else
  15079. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15080. #endif
  15081. source.Expression,
  15082. Expression.Constant(dueTime, typeof(TimeSpan)),
  15083. Expression.Constant(scheduler, typeof(IScheduler))
  15084. )
  15085. );
  15086. }
  15087. /// <summary>
  15088. /// 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.
  15089. /// If the next element isn't received within the computed duration starting from its predecessor, a TimeoutException is propagated to the observer.
  15090. /// </summary>
  15091. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15092. /// <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>
  15093. /// <param name="source">Source sequence to perform a timeout for.</param>
  15094. /// <param name="firstTimeout">Observable sequence that represents the timeout for the first element.</param>
  15095. /// <param name="timeoutDurationSelector">Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.</param>
  15096. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  15097. /// <exception cref="T:System.ArgumentNullException">
  15098. /// <paramref name="source" /> or <paramref name="firstTimeout" /> or <paramref name="timeoutDurationSelector" /> is null.</exception>
  15099. public static IQbservable<TSource> Timeout<TSource, TTimeout>(this IQbservable<TSource> source, IObservable<TTimeout> firstTimeout, Expression<Func<TSource, IObservable<TTimeout>>> timeoutDurationSelector)
  15100. {
  15101. if (source == null)
  15102. throw new ArgumentNullException("source");
  15103. if (firstTimeout == null)
  15104. throw new ArgumentNullException("firstTimeout");
  15105. if (timeoutDurationSelector == null)
  15106. throw new ArgumentNullException("timeoutDurationSelector");
  15107. return source.Provider.CreateQuery<TSource>(
  15108. Expression.Call(
  15109. null,
  15110. #if CRIPPLED_REFLECTION
  15111. InfoOf(() => Qbservable.Timeout<TSource, TTimeout>(default(IQbservable<TSource>), default(IObservable<TTimeout>), default(Expression<Func<TSource, IObservable<TTimeout>>>))),
  15112. #else
  15113. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTimeout)),
  15114. #endif
  15115. source.Expression,
  15116. GetSourceExpression(firstTimeout),
  15117. timeoutDurationSelector
  15118. )
  15119. );
  15120. }
  15121. /// <summary>
  15122. /// 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.
  15123. /// 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.
  15124. /// </summary>
  15125. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  15126. /// <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>
  15127. /// <param name="source">Source sequence to perform a timeout for.</param>
  15128. /// <param name="firstTimeout">Observable sequence that represents the timeout for the first element.</param>
  15129. /// <param name="timeoutDurationSelector">Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.</param>
  15130. /// <param name="other">Sequence to return in case of a timeout.</param>
  15131. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  15132. /// <exception cref="T:System.ArgumentNullException">
  15133. /// <paramref name="source" /> or <paramref name="firstTimeout" /> or <paramref name="timeoutDurationSelector" /> or <paramref name="other" /> is null.</exception>
  15134. public static IQbservable<TSource> Timeout<TSource, TTimeout>(this IQbservable<TSource> source, IObservable<TTimeout> firstTimeout, Expression<Func<TSource, IObservable<TTimeout>>> timeoutDurationSelector, IObservable<TSource> other)
  15135. {
  15136. if (source == null)
  15137. throw new ArgumentNullException("source");
  15138. if (firstTimeout == null)
  15139. throw new ArgumentNullException("firstTimeout");
  15140. if (timeoutDurationSelector == null)
  15141. throw new ArgumentNullException("timeoutDurationSelector");
  15142. if (other == null)
  15143. throw new ArgumentNullException("other");
  15144. return source.Provider.CreateQuery<TSource>(
  15145. Expression.Call(
  15146. null,
  15147. #if CRIPPLED_REFLECTION
  15148. InfoOf(() => Qbservable.Timeout<TSource, TTimeout>(default(IQbservable<TSource>), default(IObservable<TTimeout>), default(Expression<Func<TSource, IObservable<TTimeout>>>), default(IObservable<TSource>))),
  15149. #else
  15150. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTimeout)),
  15151. #endif
  15152. source.Expression,
  15153. GetSourceExpression(firstTimeout),
  15154. timeoutDurationSelector,
  15155. GetSourceExpression(other)
  15156. )
  15157. );
  15158. }
  15159. /// <summary>
  15160. /// Applies a timeout policy to the observable sequence based on a timeout duration computed for each element.
  15161. /// If the next element isn't received within the computed duration starting from its predecessor, a TimeoutException is propagated to the observer.
  15162. /// </summary>
  15163. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15164. /// <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>
  15165. /// <param name="source">Source sequence to perform a timeout for.</param>
  15166. /// <param name="timeoutDurationSelector">Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.</param>
  15167. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  15168. /// <exception cref="T:System.ArgumentNullException">
  15169. /// <paramref name="source" /> or <paramref name="timeoutDurationSelector" /> is null.</exception>
  15170. public static IQbservable<TSource> Timeout<TSource, TTimeout>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TTimeout>>> timeoutDurationSelector)
  15171. {
  15172. if (source == null)
  15173. throw new ArgumentNullException("source");
  15174. if (timeoutDurationSelector == null)
  15175. throw new ArgumentNullException("timeoutDurationSelector");
  15176. return source.Provider.CreateQuery<TSource>(
  15177. Expression.Call(
  15178. null,
  15179. #if CRIPPLED_REFLECTION
  15180. InfoOf(() => Qbservable.Timeout<TSource, TTimeout>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TTimeout>>>))),
  15181. #else
  15182. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTimeout)),
  15183. #endif
  15184. source.Expression,
  15185. timeoutDurationSelector
  15186. )
  15187. );
  15188. }
  15189. /// <summary>
  15190. /// Applies a timeout policy to the observable sequence based on a timeout duration computed for each element.
  15191. /// 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.
  15192. /// </summary>
  15193. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  15194. /// <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>
  15195. /// <param name="source">Source sequence to perform a timeout for.</param>
  15196. /// <param name="timeoutDurationSelector">Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.</param>
  15197. /// <param name="other">Sequence to return in case of a timeout.</param>
  15198. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  15199. /// <exception cref="T:System.ArgumentNullException">
  15200. /// <paramref name="source" /> or <paramref name="timeoutDurationSelector" /> or <paramref name="other" /> is null.</exception>
  15201. public static IQbservable<TSource> Timeout<TSource, TTimeout>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TTimeout>>> timeoutDurationSelector, IObservable<TSource> other)
  15202. {
  15203. if (source == null)
  15204. throw new ArgumentNullException("source");
  15205. if (timeoutDurationSelector == null)
  15206. throw new ArgumentNullException("timeoutDurationSelector");
  15207. if (other == null)
  15208. throw new ArgumentNullException("other");
  15209. return source.Provider.CreateQuery<TSource>(
  15210. Expression.Call(
  15211. null,
  15212. #if CRIPPLED_REFLECTION
  15213. InfoOf(() => Qbservable.Timeout<TSource, TTimeout>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TTimeout>>>), default(IObservable<TSource>))),
  15214. #else
  15215. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTimeout)),
  15216. #endif
  15217. source.Expression,
  15218. timeoutDurationSelector,
  15219. GetSourceExpression(other)
  15220. )
  15221. );
  15222. }
  15223. /// <summary>
  15224. /// Returns an observable sequence that produces a single value at the specified absolute due time.
  15225. /// </summary>
  15226. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  15227. /// <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>
  15228. /// <returns>An observable sequence that produces a value at due time.</returns>
  15229. public static IQbservable<long> Timer(this IQbservableProvider provider, DateTimeOffset dueTime)
  15230. {
  15231. if (provider == null)
  15232. throw new ArgumentNullException("provider");
  15233. return provider.CreateQuery<long>(
  15234. Expression.Call(
  15235. null,
  15236. #if CRIPPLED_REFLECTION
  15237. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(DateTimeOffset))),
  15238. #else
  15239. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15240. #endif
  15241. Expression.Constant(provider, typeof(IQbservableProvider)),
  15242. Expression.Constant(dueTime, typeof(DateTimeOffset))
  15243. )
  15244. );
  15245. }
  15246. /// <summary>
  15247. /// Returns an observable sequence that periodically produces a value starting at the specified initial absolute due time.
  15248. /// </summary>
  15249. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  15250. /// <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>
  15251. /// <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>
  15252. /// <returns>An observable sequence that produces a value at due time and then after each period.</returns>
  15253. /// <exception cref="T:System.ArgumentOutOfRangeException">
  15254. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  15255. public static IQbservable<long> Timer(this IQbservableProvider provider, DateTimeOffset dueTime, TimeSpan period)
  15256. {
  15257. if (provider == null)
  15258. throw new ArgumentNullException("provider");
  15259. return provider.CreateQuery<long>(
  15260. Expression.Call(
  15261. null,
  15262. #if CRIPPLED_REFLECTION
  15263. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(DateTimeOffset), default(TimeSpan))),
  15264. #else
  15265. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15266. #endif
  15267. Expression.Constant(provider, typeof(IQbservableProvider)),
  15268. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  15269. Expression.Constant(period, typeof(TimeSpan))
  15270. )
  15271. );
  15272. }
  15273. /// <summary>
  15274. /// Returns an observable sequence that periodically produces a value starting at the specified initial absolute due time, using the specified scheduler to run timers.
  15275. /// </summary>
  15276. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  15277. /// <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>
  15278. /// <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>
  15279. /// <param name="scheduler">Scheduler to run timers on.</param>
  15280. /// <returns>An observable sequence that produces a value at due time and then after each period.</returns>
  15281. /// <exception cref="T:System.ArgumentOutOfRangeException">
  15282. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  15283. /// <exception cref="T:System.ArgumentNullException">
  15284. /// <paramref name="scheduler" /> is null.</exception>
  15285. public static IQbservable<long> Timer(this IQbservableProvider provider, DateTimeOffset dueTime, TimeSpan period, IScheduler scheduler)
  15286. {
  15287. if (provider == null)
  15288. throw new ArgumentNullException("provider");
  15289. if (scheduler == null)
  15290. throw new ArgumentNullException("scheduler");
  15291. return provider.CreateQuery<long>(
  15292. Expression.Call(
  15293. null,
  15294. #if CRIPPLED_REFLECTION
  15295. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(DateTimeOffset), default(TimeSpan), default(IScheduler))),
  15296. #else
  15297. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15298. #endif
  15299. Expression.Constant(provider, typeof(IQbservableProvider)),
  15300. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  15301. Expression.Constant(period, typeof(TimeSpan)),
  15302. Expression.Constant(scheduler, typeof(IScheduler))
  15303. )
  15304. );
  15305. }
  15306. /// <summary>
  15307. /// Returns an observable sequence that produces a single value at the specified absolute due time, using the specified scheduler to run the timer.
  15308. /// </summary>
  15309. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  15310. /// <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>
  15311. /// <param name="scheduler">Scheduler to run the timer on.</param>
  15312. /// <returns>An observable sequence that produces a value at due time.</returns>
  15313. /// <exception cref="T:System.ArgumentNullException">
  15314. /// <paramref name="scheduler" /> is null.</exception>
  15315. public static IQbservable<long> Timer(this IQbservableProvider provider, DateTimeOffset dueTime, IScheduler scheduler)
  15316. {
  15317. if (provider == null)
  15318. throw new ArgumentNullException("provider");
  15319. if (scheduler == null)
  15320. throw new ArgumentNullException("scheduler");
  15321. return provider.CreateQuery<long>(
  15322. Expression.Call(
  15323. null,
  15324. #if CRIPPLED_REFLECTION
  15325. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(DateTimeOffset), default(IScheduler))),
  15326. #else
  15327. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15328. #endif
  15329. Expression.Constant(provider, typeof(IQbservableProvider)),
  15330. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  15331. Expression.Constant(scheduler, typeof(IScheduler))
  15332. )
  15333. );
  15334. }
  15335. /// <summary>
  15336. /// Returns an observable sequence that produces a single value after the specified relative due time has elapsed.
  15337. /// </summary>
  15338. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  15339. /// <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>
  15340. /// <returns>An observable sequence that produces a value after the due time has elapsed.</returns>
  15341. public static IQbservable<long> Timer(this IQbservableProvider provider, TimeSpan dueTime)
  15342. {
  15343. if (provider == null)
  15344. throw new ArgumentNullException("provider");
  15345. return provider.CreateQuery<long>(
  15346. Expression.Call(
  15347. null,
  15348. #if CRIPPLED_REFLECTION
  15349. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(TimeSpan))),
  15350. #else
  15351. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15352. #endif
  15353. Expression.Constant(provider, typeof(IQbservableProvider)),
  15354. Expression.Constant(dueTime, typeof(TimeSpan))
  15355. )
  15356. );
  15357. }
  15358. /// <summary>
  15359. /// Returns an observable sequence that periodically produces a value after the specified initial relative due time has elapsed.
  15360. /// </summary>
  15361. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  15362. /// <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>
  15363. /// <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>
  15364. /// <returns>An observable sequence that produces a value after due time has elapsed and then after each period.</returns>
  15365. /// <exception cref="T:System.ArgumentOutOfRangeException">
  15366. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  15367. public static IQbservable<long> Timer(this IQbservableProvider provider, TimeSpan dueTime, TimeSpan period)
  15368. {
  15369. if (provider == null)
  15370. throw new ArgumentNullException("provider");
  15371. return provider.CreateQuery<long>(
  15372. Expression.Call(
  15373. null,
  15374. #if CRIPPLED_REFLECTION
  15375. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(TimeSpan), default(TimeSpan))),
  15376. #else
  15377. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15378. #endif
  15379. Expression.Constant(provider, typeof(IQbservableProvider)),
  15380. Expression.Constant(dueTime, typeof(TimeSpan)),
  15381. Expression.Constant(period, typeof(TimeSpan))
  15382. )
  15383. );
  15384. }
  15385. /// <summary>
  15386. /// 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.
  15387. /// </summary>
  15388. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  15389. /// <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>
  15390. /// <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>
  15391. /// <param name="scheduler">Scheduler to run timers on.</param>
  15392. /// <returns>An observable sequence that produces a value after due time has elapsed and then each period.</returns>
  15393. /// <exception cref="T:System.ArgumentOutOfRangeException">
  15394. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  15395. /// <exception cref="T:System.ArgumentNullException">
  15396. /// <paramref name="scheduler" /> is null.</exception>
  15397. public static IQbservable<long> Timer(this IQbservableProvider provider, TimeSpan dueTime, TimeSpan period, IScheduler scheduler)
  15398. {
  15399. if (provider == null)
  15400. throw new ArgumentNullException("provider");
  15401. if (scheduler == null)
  15402. throw new ArgumentNullException("scheduler");
  15403. return provider.CreateQuery<long>(
  15404. Expression.Call(
  15405. null,
  15406. #if CRIPPLED_REFLECTION
  15407. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(TimeSpan), default(TimeSpan), default(IScheduler))),
  15408. #else
  15409. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15410. #endif
  15411. Expression.Constant(provider, typeof(IQbservableProvider)),
  15412. Expression.Constant(dueTime, typeof(TimeSpan)),
  15413. Expression.Constant(period, typeof(TimeSpan)),
  15414. Expression.Constant(scheduler, typeof(IScheduler))
  15415. )
  15416. );
  15417. }
  15418. /// <summary>
  15419. /// 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.
  15420. /// </summary>
  15421. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  15422. /// <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>
  15423. /// <param name="scheduler">Scheduler to run the timer on.</param>
  15424. /// <returns>An observable sequence that produces a value after the due time has elapsed.</returns>
  15425. /// <exception cref="T:System.ArgumentNullException">
  15426. /// <paramref name="scheduler" /> is null.</exception>
  15427. public static IQbservable<long> Timer(this IQbservableProvider provider, TimeSpan dueTime, IScheduler scheduler)
  15428. {
  15429. if (provider == null)
  15430. throw new ArgumentNullException("provider");
  15431. if (scheduler == null)
  15432. throw new ArgumentNullException("scheduler");
  15433. return provider.CreateQuery<long>(
  15434. Expression.Call(
  15435. null,
  15436. #if CRIPPLED_REFLECTION
  15437. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(TimeSpan), default(IScheduler))),
  15438. #else
  15439. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15440. #endif
  15441. Expression.Constant(provider, typeof(IQbservableProvider)),
  15442. Expression.Constant(dueTime, typeof(TimeSpan)),
  15443. Expression.Constant(scheduler, typeof(IScheduler))
  15444. )
  15445. );
  15446. }
  15447. /// <summary>
  15448. /// Timestamps each element in an observable sequence using the local system clock.
  15449. /// </summary>
  15450. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15451. /// <param name="source">Source sequence to timestamp elements for.</param>
  15452. /// <returns>An observable sequence with timestamp information on elements.</returns>
  15453. /// <exception cref="T:System.ArgumentNullException">
  15454. /// <paramref name="source" /> is null.</exception>
  15455. public static IQbservable<Timestamped<TSource>> Timestamp<TSource>(this IQbservable<TSource> source)
  15456. {
  15457. if (source == null)
  15458. throw new ArgumentNullException("source");
  15459. return source.Provider.CreateQuery<Timestamped<TSource>>(
  15460. Expression.Call(
  15461. null,
  15462. #if CRIPPLED_REFLECTION
  15463. InfoOf(() => Qbservable.Timestamp<TSource>(default(IQbservable<TSource>))),
  15464. #else
  15465. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15466. #endif
  15467. source.Expression
  15468. )
  15469. );
  15470. }
  15471. /// <summary>
  15472. /// Timestamp each element in an observable sequence using the clock of the specified scheduler.
  15473. /// </summary>
  15474. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15475. /// <param name="source">Source sequence to timestamp elements for.</param>
  15476. /// <param name="scheduler">Scheduler used to compute timestamps.</param>
  15477. /// <returns>An observable sequence with timestamp information on elements.</returns>
  15478. /// <exception cref="T:System.ArgumentNullException">
  15479. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  15480. public static IQbservable<Timestamped<TSource>> Timestamp<TSource>(this IQbservable<TSource> source, IScheduler scheduler)
  15481. {
  15482. if (source == null)
  15483. throw new ArgumentNullException("source");
  15484. if (scheduler == null)
  15485. throw new ArgumentNullException("scheduler");
  15486. return source.Provider.CreateQuery<Timestamped<TSource>>(
  15487. Expression.Call(
  15488. null,
  15489. #if CRIPPLED_REFLECTION
  15490. InfoOf(() => Qbservable.Timestamp<TSource>(default(IQbservable<TSource>), default(IScheduler))),
  15491. #else
  15492. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15493. #endif
  15494. source.Expression,
  15495. Expression.Constant(scheduler, typeof(IScheduler))
  15496. )
  15497. );
  15498. }
  15499. /// <summary>
  15500. /// Creates an array from an observable sequence.
  15501. /// </summary>
  15502. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15503. /// <param name="source">The source observable sequence to get an array of elements for.</param>
  15504. /// <returns>An observable sequence containing a single element with an array containing all the elements of the source sequence.</returns>
  15505. /// <exception cref="T:System.ArgumentNullException">
  15506. /// <paramref name="source" /> is null.</exception>
  15507. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15508. public static IQbservable<TSource[]> ToArray<TSource>(this IQbservable<TSource> source)
  15509. {
  15510. if (source == null)
  15511. throw new ArgumentNullException("source");
  15512. return source.Provider.CreateQuery<TSource[]>(
  15513. Expression.Call(
  15514. null,
  15515. #if CRIPPLED_REFLECTION
  15516. InfoOf(() => Qbservable.ToArray<TSource>(default(IQbservable<TSource>))),
  15517. #else
  15518. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15519. #endif
  15520. source.Expression
  15521. )
  15522. );
  15523. }
  15524. /// <summary>
  15525. /// Creates a dictionary from an observable sequence according to a specified key selector function.
  15526. /// </summary>
  15527. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15528. /// <typeparam name="TKey">The type of the dictionary key computed for each element in the source sequence.</typeparam>
  15529. /// <param name="source">An observable sequence to create a dictionary for.</param>
  15530. /// <param name="keySelector">A function to extract a key from each element.</param>
  15531. /// <returns>An observable sequence containing a single element with a dictionary mapping unique key values onto the corresponding source sequence's element.</returns>
  15532. /// <exception cref="T:System.ArgumentNullException">
  15533. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  15534. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15535. public static IQbservable<IDictionary<TKey, TSource>> ToDictionary<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  15536. {
  15537. if (source == null)
  15538. throw new ArgumentNullException("source");
  15539. if (keySelector == null)
  15540. throw new ArgumentNullException("keySelector");
  15541. return source.Provider.CreateQuery<IDictionary<TKey, TSource>>(
  15542. Expression.Call(
  15543. null,
  15544. #if CRIPPLED_REFLECTION
  15545. InfoOf(() => Qbservable.ToDictionary<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  15546. #else
  15547. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  15548. #endif
  15549. source.Expression,
  15550. keySelector
  15551. )
  15552. );
  15553. }
  15554. /// <summary>
  15555. /// Creates a dictionary from an observable sequence according to a specified key selector function, and a comparer.
  15556. /// </summary>
  15557. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15558. /// <typeparam name="TKey">The type of the dictionary key computed for each element in the source sequence.</typeparam>
  15559. /// <param name="source">An observable sequence to create a dictionary for.</param>
  15560. /// <param name="keySelector">A function to extract a key from each element.</param>
  15561. /// <param name="comparer">An equality comparer to compare keys.</param>
  15562. /// <returns>An observable sequence containing a single element with a dictionary mapping unique key values onto the corresponding source sequence's element.</returns>
  15563. /// <exception cref="T:System.ArgumentNullException">
  15564. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  15565. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15566. public static IQbservable<IDictionary<TKey, TSource>> ToDictionary<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  15567. {
  15568. if (source == null)
  15569. throw new ArgumentNullException("source");
  15570. if (keySelector == null)
  15571. throw new ArgumentNullException("keySelector");
  15572. if (comparer == null)
  15573. throw new ArgumentNullException("comparer");
  15574. return source.Provider.CreateQuery<IDictionary<TKey, TSource>>(
  15575. Expression.Call(
  15576. null,
  15577. #if CRIPPLED_REFLECTION
  15578. InfoOf(() => Qbservable.ToDictionary<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IEqualityComparer<TKey>))),
  15579. #else
  15580. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  15581. #endif
  15582. source.Expression,
  15583. keySelector,
  15584. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  15585. )
  15586. );
  15587. }
  15588. /// <summary>
  15589. /// Creates a dictionary from an observable sequence according to a specified key selector function, and an element selector function.
  15590. /// </summary>
  15591. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15592. /// <typeparam name="TKey">The type of the dictionary key computed for each element in the source sequence.</typeparam>
  15593. /// <typeparam name="TElement">The type of the dictionary value computed for each element in the source sequence.</typeparam>
  15594. /// <param name="source">An observable sequence to create a dictionary for.</param>
  15595. /// <param name="keySelector">A function to extract a key from each element.</param>
  15596. /// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
  15597. /// <returns>An observable sequence containing a single element with a dictionary mapping unique key values onto the corresponding source sequence's element.</returns>
  15598. /// <exception cref="T:System.ArgumentNullException">
  15599. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> is null.</exception>
  15600. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15601. public static IQbservable<IDictionary<TKey, TElement>> ToDictionary<TSource, TKey, TElement>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector)
  15602. {
  15603. if (source == null)
  15604. throw new ArgumentNullException("source");
  15605. if (keySelector == null)
  15606. throw new ArgumentNullException("keySelector");
  15607. if (elementSelector == null)
  15608. throw new ArgumentNullException("elementSelector");
  15609. return source.Provider.CreateQuery<IDictionary<TKey, TElement>>(
  15610. Expression.Call(
  15611. null,
  15612. #if CRIPPLED_REFLECTION
  15613. InfoOf(() => Qbservable.ToDictionary<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>))),
  15614. #else
  15615. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  15616. #endif
  15617. source.Expression,
  15618. keySelector,
  15619. elementSelector
  15620. )
  15621. );
  15622. }
  15623. /// <summary>
  15624. /// Creates a dictionary from an observable sequence according to a specified key selector function, a comparer, and an element selector function.
  15625. /// </summary>
  15626. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15627. /// <typeparam name="TKey">The type of the dictionary key computed for each element in the source sequence.</typeparam>
  15628. /// <typeparam name="TElement">The type of the dictionary value computed for each element in the source sequence.</typeparam>
  15629. /// <param name="source">An observable sequence to create a dictionary for.</param>
  15630. /// <param name="keySelector">A function to extract a key from each element.</param>
  15631. /// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
  15632. /// <param name="comparer">An equality comparer to compare keys.</param>
  15633. /// <returns>An observable sequence containing a single element with a dictionary mapping unique key values onto the corresponding source sequence's element.</returns>
  15634. /// <exception cref="T:System.ArgumentNullException">
  15635. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="comparer" /> is null.</exception>
  15636. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15637. 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)
  15638. {
  15639. if (source == null)
  15640. throw new ArgumentNullException("source");
  15641. if (keySelector == null)
  15642. throw new ArgumentNullException("keySelector");
  15643. if (elementSelector == null)
  15644. throw new ArgumentNullException("elementSelector");
  15645. if (comparer == null)
  15646. throw new ArgumentNullException("comparer");
  15647. return source.Provider.CreateQuery<IDictionary<TKey, TElement>>(
  15648. Expression.Call(
  15649. null,
  15650. #if CRIPPLED_REFLECTION
  15651. InfoOf(() => Qbservable.ToDictionary<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(IEqualityComparer<TKey>))),
  15652. #else
  15653. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  15654. #endif
  15655. source.Expression,
  15656. keySelector,
  15657. elementSelector,
  15658. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  15659. )
  15660. );
  15661. }
  15662. /// <summary>
  15663. /// Converts an observable sequence to an enumerable sequence.
  15664. /// </summary>
  15665. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15666. /// <param name="source">An observable sequence to convert to an enumerable sequence.</param>
  15667. /// <returns>The enumerable sequence containing the elements in the observable sequence.</returns>
  15668. /// <exception cref="T:System.ArgumentNullException">
  15669. /// <paramref name="source" /> is null.</exception>
  15670. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  15671. public static IQueryable<TSource> ToQueryable<TSource>(this IQbservable<TSource> source)
  15672. {
  15673. if (source == null)
  15674. throw new ArgumentNullException("source");
  15675. return ((IQueryProvider)source.Provider).CreateQuery<TSource>(
  15676. Expression.Call(
  15677. null,
  15678. #if CRIPPLED_REFLECTION
  15679. InfoOf(() => Qbservable.ToQueryable<TSource>(default(IQbservable<TSource>))),
  15680. #else
  15681. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15682. #endif
  15683. source.Expression
  15684. )
  15685. );
  15686. }
  15687. /// <summary>
  15688. /// Creates a list from an observable sequence.
  15689. /// </summary>
  15690. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15691. /// <param name="source">The source observable sequence to get a list of elements for.</param>
  15692. /// <returns>An observable sequence containing a single element with a list containing all the elements of the source sequence.</returns>
  15693. /// <exception cref="T:System.ArgumentNullException">
  15694. /// <paramref name="source" /> is null.</exception>
  15695. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15696. public static IQbservable<IList<TSource>> ToList<TSource>(this IQbservable<TSource> source)
  15697. {
  15698. if (source == null)
  15699. throw new ArgumentNullException("source");
  15700. return source.Provider.CreateQuery<IList<TSource>>(
  15701. Expression.Call(
  15702. null,
  15703. #if CRIPPLED_REFLECTION
  15704. InfoOf(() => Qbservable.ToList<TSource>(default(IQbservable<TSource>))),
  15705. #else
  15706. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15707. #endif
  15708. source.Expression
  15709. )
  15710. );
  15711. }
  15712. /// <summary>
  15713. /// Creates a lookup from an observable sequence according to a specified key selector function.
  15714. /// </summary>
  15715. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15716. /// <typeparam name="TKey">The type of the lookup key computed for each element in the source sequence.</typeparam>
  15717. /// <param name="source">An observable sequence to create a lookup for.</param>
  15718. /// <param name="keySelector">A function to extract a key from each element.</param>
  15719. /// <returns>An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.</returns>
  15720. /// <exception cref="T:System.ArgumentNullException">
  15721. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  15722. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15723. public static IQbservable<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  15724. {
  15725. if (source == null)
  15726. throw new ArgumentNullException("source");
  15727. if (keySelector == null)
  15728. throw new ArgumentNullException("keySelector");
  15729. return source.Provider.CreateQuery<ILookup<TKey, TSource>>(
  15730. Expression.Call(
  15731. null,
  15732. #if CRIPPLED_REFLECTION
  15733. InfoOf(() => Qbservable.ToLookup<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  15734. #else
  15735. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  15736. #endif
  15737. source.Expression,
  15738. keySelector
  15739. )
  15740. );
  15741. }
  15742. /// <summary>
  15743. /// Creates a lookup from an observable sequence according to a specified key selector function, and a comparer.
  15744. /// </summary>
  15745. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15746. /// <typeparam name="TKey">The type of the lookup key computed for each element in the source sequence.</typeparam>
  15747. /// <param name="source">An observable sequence to create a lookup for.</param>
  15748. /// <param name="keySelector">A function to extract a key from each element.</param>
  15749. /// <param name="comparer">An equality comparer to compare keys.</param>
  15750. /// <returns>An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.</returns>
  15751. /// <exception cref="T:System.ArgumentNullException">
  15752. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  15753. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15754. public static IQbservable<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  15755. {
  15756. if (source == null)
  15757. throw new ArgumentNullException("source");
  15758. if (keySelector == null)
  15759. throw new ArgumentNullException("keySelector");
  15760. if (comparer == null)
  15761. throw new ArgumentNullException("comparer");
  15762. return source.Provider.CreateQuery<ILookup<TKey, TSource>>(
  15763. Expression.Call(
  15764. null,
  15765. #if CRIPPLED_REFLECTION
  15766. InfoOf(() => Qbservable.ToLookup<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IEqualityComparer<TKey>))),
  15767. #else
  15768. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  15769. #endif
  15770. source.Expression,
  15771. keySelector,
  15772. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  15773. )
  15774. );
  15775. }
  15776. /// <summary>
  15777. /// Creates a lookup from an observable sequence according to a specified key selector function, and an element selector function.
  15778. /// </summary>
  15779. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15780. /// <typeparam name="TKey">The type of the lookup key computed for each element in the source sequence.</typeparam>
  15781. /// <typeparam name="TElement">The type of the lookup value computed for each element in the source sequence.</typeparam>
  15782. /// <param name="source">An observable sequence to create a lookup for.</param>
  15783. /// <param name="keySelector">A function to extract a key from each element.</param>
  15784. /// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
  15785. /// <returns>An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.</returns>
  15786. /// <exception cref="T:System.ArgumentNullException">
  15787. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> is null.</exception>
  15788. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15789. public static IQbservable<ILookup<TKey, TElement>> ToLookup<TSource, TKey, TElement>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector)
  15790. {
  15791. if (source == null)
  15792. throw new ArgumentNullException("source");
  15793. if (keySelector == null)
  15794. throw new ArgumentNullException("keySelector");
  15795. if (elementSelector == null)
  15796. throw new ArgumentNullException("elementSelector");
  15797. return source.Provider.CreateQuery<ILookup<TKey, TElement>>(
  15798. Expression.Call(
  15799. null,
  15800. #if CRIPPLED_REFLECTION
  15801. InfoOf(() => Qbservable.ToLookup<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>))),
  15802. #else
  15803. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  15804. #endif
  15805. source.Expression,
  15806. keySelector,
  15807. elementSelector
  15808. )
  15809. );
  15810. }
  15811. /// <summary>
  15812. /// Creates a lookup from an observable sequence according to a specified key selector function, a comparer, and an element selector function.
  15813. /// </summary>
  15814. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15815. /// <typeparam name="TKey">The type of the lookup key computed for each element in the source sequence.</typeparam>
  15816. /// <typeparam name="TElement">The type of the lookup value computed for each element in the source sequence.</typeparam>
  15817. /// <param name="source">An observable sequence to create a lookup for.</param>
  15818. /// <param name="keySelector">A function to extract a key from each element.</param>
  15819. /// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
  15820. /// <param name="comparer">An equality comparer to compare keys.</param>
  15821. /// <returns>An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.</returns>
  15822. /// <exception cref="T:System.ArgumentNullException">
  15823. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="comparer" /> is null.</exception>
  15824. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15825. 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)
  15826. {
  15827. if (source == null)
  15828. throw new ArgumentNullException("source");
  15829. if (keySelector == null)
  15830. throw new ArgumentNullException("keySelector");
  15831. if (elementSelector == null)
  15832. throw new ArgumentNullException("elementSelector");
  15833. if (comparer == null)
  15834. throw new ArgumentNullException("comparer");
  15835. return source.Provider.CreateQuery<ILookup<TKey, TElement>>(
  15836. Expression.Call(
  15837. null,
  15838. #if CRIPPLED_REFLECTION
  15839. InfoOf(() => Qbservable.ToLookup<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(IEqualityComparer<TKey>))),
  15840. #else
  15841. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  15842. #endif
  15843. source.Expression,
  15844. keySelector,
  15845. elementSelector,
  15846. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  15847. )
  15848. );
  15849. }
  15850. /// <summary>
  15851. /// Converts an enumerable sequence to an observable sequence.
  15852. /// </summary>
  15853. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  15854. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15855. /// <param name="source">Enumerable sequence to convert to an observable sequence.</param>
  15856. /// <returns>The observable sequence whose elements are pulled from the given enumerable sequence.</returns>
  15857. /// <exception cref="T:System.ArgumentNullException">
  15858. /// <paramref name="source" /> is null.</exception>
  15859. public static IQbservable<TSource> ToObservable<TSource>(this IQbservableProvider provider, IEnumerable<TSource> source)
  15860. {
  15861. if (provider == null)
  15862. throw new ArgumentNullException("provider");
  15863. if (source == null)
  15864. throw new ArgumentNullException("source");
  15865. return provider.CreateQuery<TSource>(
  15866. Expression.Call(
  15867. null,
  15868. #if CRIPPLED_REFLECTION
  15869. InfoOf(() => Qbservable.ToObservable<TSource>(default(IQbservableProvider), default(IEnumerable<TSource>))),
  15870. #else
  15871. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15872. #endif
  15873. Expression.Constant(provider, typeof(IQbservableProvider)),
  15874. GetSourceExpression(source)
  15875. )
  15876. );
  15877. }
  15878. /// <summary>
  15879. /// Converts an enumerable sequence to an observable sequence, using the specified scheduler to run the enumeration loop.
  15880. /// </summary>
  15881. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  15882. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15883. /// <param name="source">Enumerable sequence to convert to an observable sequence.</param>
  15884. /// <param name="scheduler">Scheduler to run the enumeration of the input sequence on.</param>
  15885. /// <returns>The observable sequence whose elements are pulled from the given enumerable sequence.</returns>
  15886. /// <exception cref="T:System.ArgumentNullException">
  15887. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  15888. public static IQbservable<TSource> ToObservable<TSource>(this IQbservableProvider provider, IEnumerable<TSource> source, IScheduler scheduler)
  15889. {
  15890. if (provider == null)
  15891. throw new ArgumentNullException("provider");
  15892. if (source == null)
  15893. throw new ArgumentNullException("source");
  15894. if (scheduler == null)
  15895. throw new ArgumentNullException("scheduler");
  15896. return provider.CreateQuery<TSource>(
  15897. Expression.Call(
  15898. null,
  15899. #if CRIPPLED_REFLECTION
  15900. InfoOf(() => Qbservable.ToObservable<TSource>(default(IQbservableProvider), default(IEnumerable<TSource>), default(IScheduler))),
  15901. #else
  15902. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15903. #endif
  15904. Expression.Constant(provider, typeof(IQbservableProvider)),
  15905. GetSourceExpression(source),
  15906. Expression.Constant(scheduler, typeof(IScheduler))
  15907. )
  15908. );
  15909. }
  15910. /// <summary>
  15911. /// Constructs an observable sequence that depends on a resource object, whose lifetime is tied to the resulting observable sequence's lifetime.
  15912. /// </summary>
  15913. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  15914. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  15915. /// <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>
  15916. /// <param name="resourceFactory">Factory function to obtain a resource object.</param>
  15917. /// <param name="observableFactory">Factory function to obtain an observable sequence that depends on the obtained resource.</param>
  15918. /// <returns>An observable sequence whose lifetime controls the lifetime of the dependent resource object.</returns>
  15919. /// <exception cref="T:System.ArgumentNullException">
  15920. /// <paramref name="resourceFactory" /> or <paramref name="observableFactory" /> is null.</exception>
  15921. public static IQbservable<TResult> Using<TResult, TResource>(this IQbservableProvider provider, Expression<Func<TResource>> resourceFactory, Expression<Func<TResource, IObservable<TResult>>> observableFactory)
  15922. where TResource : IDisposable
  15923. {
  15924. if (provider == null)
  15925. throw new ArgumentNullException("provider");
  15926. if (resourceFactory == null)
  15927. throw new ArgumentNullException("resourceFactory");
  15928. if (observableFactory == null)
  15929. throw new ArgumentNullException("observableFactory");
  15930. return provider.CreateQuery<TResult>(
  15931. Expression.Call(
  15932. null,
  15933. #if CRIPPLED_REFLECTION
  15934. InfoOf(() => Qbservable.Using<TResult, TResource>(default(IQbservableProvider), default(Expression<Func<TResource>>), default(Expression<Func<TResource, IObservable<TResult>>>))),
  15935. #else
  15936. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult), typeof(TResource)),
  15937. #endif
  15938. Expression.Constant(provider, typeof(IQbservableProvider)),
  15939. resourceFactory,
  15940. observableFactory
  15941. )
  15942. );
  15943. }
  15944. #if !NO_TPL
  15945. /// <summary>
  15946. /// 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.
  15947. /// 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.
  15948. /// </summary>
  15949. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  15950. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  15951. /// <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>
  15952. /// <param name="resourceFactoryAsync">Asynchronous factory function to obtain a resource object.</param>
  15953. /// <param name="observableFactoryAsync">Asynchronous factory function to obtain an observable sequence that depends on the obtained resource.</param>
  15954. /// <returns>An observable sequence whose lifetime controls the lifetime of the dependent resource object.</returns>
  15955. /// <exception cref="T:System.ArgumentNullException">
  15956. /// <paramref name="resourceFactoryAsync" /> or <paramref name="observableFactoryAsync" /> is null.</exception>
  15957. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  15958. /// <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>
  15959. public static IQbservable<TResult> Using<TResult, TResource>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<TResource>>> resourceFactoryAsync, Expression<Func<TResource, CancellationToken, Task<IObservable<TResult>>>> observableFactoryAsync)
  15960. where TResource : IDisposable
  15961. {
  15962. if (provider == null)
  15963. throw new ArgumentNullException("provider");
  15964. if (resourceFactoryAsync == null)
  15965. throw new ArgumentNullException("resourceFactoryAsync");
  15966. if (observableFactoryAsync == null)
  15967. throw new ArgumentNullException("observableFactoryAsync");
  15968. return provider.CreateQuery<TResult>(
  15969. Expression.Call(
  15970. null,
  15971. #if CRIPPLED_REFLECTION
  15972. InfoOf(() => Qbservable.Using<TResult, TResource>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<TResource>>>), default(Expression<Func<TResource, CancellationToken, Task<IObservable<TResult>>>>))),
  15973. #else
  15974. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult), typeof(TResource)),
  15975. #endif
  15976. Expression.Constant(provider, typeof(IQbservableProvider)),
  15977. resourceFactoryAsync,
  15978. observableFactoryAsync
  15979. )
  15980. );
  15981. }
  15982. #endif
  15983. /// <summary>
  15984. /// Filters the elements of an observable sequence based on a predicate.
  15985. /// </summary>
  15986. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15987. /// <param name="source">An observable sequence whose elements to filter.</param>
  15988. /// <param name="predicate">A function to test each source element for a condition.</param>
  15989. /// <returns>An observable sequence that contains elements from the input sequence that satisfy the condition.</returns>
  15990. /// <exception cref="T:System.ArgumentNullException">
  15991. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  15992. public static IQbservable<TSource> Where<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  15993. {
  15994. if (source == null)
  15995. throw new ArgumentNullException("source");
  15996. if (predicate == null)
  15997. throw new ArgumentNullException("predicate");
  15998. return source.Provider.CreateQuery<TSource>(
  15999. Expression.Call(
  16000. null,
  16001. #if CRIPPLED_REFLECTION
  16002. InfoOf(() => Qbservable.Where<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  16003. #else
  16004. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16005. #endif
  16006. source.Expression,
  16007. predicate
  16008. )
  16009. );
  16010. }
  16011. /// <summary>
  16012. /// Filters the elements of an observable sequence based on a predicate by incorporating the element's index.
  16013. /// </summary>
  16014. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  16015. /// <param name="source">An observable sequence whose elements to filter.</param>
  16016. /// <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>
  16017. /// <returns>An observable sequence that contains elements from the input sequence that satisfy the condition.</returns>
  16018. /// <exception cref="T:System.ArgumentNullException">
  16019. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  16020. public static IQbservable<TSource> Where<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int, bool>> predicate)
  16021. {
  16022. if (source == null)
  16023. throw new ArgumentNullException("source");
  16024. if (predicate == null)
  16025. throw new ArgumentNullException("predicate");
  16026. return source.Provider.CreateQuery<TSource>(
  16027. Expression.Call(
  16028. null,
  16029. #if CRIPPLED_REFLECTION
  16030. InfoOf(() => Qbservable.Where<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, bool>>))),
  16031. #else
  16032. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16033. #endif
  16034. source.Expression,
  16035. predicate
  16036. )
  16037. );
  16038. }
  16039. /// <summary>
  16040. /// 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.
  16041. /// </summary>
  16042. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  16043. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  16044. /// <param name="source">Source to repeat as long as the <paramref name="condition" /> function evaluates to true.</param>
  16045. /// <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>
  16046. /// <returns>The observable sequence obtained by concatenating the <paramref name="source" /> sequence as long as the <paramref name="condition" /> holds.</returns>
  16047. /// <exception cref="T:System.ArgumentNullException">
  16048. /// <paramref name="condition" /> or <paramref name="source" /> is null.</exception>
  16049. public static IQbservable<TSource> While<TSource>(this IQbservableProvider provider, Expression<Func<bool>> condition, IObservable<TSource> source)
  16050. {
  16051. if (provider == null)
  16052. throw new ArgumentNullException("provider");
  16053. if (condition == null)
  16054. throw new ArgumentNullException("condition");
  16055. if (source == null)
  16056. throw new ArgumentNullException("source");
  16057. return provider.CreateQuery<TSource>(
  16058. Expression.Call(
  16059. null,
  16060. #if CRIPPLED_REFLECTION
  16061. InfoOf(() => Qbservable.While<TSource>(default(IQbservableProvider), default(Expression<Func<bool>>), default(IObservable<TSource>))),
  16062. #else
  16063. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16064. #endif
  16065. Expression.Constant(provider, typeof(IQbservableProvider)),
  16066. condition,
  16067. GetSourceExpression(source)
  16068. )
  16069. );
  16070. }
  16071. /// <summary>
  16072. /// Projects each element of an observable sequence into consecutive non-overlapping windows which are produced based on element count information.
  16073. /// </summary>
  16074. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16075. /// <param name="source">Source sequence to produce windows over.</param>
  16076. /// <param name="count">Length of each window.</param>
  16077. /// <returns>An observable sequence of windows.</returns>
  16078. /// <exception cref="T:System.ArgumentNullException">
  16079. /// <paramref name="source" /> is null.</exception>
  16080. /// <exception cref="T:System.ArgumentOutOfRangeException">
  16081. /// <paramref name="count" /> is less than or equal to zero.</exception>
  16082. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, int count)
  16083. {
  16084. if (source == null)
  16085. throw new ArgumentNullException("source");
  16086. return source.Provider.CreateQuery<IObservable<TSource>>(
  16087. Expression.Call(
  16088. null,
  16089. #if CRIPPLED_REFLECTION
  16090. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(int))),
  16091. #else
  16092. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16093. #endif
  16094. source.Expression,
  16095. Expression.Constant(count, typeof(int))
  16096. )
  16097. );
  16098. }
  16099. /// <summary>
  16100. /// Projects each element of an observable sequence into zero or more windows which are produced based on element count information.
  16101. /// </summary>
  16102. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16103. /// <param name="source">Source sequence to produce windows over.</param>
  16104. /// <param name="count">Length of each window.</param>
  16105. /// <param name="skip">Number of elements to skip between creation of consecutive windows.</param>
  16106. /// <returns>An observable sequence of windows.</returns>
  16107. /// <exception cref="T:System.ArgumentNullException">
  16108. /// <paramref name="source" /> is null.</exception>
  16109. /// <exception cref="T:System.ArgumentOutOfRangeException">
  16110. /// <paramref name="count" /> or <paramref name="skip" /> is less than or equal to zero.</exception>
  16111. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, int count, int skip)
  16112. {
  16113. if (source == null)
  16114. throw new ArgumentNullException("source");
  16115. return source.Provider.CreateQuery<IObservable<TSource>>(
  16116. Expression.Call(
  16117. null,
  16118. #if CRIPPLED_REFLECTION
  16119. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(int), default(int))),
  16120. #else
  16121. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16122. #endif
  16123. source.Expression,
  16124. Expression.Constant(count, typeof(int)),
  16125. Expression.Constant(skip, typeof(int))
  16126. )
  16127. );
  16128. }
  16129. /// <summary>
  16130. /// Projects each element of an observable sequence into consecutive non-overlapping windows which are produced based on timing information.
  16131. /// </summary>
  16132. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16133. /// <param name="source">Source sequence to produce windows over.</param>
  16134. /// <param name="timeSpan">Length of each window.</param>
  16135. /// <returns>The sequence of windows.</returns>
  16136. /// <exception cref="T:System.ArgumentNullException">
  16137. /// <paramref name="source" /> is null.</exception>
  16138. /// <exception cref="T:System.ArgumentOutOfRangeException">
  16139. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  16140. /// <remarks>
  16141. /// 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.
  16142. /// 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
  16143. /// 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.
  16144. /// </remarks>
  16145. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan)
  16146. {
  16147. if (source == null)
  16148. throw new ArgumentNullException("source");
  16149. return source.Provider.CreateQuery<IObservable<TSource>>(
  16150. Expression.Call(
  16151. null,
  16152. #if CRIPPLED_REFLECTION
  16153. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  16154. #else
  16155. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16156. #endif
  16157. source.Expression,
  16158. Expression.Constant(timeSpan, typeof(TimeSpan))
  16159. )
  16160. );
  16161. }
  16162. /// <summary>
  16163. /// 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.
  16164. /// 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.
  16165. /// </summary>
  16166. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16167. /// <param name="source">Source sequence to produce windows over.</param>
  16168. /// <param name="timeSpan">Maximum time length of a window.</param>
  16169. /// <param name="count">Maximum element count of a window.</param>
  16170. /// <returns>An observable sequence of windows.</returns>
  16171. /// <exception cref="T:System.ArgumentNullException">
  16172. /// <paramref name="source" /> is null.</exception>
  16173. /// <exception cref="T:System.ArgumentOutOfRangeException">
  16174. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero. -or- <paramref name="count" /> is less than or equal to zero.</exception>
  16175. /// <remarks>
  16176. /// 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.
  16177. /// 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
  16178. /// 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.
  16179. /// </remarks>
  16180. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, int count)
  16181. {
  16182. if (source == null)
  16183. throw new ArgumentNullException("source");
  16184. return source.Provider.CreateQuery<IObservable<TSource>>(
  16185. Expression.Call(
  16186. null,
  16187. #if CRIPPLED_REFLECTION
  16188. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(int))),
  16189. #else
  16190. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16191. #endif
  16192. source.Expression,
  16193. Expression.Constant(timeSpan, typeof(TimeSpan)),
  16194. Expression.Constant(count, typeof(int))
  16195. )
  16196. );
  16197. }
  16198. /// <summary>
  16199. /// 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.
  16200. /// 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.
  16201. /// </summary>
  16202. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16203. /// <param name="source">Source sequence to produce windows over.</param>
  16204. /// <param name="timeSpan">Maximum time length of a window.</param>
  16205. /// <param name="count">Maximum element count of a window.</param>
  16206. /// <param name="scheduler">Scheduler to run windowing timers on.</param>
  16207. /// <returns>An observable sequence of windows.</returns>
  16208. /// <exception cref="T:System.ArgumentNullException">
  16209. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  16210. /// <exception cref="T:System.ArgumentOutOfRangeException">
  16211. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero. -or- <paramref name="count" /> is less than or equal to zero.</exception>
  16212. /// <remarks>
  16213. /// 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.
  16214. /// 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
  16215. /// 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.
  16216. /// </remarks>
  16217. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, int count, IScheduler scheduler)
  16218. {
  16219. if (source == null)
  16220. throw new ArgumentNullException("source");
  16221. if (scheduler == null)
  16222. throw new ArgumentNullException("scheduler");
  16223. return source.Provider.CreateQuery<IObservable<TSource>>(
  16224. Expression.Call(
  16225. null,
  16226. #if CRIPPLED_REFLECTION
  16227. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(int), default(IScheduler))),
  16228. #else
  16229. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16230. #endif
  16231. source.Expression,
  16232. Expression.Constant(timeSpan, typeof(TimeSpan)),
  16233. Expression.Constant(count, typeof(int)),
  16234. Expression.Constant(scheduler, typeof(IScheduler))
  16235. )
  16236. );
  16237. }
  16238. /// <summary>
  16239. /// 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.
  16240. /// </summary>
  16241. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16242. /// <param name="source">Source sequence to produce windows over.</param>
  16243. /// <param name="timeSpan">Length of each window.</param>
  16244. /// <param name="scheduler">Scheduler to run windowing timers on.</param>
  16245. /// <returns>An observable sequence of windows.</returns>
  16246. /// <exception cref="T:System.ArgumentNullException">
  16247. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  16248. /// <exception cref="T:System.ArgumentOutOfRangeException">
  16249. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  16250. /// <remarks>
  16251. /// 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.
  16252. /// 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
  16253. /// 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.
  16254. /// </remarks>
  16255. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, IScheduler scheduler)
  16256. {
  16257. if (source == null)
  16258. throw new ArgumentNullException("source");
  16259. if (scheduler == null)
  16260. throw new ArgumentNullException("scheduler");
  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(TimeSpan), default(IScheduler))),
  16266. #else
  16267. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16268. #endif
  16269. source.Expression,
  16270. Expression.Constant(timeSpan, typeof(TimeSpan)),
  16271. Expression.Constant(scheduler, typeof(IScheduler))
  16272. )
  16273. );
  16274. }
  16275. /// <summary>
  16276. /// Projects each element of an observable sequence into zero or more windows which are produced based on timing information.
  16277. /// </summary>
  16278. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16279. /// <param name="source">Source sequence to produce windows over.</param>
  16280. /// <param name="timeSpan">Length of each window.</param>
  16281. /// <param name="timeShift">Interval between creation of consecutive windows.</param>
  16282. /// <returns>An observable sequence of windows.</returns>
  16283. /// <exception cref="T:System.ArgumentNullException">
  16284. /// <paramref name="source" /> is null.</exception>
  16285. /// <exception cref="T:System.ArgumentOutOfRangeException">
  16286. /// <paramref name="timeSpan" /> or <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  16287. /// <remarks>
  16288. /// <para>
  16289. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create windows with minimum duration
  16290. /// 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
  16291. /// current window may not execute immediately, despite the TimeSpan.Zero due time.
  16292. /// </para>
  16293. /// <para>
  16294. /// 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.
  16295. /// 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,
  16296. /// where the action to create a new window may not execute immediately, despite the TimeSpan.Zero due time.
  16297. /// </para>
  16298. /// </remarks>
  16299. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, TimeSpan timeShift)
  16300. {
  16301. if (source == null)
  16302. throw new ArgumentNullException("source");
  16303. return source.Provider.CreateQuery<IObservable<TSource>>(
  16304. Expression.Call(
  16305. null,
  16306. #if CRIPPLED_REFLECTION
  16307. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(TimeSpan))),
  16308. #else
  16309. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16310. #endif
  16311. source.Expression,
  16312. Expression.Constant(timeSpan, typeof(TimeSpan)),
  16313. Expression.Constant(timeShift, typeof(TimeSpan))
  16314. )
  16315. );
  16316. }
  16317. /// <summary>
  16318. /// 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.
  16319. /// </summary>
  16320. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16321. /// <param name="source">Source sequence to produce windows over.</param>
  16322. /// <param name="timeSpan">Length of each window.</param>
  16323. /// <param name="timeShift">Interval between creation of consecutive windows.</param>
  16324. /// <param name="scheduler">Scheduler to run windowing timers on.</param>
  16325. /// <returns>An observable sequence of windows.</returns>
  16326. /// <exception cref="T:System.ArgumentNullException">
  16327. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  16328. /// <exception cref="T:System.ArgumentOutOfRangeException">
  16329. /// <paramref name="timeSpan" /> or <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  16330. /// <remarks>
  16331. /// <para>
  16332. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create windows with minimum duration
  16333. /// 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
  16334. /// current window may not execute immediately, despite the TimeSpan.Zero due time.
  16335. /// </para>
  16336. /// <para>
  16337. /// 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.
  16338. /// 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,
  16339. /// where the action to create a new window may not execute immediately, despite the TimeSpan.Zero due time.
  16340. /// </para>
  16341. /// </remarks>
  16342. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, TimeSpan timeShift, IScheduler scheduler)
  16343. {
  16344. if (source == null)
  16345. throw new ArgumentNullException("source");
  16346. if (scheduler == null)
  16347. throw new ArgumentNullException("scheduler");
  16348. return source.Provider.CreateQuery<IObservable<TSource>>(
  16349. Expression.Call(
  16350. null,
  16351. #if CRIPPLED_REFLECTION
  16352. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(TimeSpan), default(IScheduler))),
  16353. #else
  16354. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16355. #endif
  16356. source.Expression,
  16357. Expression.Constant(timeSpan, typeof(TimeSpan)),
  16358. Expression.Constant(timeShift, typeof(TimeSpan)),
  16359. Expression.Constant(scheduler, typeof(IScheduler))
  16360. )
  16361. );
  16362. }
  16363. /// <summary>
  16364. /// Projects each element of an observable sequence into consecutive non-overlapping windows.
  16365. /// </summary>
  16366. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16367. /// <typeparam name="TWindowBoundary">The type of the elements in the sequences indicating window boundary events.</typeparam>
  16368. /// <param name="source">Source sequence to produce windows over.</param>
  16369. /// <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>
  16370. /// <returns>An observable sequence of windows.</returns>
  16371. /// <exception cref="T:System.ArgumentNullException">
  16372. /// <paramref name="source" /> or <paramref name="windowBoundaries" /> is null.</exception>
  16373. public static IQbservable<IObservable<TSource>> Window<TSource, TWindowBoundary>(this IQbservable<TSource> source, IObservable<TWindowBoundary> windowBoundaries)
  16374. {
  16375. if (source == null)
  16376. throw new ArgumentNullException("source");
  16377. if (windowBoundaries == null)
  16378. throw new ArgumentNullException("windowBoundaries");
  16379. return source.Provider.CreateQuery<IObservable<TSource>>(
  16380. Expression.Call(
  16381. null,
  16382. #if CRIPPLED_REFLECTION
  16383. InfoOf(() => Qbservable.Window<TSource, TWindowBoundary>(default(IQbservable<TSource>), default(IObservable<TWindowBoundary>))),
  16384. #else
  16385. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TWindowBoundary)),
  16386. #endif
  16387. source.Expression,
  16388. GetSourceExpression(windowBoundaries)
  16389. )
  16390. );
  16391. }
  16392. /// <summary>
  16393. /// Projects each element of an observable sequence into consecutive non-overlapping windows.
  16394. /// </summary>
  16395. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16396. /// <typeparam name="TWindowClosing">The type of the elements in the sequences indicating window closing events.</typeparam>
  16397. /// <param name="source">Source sequence to produce windows over.</param>
  16398. /// <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>
  16399. /// <returns>An observable sequence of windows.</returns>
  16400. /// <exception cref="T:System.ArgumentNullException">
  16401. /// <paramref name="source" /> or <paramref name="windowClosingSelector" /> is null.</exception>
  16402. public static IQbservable<IObservable<TSource>> Window<TSource, TWindowClosing>(this IQbservable<TSource> source, Expression<Func<IObservable<TWindowClosing>>> windowClosingSelector)
  16403. {
  16404. if (source == null)
  16405. throw new ArgumentNullException("source");
  16406. if (windowClosingSelector == null)
  16407. throw new ArgumentNullException("windowClosingSelector");
  16408. return source.Provider.CreateQuery<IObservable<TSource>>(
  16409. Expression.Call(
  16410. null,
  16411. #if CRIPPLED_REFLECTION
  16412. InfoOf(() => Qbservable.Window<TSource, TWindowClosing>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TWindowClosing>>>))),
  16413. #else
  16414. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TWindowClosing)),
  16415. #endif
  16416. source.Expression,
  16417. windowClosingSelector
  16418. )
  16419. );
  16420. }
  16421. /// <summary>
  16422. /// Projects each element of an observable sequence into zero or more windows.
  16423. /// </summary>
  16424. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16425. /// <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>
  16426. /// <typeparam name="TWindowClosing">The type of the elements in the sequences indicating window closing events.</typeparam>
  16427. /// <param name="source">Source sequence to produce windows over.</param>
  16428. /// <param name="windowOpenings">Observable sequence whose elements denote the creation of new windows.</param>
  16429. /// <param name="windowClosingSelector">A function invoked to define the closing of each produced window.</param>
  16430. /// <returns>An observable sequence of windows.</returns>
  16431. /// <exception cref="T:System.ArgumentNullException">
  16432. /// <paramref name="source" /> or <paramref name="windowOpenings" /> or <paramref name="windowClosingSelector" /> is null.</exception>
  16433. public static IQbservable<IObservable<TSource>> Window<TSource, TWindowOpening, TWindowClosing>(this IQbservable<TSource> source, IObservable<TWindowOpening> windowOpenings, Expression<Func<TWindowOpening, IObservable<TWindowClosing>>> windowClosingSelector)
  16434. {
  16435. if (source == null)
  16436. throw new ArgumentNullException("source");
  16437. if (windowOpenings == null)
  16438. throw new ArgumentNullException("windowOpenings");
  16439. if (windowClosingSelector == null)
  16440. throw new ArgumentNullException("windowClosingSelector");
  16441. return source.Provider.CreateQuery<IObservable<TSource>>(
  16442. Expression.Call(
  16443. null,
  16444. #if CRIPPLED_REFLECTION
  16445. InfoOf(() => Qbservable.Window<TSource, TWindowOpening, TWindowClosing>(default(IQbservable<TSource>), default(IObservable<TWindowOpening>), default(Expression<Func<TWindowOpening, IObservable<TWindowClosing>>>))),
  16446. #else
  16447. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TWindowOpening), typeof(TWindowClosing)),
  16448. #endif
  16449. source.Expression,
  16450. GetSourceExpression(windowOpenings),
  16451. windowClosingSelector
  16452. )
  16453. );
  16454. }
  16455. /// <summary>
  16456. /// Merges two observable sequences into one observable sequence by combining each element from the first source with the latest element from the second source, if any.
  16457. /// </summary>
  16458. /// <typeparam name="TFirst">The type of the elements in the first source sequence.</typeparam>
  16459. /// <typeparam name="TSecond">The type of the elements in the second source sequence.</typeparam>
  16460. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16461. /// <param name="first">First observable source.</param>
  16462. /// <param name="second">Second observable source.</param>
  16463. /// <param name="resultSelector">Function to invoke for each element from the first source combined with the latest element from the second source, if any.</param>
  16464. /// <returns>An observable sequence containing the result of combining each element of the first source with the latest element from the second source, if any, using the specified result selector function.</returns>
  16465. /// <exception cref="T:System.ArgumentNullException">
  16466. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="resultSelector" /> is null.</exception>
  16467. public static IQbservable<TResult> WithLatestFrom<TFirst, TSecond, TResult>(this IQbservable<TFirst> first, IObservable<TSecond> second, Expression<Func<TFirst, TSecond, TResult>> resultSelector)
  16468. {
  16469. if (first == null)
  16470. throw new ArgumentNullException("first");
  16471. if (second == null)
  16472. throw new ArgumentNullException("second");
  16473. if (resultSelector == null)
  16474. throw new ArgumentNullException("resultSelector");
  16475. return first.Provider.CreateQuery<TResult>(
  16476. Expression.Call(
  16477. null,
  16478. #if CRIPPLED_REFLECTION
  16479. InfoOf(() => Qbservable.WithLatestFrom<TFirst, TSecond, TResult>(default(IQbservable<TFirst>), default(IObservable<TSecond>), default(Expression<Func<TFirst, TSecond, TResult>>))),
  16480. #else
  16481. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TResult)),
  16482. #endif
  16483. first.Expression,
  16484. GetSourceExpression(second),
  16485. resultSelector
  16486. )
  16487. );
  16488. }
  16489. /// <summary>
  16490. /// Merges the specified observable sequences into one observable sequence by emitting a list with the elements of the observable sequences at corresponding indexes.
  16491. /// </summary>
  16492. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  16493. /// <typeparam name="TSource">The type of the elements in the source sequences, and in the lists in the result sequence.</typeparam>
  16494. /// <param name="sources">Observable sources.</param>
  16495. /// <returns>An observable sequence containing lists of elements at corresponding indexes.</returns>
  16496. /// <exception cref="T:System.ArgumentNullException">
  16497. /// <paramref name="sources" /> is null.</exception>
  16498. public static IQbservable<IList<TSource>> Zip<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  16499. {
  16500. if (provider == null)
  16501. throw new ArgumentNullException("provider");
  16502. if (sources == null)
  16503. throw new ArgumentNullException("sources");
  16504. return provider.CreateQuery<IList<TSource>>(
  16505. Expression.Call(
  16506. null,
  16507. #if CRIPPLED_REFLECTION
  16508. InfoOf(() => Qbservable.Zip<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  16509. #else
  16510. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16511. #endif
  16512. Expression.Constant(provider, typeof(IQbservableProvider)),
  16513. GetSourceExpression(sources)
  16514. )
  16515. );
  16516. }
  16517. /// <summary>
  16518. /// Merges the specified observable sequences into one observable sequence by emitting a list with the elements of the observable sequences at corresponding indexes.
  16519. /// </summary>
  16520. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  16521. /// <typeparam name="TSource">The type of the elements in the source sequences, and in the lists in the result sequence.</typeparam>
  16522. /// <param name="sources">Observable sources.</param>
  16523. /// <returns>An observable sequence containing lists of elements at corresponding indexes.</returns>
  16524. /// <exception cref="T:System.ArgumentNullException">
  16525. /// <paramref name="sources" /> is null.</exception>
  16526. public static IQbservable<IList<TSource>> Zip<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  16527. {
  16528. if (provider == null)
  16529. throw new ArgumentNullException("provider");
  16530. if (sources == null)
  16531. throw new ArgumentNullException("sources");
  16532. return provider.CreateQuery<IList<TSource>>(
  16533. Expression.Call(
  16534. null,
  16535. #if CRIPPLED_REFLECTION
  16536. InfoOf(() => Qbservable.Zip<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  16537. #else
  16538. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16539. #endif
  16540. Expression.Constant(provider, typeof(IQbservableProvider)),
  16541. GetSourceExpression(sources)
  16542. )
  16543. );
  16544. }
  16545. /// <summary>
  16546. /// 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.
  16547. /// </summary>
  16548. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  16549. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  16550. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16551. /// <param name="sources">Observable sources.</param>
  16552. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16553. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16554. /// <exception cref="T:System.ArgumentNullException">
  16555. /// <paramref name="sources" /> or <paramref name="resultSelector" /> is null.</exception>
  16556. public static IQbservable<TResult> Zip<TSource, TResult>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, Expression<Func<IList<TSource>, TResult>> resultSelector)
  16557. {
  16558. if (provider == null)
  16559. throw new ArgumentNullException("provider");
  16560. if (sources == null)
  16561. throw new ArgumentNullException("sources");
  16562. if (resultSelector == null)
  16563. throw new ArgumentNullException("resultSelector");
  16564. return provider.CreateQuery<TResult>(
  16565. Expression.Call(
  16566. null,
  16567. #if CRIPPLED_REFLECTION
  16568. InfoOf(() => Qbservable.Zip<TSource, TResult>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(Expression<Func<IList<TSource>, TResult>>))),
  16569. #else
  16570. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  16571. #endif
  16572. Expression.Constant(provider, typeof(IQbservableProvider)),
  16573. GetSourceExpression(sources),
  16574. resultSelector
  16575. )
  16576. );
  16577. }
  16578. /// <summary>
  16579. /// Merges two observable sequences into one observable sequence by combining their elements in a pairwise fashion.
  16580. /// </summary>
  16581. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16582. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16583. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16584. /// <param name="first">First observable source.</param>
  16585. /// <param name="second">Second observable source.</param>
  16586. /// <param name="resultSelector">Function to invoke for each consecutive pair of elements from the first and second source.</param>
  16587. /// <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>
  16588. /// <exception cref="T:System.ArgumentNullException">
  16589. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="resultSelector" /> is null.</exception>
  16590. public static IQbservable<TResult> Zip<TSource1, TSource2, TResult>(this IQbservable<TSource1> first, IObservable<TSource2> second, Expression<Func<TSource1, TSource2, TResult>> resultSelector)
  16591. {
  16592. if (first == null)
  16593. throw new ArgumentNullException("first");
  16594. if (second == null)
  16595. throw new ArgumentNullException("second");
  16596. if (resultSelector == null)
  16597. throw new ArgumentNullException("resultSelector");
  16598. return first.Provider.CreateQuery<TResult>(
  16599. Expression.Call(
  16600. null,
  16601. #if CRIPPLED_REFLECTION
  16602. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(Expression<Func<TSource1, TSource2, TResult>>))),
  16603. #else
  16604. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TResult)),
  16605. #endif
  16606. first.Expression,
  16607. GetSourceExpression(second),
  16608. resultSelector
  16609. )
  16610. );
  16611. }
  16612. /// <summary>
  16613. /// Merges an observable sequence and an enumerable sequence into one observable sequence by using the selector function.
  16614. /// </summary>
  16615. /// <typeparam name="TSource1">The type of the elements in the first observable source sequence.</typeparam>
  16616. /// <typeparam name="TSource2">The type of the elements in the second enumerable source sequence.</typeparam>
  16617. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16618. /// <param name="first">First observable source.</param>
  16619. /// <param name="second">Second enumerable source.</param>
  16620. /// <param name="resultSelector">Function to invoke for each consecutive pair of elements from the first and second source.</param>
  16621. /// <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>
  16622. /// <exception cref="T:System.ArgumentNullException">
  16623. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="resultSelector" /> is null.</exception>
  16624. public static IQbservable<TResult> Zip<TSource1, TSource2, TResult>(this IQbservable<TSource1> first, IEnumerable<TSource2> second, Expression<Func<TSource1, TSource2, TResult>> resultSelector)
  16625. {
  16626. if (first == null)
  16627. throw new ArgumentNullException("first");
  16628. if (second == null)
  16629. throw new ArgumentNullException("second");
  16630. if (resultSelector == null)
  16631. throw new ArgumentNullException("resultSelector");
  16632. return first.Provider.CreateQuery<TResult>(
  16633. Expression.Call(
  16634. null,
  16635. #if CRIPPLED_REFLECTION
  16636. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TResult>(default(IQbservable<TSource1>), default(IEnumerable<TSource2>), default(Expression<Func<TSource1, TSource2, TResult>>))),
  16637. #else
  16638. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TResult)),
  16639. #endif
  16640. first.Expression,
  16641. GetSourceExpression(second),
  16642. resultSelector
  16643. )
  16644. );
  16645. }
  16646. /// <summary>
  16647. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
  16648. /// </summary>
  16649. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16650. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16651. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16652. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16653. /// <param name="source1">First observable source.</param>
  16654. /// <param name="source2">Second observable source.</param>
  16655. /// <param name="source3">Third observable source.</param>
  16656. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16657. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16658. /// <exception cref="T:System.ArgumentNullException">
  16659. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="resultSelector" /> is null.</exception>
  16660. 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)
  16661. {
  16662. if (source1 == null)
  16663. throw new ArgumentNullException("source1");
  16664. if (source2 == null)
  16665. throw new ArgumentNullException("source2");
  16666. if (source3 == null)
  16667. throw new ArgumentNullException("source3");
  16668. if (resultSelector == null)
  16669. throw new ArgumentNullException("resultSelector");
  16670. return source1.Provider.CreateQuery<TResult>(
  16671. Expression.Call(
  16672. null,
  16673. #if CRIPPLED_REFLECTION
  16674. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TSource3, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(Expression<Func<TSource1, TSource2, TSource3, TResult>>))),
  16675. #else
  16676. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TResult)),
  16677. #endif
  16678. source1.Expression,
  16679. GetSourceExpression(source2),
  16680. GetSourceExpression(source3),
  16681. resultSelector
  16682. )
  16683. );
  16684. }
  16685. /// <summary>
  16686. /// 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.
  16687. /// </summary>
  16688. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16689. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16690. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16691. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16692. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16693. /// <param name="source1">First observable source.</param>
  16694. /// <param name="source2">Second observable source.</param>
  16695. /// <param name="source3">Third observable source.</param>
  16696. /// <param name="source4">Fourth observable source.</param>
  16697. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16698. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16699. /// <exception cref="T:System.ArgumentNullException">
  16700. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="resultSelector" /> is null.</exception>
  16701. 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)
  16702. {
  16703. if (source1 == null)
  16704. throw new ArgumentNullException("source1");
  16705. if (source2 == null)
  16706. throw new ArgumentNullException("source2");
  16707. if (source3 == null)
  16708. throw new ArgumentNullException("source3");
  16709. if (source4 == null)
  16710. throw new ArgumentNullException("source4");
  16711. if (resultSelector == null)
  16712. throw new ArgumentNullException("resultSelector");
  16713. return source1.Provider.CreateQuery<TResult>(
  16714. Expression.Call(
  16715. null,
  16716. #if CRIPPLED_REFLECTION
  16717. 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>>))),
  16718. #else
  16719. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TResult)),
  16720. #endif
  16721. source1.Expression,
  16722. GetSourceExpression(source2),
  16723. GetSourceExpression(source3),
  16724. GetSourceExpression(source4),
  16725. resultSelector
  16726. )
  16727. );
  16728. }
  16729. #if !NO_LARGEARITY
  16730. /// <summary>
  16731. /// 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.
  16732. /// </summary>
  16733. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16734. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16735. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16736. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16737. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16738. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16739. /// <param name="source1">First observable source.</param>
  16740. /// <param name="source2">Second observable source.</param>
  16741. /// <param name="source3">Third observable source.</param>
  16742. /// <param name="source4">Fourth observable source.</param>
  16743. /// <param name="source5">Fifth observable source.</param>
  16744. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16745. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16746. /// <exception cref="T:System.ArgumentNullException">
  16747. /// <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>
  16748. 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)
  16749. {
  16750. if (source1 == null)
  16751. throw new ArgumentNullException("source1");
  16752. if (source2 == null)
  16753. throw new ArgumentNullException("source2");
  16754. if (source3 == null)
  16755. throw new ArgumentNullException("source3");
  16756. if (source4 == null)
  16757. throw new ArgumentNullException("source4");
  16758. if (source5 == null)
  16759. throw new ArgumentNullException("source5");
  16760. if (resultSelector == null)
  16761. throw new ArgumentNullException("resultSelector");
  16762. return source1.Provider.CreateQuery<TResult>(
  16763. Expression.Call(
  16764. null,
  16765. #if CRIPPLED_REFLECTION
  16766. 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>>))),
  16767. #else
  16768. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TResult)),
  16769. #endif
  16770. source1.Expression,
  16771. GetSourceExpression(source2),
  16772. GetSourceExpression(source3),
  16773. GetSourceExpression(source4),
  16774. GetSourceExpression(source5),
  16775. resultSelector
  16776. )
  16777. );
  16778. }
  16779. #endif
  16780. #if !NO_LARGEARITY
  16781. /// <summary>
  16782. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
  16783. /// </summary>
  16784. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16785. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16786. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16787. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16788. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16789. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16790. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16791. /// <param name="source1">First observable source.</param>
  16792. /// <param name="source2">Second observable source.</param>
  16793. /// <param name="source3">Third observable source.</param>
  16794. /// <param name="source4">Fourth observable source.</param>
  16795. /// <param name="source5">Fifth observable source.</param>
  16796. /// <param name="source6">Sixth 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="source4" /> or <paramref name="source5" /> or <paramref name="source6" /> or <paramref name="resultSelector" /> is null.</exception>
  16801. 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)
  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 (source4 == null)
  16810. throw new ArgumentNullException("source4");
  16811. if (source5 == null)
  16812. throw new ArgumentNullException("source5");
  16813. if (source6 == null)
  16814. throw new ArgumentNullException("source6");
  16815. if (resultSelector == null)
  16816. throw new ArgumentNullException("resultSelector");
  16817. return source1.Provider.CreateQuery<TResult>(
  16818. Expression.Call(
  16819. null,
  16820. #if CRIPPLED_REFLECTION
  16821. 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>>))),
  16822. #else
  16823. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TResult)),
  16824. #endif
  16825. source1.Expression,
  16826. GetSourceExpression(source2),
  16827. GetSourceExpression(source3),
  16828. GetSourceExpression(source4),
  16829. GetSourceExpression(source5),
  16830. GetSourceExpression(source6),
  16831. resultSelector
  16832. )
  16833. );
  16834. }
  16835. #endif
  16836. #if !NO_LARGEARITY
  16837. /// <summary>
  16838. /// 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.
  16839. /// </summary>
  16840. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16841. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16842. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16843. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16844. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16845. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16846. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16847. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16848. /// <param name="source1">First observable source.</param>
  16849. /// <param name="source2">Second observable source.</param>
  16850. /// <param name="source3">Third observable source.</param>
  16851. /// <param name="source4">Fourth observable source.</param>
  16852. /// <param name="source5">Fifth observable source.</param>
  16853. /// <param name="source6">Sixth observable source.</param>
  16854. /// <param name="source7">Seventh observable source.</param>
  16855. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16856. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16857. /// <exception cref="T:System.ArgumentNullException">
  16858. /// <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>
  16859. 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)
  16860. {
  16861. if (source1 == null)
  16862. throw new ArgumentNullException("source1");
  16863. if (source2 == null)
  16864. throw new ArgumentNullException("source2");
  16865. if (source3 == null)
  16866. throw new ArgumentNullException("source3");
  16867. if (source4 == null)
  16868. throw new ArgumentNullException("source4");
  16869. if (source5 == null)
  16870. throw new ArgumentNullException("source5");
  16871. if (source6 == null)
  16872. throw new ArgumentNullException("source6");
  16873. if (source7 == null)
  16874. throw new ArgumentNullException("source7");
  16875. if (resultSelector == null)
  16876. throw new ArgumentNullException("resultSelector");
  16877. return source1.Provider.CreateQuery<TResult>(
  16878. Expression.Call(
  16879. null,
  16880. #if CRIPPLED_REFLECTION
  16881. 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>>))),
  16882. #else
  16883. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TResult)),
  16884. #endif
  16885. source1.Expression,
  16886. GetSourceExpression(source2),
  16887. GetSourceExpression(source3),
  16888. GetSourceExpression(source4),
  16889. GetSourceExpression(source5),
  16890. GetSourceExpression(source6),
  16891. GetSourceExpression(source7),
  16892. resultSelector
  16893. )
  16894. );
  16895. }
  16896. #endif
  16897. #if !NO_LARGEARITY
  16898. /// <summary>
  16899. /// 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.
  16900. /// </summary>
  16901. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16902. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16903. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16904. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16905. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16906. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16907. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16908. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  16909. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16910. /// <param name="source1">First observable source.</param>
  16911. /// <param name="source2">Second observable source.</param>
  16912. /// <param name="source3">Third observable source.</param>
  16913. /// <param name="source4">Fourth observable source.</param>
  16914. /// <param name="source5">Fifth observable source.</param>
  16915. /// <param name="source6">Sixth observable source.</param>
  16916. /// <param name="source7">Seventh observable source.</param>
  16917. /// <param name="source8">Eighth observable source.</param>
  16918. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16919. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16920. /// <exception cref="T:System.ArgumentNullException">
  16921. /// <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>
  16922. 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)
  16923. {
  16924. if (source1 == null)
  16925. throw new ArgumentNullException("source1");
  16926. if (source2 == null)
  16927. throw new ArgumentNullException("source2");
  16928. if (source3 == null)
  16929. throw new ArgumentNullException("source3");
  16930. if (source4 == null)
  16931. throw new ArgumentNullException("source4");
  16932. if (source5 == null)
  16933. throw new ArgumentNullException("source5");
  16934. if (source6 == null)
  16935. throw new ArgumentNullException("source6");
  16936. if (source7 == null)
  16937. throw new ArgumentNullException("source7");
  16938. if (source8 == null)
  16939. throw new ArgumentNullException("source8");
  16940. if (resultSelector == null)
  16941. throw new ArgumentNullException("resultSelector");
  16942. return source1.Provider.CreateQuery<TResult>(
  16943. Expression.Call(
  16944. null,
  16945. #if CRIPPLED_REFLECTION
  16946. 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>>))),
  16947. #else
  16948. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TResult)),
  16949. #endif
  16950. source1.Expression,
  16951. GetSourceExpression(source2),
  16952. GetSourceExpression(source3),
  16953. GetSourceExpression(source4),
  16954. GetSourceExpression(source5),
  16955. GetSourceExpression(source6),
  16956. GetSourceExpression(source7),
  16957. GetSourceExpression(source8),
  16958. resultSelector
  16959. )
  16960. );
  16961. }
  16962. #endif
  16963. #if !NO_LARGEARITY
  16964. /// <summary>
  16965. /// 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.
  16966. /// </summary>
  16967. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16968. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16969. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16970. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16971. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16972. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16973. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16974. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  16975. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  16976. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16977. /// <param name="source1">First observable source.</param>
  16978. /// <param name="source2">Second observable source.</param>
  16979. /// <param name="source3">Third observable source.</param>
  16980. /// <param name="source4">Fourth observable source.</param>
  16981. /// <param name="source5">Fifth observable source.</param>
  16982. /// <param name="source6">Sixth observable source.</param>
  16983. /// <param name="source7">Seventh observable source.</param>
  16984. /// <param name="source8">Eighth observable source.</param>
  16985. /// <param name="source9">Ninth observable source.</param>
  16986. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16987. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16988. /// <exception cref="T:System.ArgumentNullException">
  16989. /// <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>
  16990. 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)
  16991. {
  16992. if (source1 == null)
  16993. throw new ArgumentNullException("source1");
  16994. if (source2 == null)
  16995. throw new ArgumentNullException("source2");
  16996. if (source3 == null)
  16997. throw new ArgumentNullException("source3");
  16998. if (source4 == null)
  16999. throw new ArgumentNullException("source4");
  17000. if (source5 == null)
  17001. throw new ArgumentNullException("source5");
  17002. if (source6 == null)
  17003. throw new ArgumentNullException("source6");
  17004. if (source7 == null)
  17005. throw new ArgumentNullException("source7");
  17006. if (source8 == null)
  17007. throw new ArgumentNullException("source8");
  17008. if (source9 == null)
  17009. throw new ArgumentNullException("source9");
  17010. if (resultSelector == null)
  17011. throw new ArgumentNullException("resultSelector");
  17012. return source1.Provider.CreateQuery<TResult>(
  17013. Expression.Call(
  17014. null,
  17015. #if CRIPPLED_REFLECTION
  17016. 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>>))),
  17017. #else
  17018. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TSource9), typeof(TResult)),
  17019. #endif
  17020. source1.Expression,
  17021. GetSourceExpression(source2),
  17022. GetSourceExpression(source3),
  17023. GetSourceExpression(source4),
  17024. GetSourceExpression(source5),
  17025. GetSourceExpression(source6),
  17026. GetSourceExpression(source7),
  17027. GetSourceExpression(source8),
  17028. GetSourceExpression(source9),
  17029. resultSelector
  17030. )
  17031. );
  17032. }
  17033. #endif
  17034. #if !NO_LARGEARITY
  17035. /// <summary>
  17036. /// 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.
  17037. /// </summary>
  17038. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  17039. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  17040. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  17041. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  17042. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  17043. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  17044. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  17045. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  17046. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  17047. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  17048. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  17049. /// <param name="source1">First observable source.</param>
  17050. /// <param name="source2">Second observable source.</param>
  17051. /// <param name="source3">Third observable source.</param>
  17052. /// <param name="source4">Fourth observable source.</param>
  17053. /// <param name="source5">Fifth observable source.</param>
  17054. /// <param name="source6">Sixth observable source.</param>
  17055. /// <param name="source7">Seventh observable source.</param>
  17056. /// <param name="source8">Eighth observable source.</param>
  17057. /// <param name="source9">Ninth observable source.</param>
  17058. /// <param name="source10">Tenth 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="source9" /> or <paramref name="source10" /> or <paramref name="resultSelector" /> is null.</exception>
  17063. 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)
  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 (source9 == null)
  17082. throw new ArgumentNullException("source9");
  17083. if (source10 == null)
  17084. throw new ArgumentNullException("source10");
  17085. if (resultSelector == null)
  17086. throw new ArgumentNullException("resultSelector");
  17087. return source1.Provider.CreateQuery<TResult>(
  17088. Expression.Call(
  17089. null,
  17090. #if CRIPPLED_REFLECTION
  17091. 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>>))),
  17092. #else
  17093. ((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)),
  17094. #endif
  17095. source1.Expression,
  17096. GetSourceExpression(source2),
  17097. GetSourceExpression(source3),
  17098. GetSourceExpression(source4),
  17099. GetSourceExpression(source5),
  17100. GetSourceExpression(source6),
  17101. GetSourceExpression(source7),
  17102. GetSourceExpression(source8),
  17103. GetSourceExpression(source9),
  17104. GetSourceExpression(source10),
  17105. resultSelector
  17106. )
  17107. );
  17108. }
  17109. #endif
  17110. #if !NO_LARGEARITY
  17111. /// <summary>
  17112. /// 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.
  17113. /// </summary>
  17114. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  17115. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  17116. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  17117. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  17118. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  17119. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  17120. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  17121. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  17122. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  17123. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  17124. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  17125. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  17126. /// <param name="source1">First observable source.</param>
  17127. /// <param name="source2">Second observable source.</param>
  17128. /// <param name="source3">Third observable source.</param>
  17129. /// <param name="source4">Fourth observable source.</param>
  17130. /// <param name="source5">Fifth observable source.</param>
  17131. /// <param name="source6">Sixth observable source.</param>
  17132. /// <param name="source7">Seventh observable source.</param>
  17133. /// <param name="source8">Eighth observable source.</param>
  17134. /// <param name="source9">Ninth observable source.</param>
  17135. /// <param name="source10">Tenth observable source.</param>
  17136. /// <param name="source11">Eleventh observable source.</param>
  17137. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  17138. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  17139. /// <exception cref="T:System.ArgumentNullException">
  17140. /// <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>
  17141. 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)
  17142. {
  17143. if (source1 == null)
  17144. throw new ArgumentNullException("source1");
  17145. if (source2 == null)
  17146. throw new ArgumentNullException("source2");
  17147. if (source3 == null)
  17148. throw new ArgumentNullException("source3");
  17149. if (source4 == null)
  17150. throw new ArgumentNullException("source4");
  17151. if (source5 == null)
  17152. throw new ArgumentNullException("source5");
  17153. if (source6 == null)
  17154. throw new ArgumentNullException("source6");
  17155. if (source7 == null)
  17156. throw new ArgumentNullException("source7");
  17157. if (source8 == null)
  17158. throw new ArgumentNullException("source8");
  17159. if (source9 == null)
  17160. throw new ArgumentNullException("source9");
  17161. if (source10 == null)
  17162. throw new ArgumentNullException("source10");
  17163. if (source11 == null)
  17164. throw new ArgumentNullException("source11");
  17165. if (resultSelector == null)
  17166. throw new ArgumentNullException("resultSelector");
  17167. return source1.Provider.CreateQuery<TResult>(
  17168. Expression.Call(
  17169. null,
  17170. #if CRIPPLED_REFLECTION
  17171. 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>>))),
  17172. #else
  17173. ((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)),
  17174. #endif
  17175. source1.Expression,
  17176. GetSourceExpression(source2),
  17177. GetSourceExpression(source3),
  17178. GetSourceExpression(source4),
  17179. GetSourceExpression(source5),
  17180. GetSourceExpression(source6),
  17181. GetSourceExpression(source7),
  17182. GetSourceExpression(source8),
  17183. GetSourceExpression(source9),
  17184. GetSourceExpression(source10),
  17185. GetSourceExpression(source11),
  17186. resultSelector
  17187. )
  17188. );
  17189. }
  17190. #endif
  17191. #if !NO_LARGEARITY
  17192. /// <summary>
  17193. /// 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.
  17194. /// </summary>
  17195. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  17196. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  17197. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  17198. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  17199. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  17200. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  17201. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  17202. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  17203. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  17204. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  17205. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  17206. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  17207. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  17208. /// <param name="source1">First observable source.</param>
  17209. /// <param name="source2">Second observable source.</param>
  17210. /// <param name="source3">Third observable source.</param>
  17211. /// <param name="source4">Fourth observable source.</param>
  17212. /// <param name="source5">Fifth observable source.</param>
  17213. /// <param name="source6">Sixth observable source.</param>
  17214. /// <param name="source7">Seventh observable source.</param>
  17215. /// <param name="source8">Eighth observable source.</param>
  17216. /// <param name="source9">Ninth observable source.</param>
  17217. /// <param name="source10">Tenth observable source.</param>
  17218. /// <param name="source11">Eleventh observable source.</param>
  17219. /// <param name="source12">Twelfth observable source.</param>
  17220. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  17221. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  17222. /// <exception cref="T:System.ArgumentNullException">
  17223. /// <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>
  17224. 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)
  17225. {
  17226. if (source1 == null)
  17227. throw new ArgumentNullException("source1");
  17228. if (source2 == null)
  17229. throw new ArgumentNullException("source2");
  17230. if (source3 == null)
  17231. throw new ArgumentNullException("source3");
  17232. if (source4 == null)
  17233. throw new ArgumentNullException("source4");
  17234. if (source5 == null)
  17235. throw new ArgumentNullException("source5");
  17236. if (source6 == null)
  17237. throw new ArgumentNullException("source6");
  17238. if (source7 == null)
  17239. throw new ArgumentNullException("source7");
  17240. if (source8 == null)
  17241. throw new ArgumentNullException("source8");
  17242. if (source9 == null)
  17243. throw new ArgumentNullException("source9");
  17244. if (source10 == null)
  17245. throw new ArgumentNullException("source10");
  17246. if (source11 == null)
  17247. throw new ArgumentNullException("source11");
  17248. if (source12 == null)
  17249. throw new ArgumentNullException("source12");
  17250. if (resultSelector == null)
  17251. throw new ArgumentNullException("resultSelector");
  17252. return source1.Provider.CreateQuery<TResult>(
  17253. Expression.Call(
  17254. null,
  17255. #if CRIPPLED_REFLECTION
  17256. 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>>))),
  17257. #else
  17258. ((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)),
  17259. #endif
  17260. source1.Expression,
  17261. GetSourceExpression(source2),
  17262. GetSourceExpression(source3),
  17263. GetSourceExpression(source4),
  17264. GetSourceExpression(source5),
  17265. GetSourceExpression(source6),
  17266. GetSourceExpression(source7),
  17267. GetSourceExpression(source8),
  17268. GetSourceExpression(source9),
  17269. GetSourceExpression(source10),
  17270. GetSourceExpression(source11),
  17271. GetSourceExpression(source12),
  17272. resultSelector
  17273. )
  17274. );
  17275. }
  17276. #endif
  17277. #if !NO_LARGEARITY
  17278. /// <summary>
  17279. /// 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.
  17280. /// </summary>
  17281. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  17282. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  17283. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  17284. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  17285. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  17286. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  17287. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  17288. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  17289. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  17290. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  17291. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  17292. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  17293. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  17294. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  17295. /// <param name="source1">First observable source.</param>
  17296. /// <param name="source2">Second observable source.</param>
  17297. /// <param name="source3">Third observable source.</param>
  17298. /// <param name="source4">Fourth observable source.</param>
  17299. /// <param name="source5">Fifth observable source.</param>
  17300. /// <param name="source6">Sixth observable source.</param>
  17301. /// <param name="source7">Seventh observable source.</param>
  17302. /// <param name="source8">Eighth observable source.</param>
  17303. /// <param name="source9">Ninth observable source.</param>
  17304. /// <param name="source10">Tenth observable source.</param>
  17305. /// <param name="source11">Eleventh observable source.</param>
  17306. /// <param name="source12">Twelfth observable source.</param>
  17307. /// <param name="source13">Thirteenth observable source.</param>
  17308. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  17309. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  17310. /// <exception cref="T:System.ArgumentNullException">
  17311. /// <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>
  17312. 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)
  17313. {
  17314. if (source1 == null)
  17315. throw new ArgumentNullException("source1");
  17316. if (source2 == null)
  17317. throw new ArgumentNullException("source2");
  17318. if (source3 == null)
  17319. throw new ArgumentNullException("source3");
  17320. if (source4 == null)
  17321. throw new ArgumentNullException("source4");
  17322. if (source5 == null)
  17323. throw new ArgumentNullException("source5");
  17324. if (source6 == null)
  17325. throw new ArgumentNullException("source6");
  17326. if (source7 == null)
  17327. throw new ArgumentNullException("source7");
  17328. if (source8 == null)
  17329. throw new ArgumentNullException("source8");
  17330. if (source9 == null)
  17331. throw new ArgumentNullException("source9");
  17332. if (source10 == null)
  17333. throw new ArgumentNullException("source10");
  17334. if (source11 == null)
  17335. throw new ArgumentNullException("source11");
  17336. if (source12 == null)
  17337. throw new ArgumentNullException("source12");
  17338. if (source13 == null)
  17339. throw new ArgumentNullException("source13");
  17340. if (resultSelector == null)
  17341. throw new ArgumentNullException("resultSelector");
  17342. return source1.Provider.CreateQuery<TResult>(
  17343. Expression.Call(
  17344. null,
  17345. #if CRIPPLED_REFLECTION
  17346. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, 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>>))),
  17347. #else
  17348. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TSource9), typeof(TSource10), typeof(TSource11), typeof(TSource12), typeof(TSource13), typeof(TResult)),
  17349. #endif
  17350. source1.Expression,
  17351. GetSourceExpression(source2),
  17352. GetSourceExpression(source3),
  17353. GetSourceExpression(source4),
  17354. GetSourceExpression(source5),
  17355. GetSourceExpression(source6),
  17356. GetSourceExpression(source7),
  17357. GetSourceExpression(source8),
  17358. GetSourceExpression(source9),
  17359. GetSourceExpression(source10),
  17360. GetSourceExpression(source11),
  17361. GetSourceExpression(source12),
  17362. GetSourceExpression(source13),
  17363. resultSelector
  17364. )
  17365. );
  17366. }
  17367. #endif
  17368. #if !NO_LARGEARITY
  17369. /// <summary>
  17370. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
  17371. /// </summary>
  17372. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  17373. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  17374. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  17375. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  17376. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  17377. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  17378. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  17379. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  17380. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  17381. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  17382. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  17383. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  17384. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  17385. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  17386. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  17387. /// <param name="source1">First observable source.</param>
  17388. /// <param name="source2">Second observable source.</param>
  17389. /// <param name="source3">Third observable source.</param>
  17390. /// <param name="source4">Fourth observable source.</param>
  17391. /// <param name="source5">Fifth observable source.</param>
  17392. /// <param name="source6">Sixth observable source.</param>
  17393. /// <param name="source7">Seventh observable source.</param>
  17394. /// <param name="source8">Eighth observable source.</param>
  17395. /// <param name="source9">Ninth observable source.</param>
  17396. /// <param name="source10">Tenth observable source.</param>
  17397. /// <param name="source11">Eleventh observable source.</param>
  17398. /// <param name="source12">Twelfth observable source.</param>
  17399. /// <param name="source13">Thirteenth observable source.</param>
  17400. /// <param name="source14">Fourteenth observable source.</param>
  17401. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  17402. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  17403. /// <exception cref="T:System.ArgumentNullException">
  17404. /// <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>
  17405. 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)
  17406. {
  17407. if (source1 == null)
  17408. throw new ArgumentNullException("source1");
  17409. if (source2 == null)
  17410. throw new ArgumentNullException("source2");
  17411. if (source3 == null)
  17412. throw new ArgumentNullException("source3");
  17413. if (source4 == null)
  17414. throw new ArgumentNullException("source4");
  17415. if (source5 == null)
  17416. throw new ArgumentNullException("source5");
  17417. if (source6 == null)
  17418. throw new ArgumentNullException("source6");
  17419. if (source7 == null)
  17420. throw new ArgumentNullException("source7");
  17421. if (source8 == null)
  17422. throw new ArgumentNullException("source8");
  17423. if (source9 == null)
  17424. throw new ArgumentNullException("source9");
  17425. if (source10 == null)
  17426. throw new ArgumentNullException("source10");
  17427. if (source11 == null)
  17428. throw new ArgumentNullException("source11");
  17429. if (source12 == null)
  17430. throw new ArgumentNullException("source12");
  17431. if (source13 == null)
  17432. throw new ArgumentNullException("source13");
  17433. if (source14 == null)
  17434. throw new ArgumentNullException("source14");
  17435. if (resultSelector == null)
  17436. throw new ArgumentNullException("resultSelector");
  17437. return source1.Provider.CreateQuery<TResult>(
  17438. Expression.Call(
  17439. null,
  17440. #if CRIPPLED_REFLECTION
  17441. 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>>))),
  17442. #else
  17443. ((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)),
  17444. #endif
  17445. source1.Expression,
  17446. GetSourceExpression(source2),
  17447. GetSourceExpression(source3),
  17448. GetSourceExpression(source4),
  17449. GetSourceExpression(source5),
  17450. GetSourceExpression(source6),
  17451. GetSourceExpression(source7),
  17452. GetSourceExpression(source8),
  17453. GetSourceExpression(source9),
  17454. GetSourceExpression(source10),
  17455. GetSourceExpression(source11),
  17456. GetSourceExpression(source12),
  17457. GetSourceExpression(source13),
  17458. GetSourceExpression(source14),
  17459. resultSelector
  17460. )
  17461. );
  17462. }
  17463. #endif
  17464. #if !NO_LARGEARITY
  17465. /// <summary>
  17466. /// 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.
  17467. /// </summary>
  17468. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  17469. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  17470. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  17471. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  17472. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  17473. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  17474. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  17475. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  17476. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  17477. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  17478. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  17479. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  17480. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  17481. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  17482. /// <typeparam name="TSource15">The type of the elements in the fifteenth source sequence.</typeparam>
  17483. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  17484. /// <param name="source1">First observable source.</param>
  17485. /// <param name="source2">Second observable source.</param>
  17486. /// <param name="source3">Third observable source.</param>
  17487. /// <param name="source4">Fourth observable source.</param>
  17488. /// <param name="source5">Fifth observable source.</param>
  17489. /// <param name="source6">Sixth observable source.</param>
  17490. /// <param name="source7">Seventh observable source.</param>
  17491. /// <param name="source8">Eighth observable source.</param>
  17492. /// <param name="source9">Ninth observable source.</param>
  17493. /// <param name="source10">Tenth observable source.</param>
  17494. /// <param name="source11">Eleventh observable source.</param>
  17495. /// <param name="source12">Twelfth observable source.</param>
  17496. /// <param name="source13">Thirteenth observable source.</param>
  17497. /// <param name="source14">Fourteenth observable source.</param>
  17498. /// <param name="source15">Fifteenth observable source.</param>
  17499. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  17500. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  17501. /// <exception cref="T:System.ArgumentNullException">
  17502. /// <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>
  17503. 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)
  17504. {
  17505. if (source1 == null)
  17506. throw new ArgumentNullException("source1");
  17507. if (source2 == null)
  17508. throw new ArgumentNullException("source2");
  17509. if (source3 == null)
  17510. throw new ArgumentNullException("source3");
  17511. if (source4 == null)
  17512. throw new ArgumentNullException("source4");
  17513. if (source5 == null)
  17514. throw new ArgumentNullException("source5");
  17515. if (source6 == null)
  17516. throw new ArgumentNullException("source6");
  17517. if (source7 == null)
  17518. throw new ArgumentNullException("source7");
  17519. if (source8 == null)
  17520. throw new ArgumentNullException("source8");
  17521. if (source9 == null)
  17522. throw new ArgumentNullException("source9");
  17523. if (source10 == null)
  17524. throw new ArgumentNullException("source10");
  17525. if (source11 == null)
  17526. throw new ArgumentNullException("source11");
  17527. if (source12 == null)
  17528. throw new ArgumentNullException("source12");
  17529. if (source13 == null)
  17530. throw new ArgumentNullException("source13");
  17531. if (source14 == null)
  17532. throw new ArgumentNullException("source14");
  17533. if (source15 == null)
  17534. throw new ArgumentNullException("source15");
  17535. if (resultSelector == null)
  17536. throw new ArgumentNullException("resultSelector");
  17537. return source1.Provider.CreateQuery<TResult>(
  17538. Expression.Call(
  17539. null,
  17540. #if CRIPPLED_REFLECTION
  17541. 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>>))),
  17542. #else
  17543. ((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)),
  17544. #endif
  17545. source1.Expression,
  17546. GetSourceExpression(source2),
  17547. GetSourceExpression(source3),
  17548. GetSourceExpression(source4),
  17549. GetSourceExpression(source5),
  17550. GetSourceExpression(source6),
  17551. GetSourceExpression(source7),
  17552. GetSourceExpression(source8),
  17553. GetSourceExpression(source9),
  17554. GetSourceExpression(source10),
  17555. GetSourceExpression(source11),
  17556. GetSourceExpression(source12),
  17557. GetSourceExpression(source13),
  17558. GetSourceExpression(source14),
  17559. GetSourceExpression(source15),
  17560. resultSelector
  17561. )
  17562. );
  17563. }
  17564. #endif
  17565. #if !NO_LARGEARITY
  17566. /// <summary>
  17567. /// 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.
  17568. /// </summary>
  17569. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  17570. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  17571. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  17572. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  17573. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  17574. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  17575. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  17576. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  17577. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  17578. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  17579. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  17580. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  17581. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  17582. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  17583. /// <typeparam name="TSource15">The type of the elements in the fifteenth source sequence.</typeparam>
  17584. /// <typeparam name="TSource16">The type of the elements in the sixteenth source sequence.</typeparam>
  17585. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  17586. /// <param name="source1">First observable source.</param>
  17587. /// <param name="source2">Second observable source.</param>
  17588. /// <param name="source3">Third observable source.</param>
  17589. /// <param name="source4">Fourth observable source.</param>
  17590. /// <param name="source5">Fifth observable source.</param>
  17591. /// <param name="source6">Sixth observable source.</param>
  17592. /// <param name="source7">Seventh observable source.</param>
  17593. /// <param name="source8">Eighth observable source.</param>
  17594. /// <param name="source9">Ninth observable source.</param>
  17595. /// <param name="source10">Tenth observable source.</param>
  17596. /// <param name="source11">Eleventh observable source.</param>
  17597. /// <param name="source12">Twelfth observable source.</param>
  17598. /// <param name="source13">Thirteenth observable source.</param>
  17599. /// <param name="source14">Fourteenth observable source.</param>
  17600. /// <param name="source15">Fifteenth observable source.</param>
  17601. /// <param name="source16">Sixteenth observable source.</param>
  17602. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  17603. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  17604. /// <exception cref="T:System.ArgumentNullException">
  17605. /// <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>
  17606. 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)
  17607. {
  17608. if (source1 == null)
  17609. throw new ArgumentNullException("source1");
  17610. if (source2 == null)
  17611. throw new ArgumentNullException("source2");
  17612. if (source3 == null)
  17613. throw new ArgumentNullException("source3");
  17614. if (source4 == null)
  17615. throw new ArgumentNullException("source4");
  17616. if (source5 == null)
  17617. throw new ArgumentNullException("source5");
  17618. if (source6 == null)
  17619. throw new ArgumentNullException("source6");
  17620. if (source7 == null)
  17621. throw new ArgumentNullException("source7");
  17622. if (source8 == null)
  17623. throw new ArgumentNullException("source8");
  17624. if (source9 == null)
  17625. throw new ArgumentNullException("source9");
  17626. if (source10 == null)
  17627. throw new ArgumentNullException("source10");
  17628. if (source11 == null)
  17629. throw new ArgumentNullException("source11");
  17630. if (source12 == null)
  17631. throw new ArgumentNullException("source12");
  17632. if (source13 == null)
  17633. throw new ArgumentNullException("source13");
  17634. if (source14 == null)
  17635. throw new ArgumentNullException("source14");
  17636. if (source15 == null)
  17637. throw new ArgumentNullException("source15");
  17638. if (source16 == null)
  17639. throw new ArgumentNullException("source16");
  17640. if (resultSelector == null)
  17641. throw new ArgumentNullException("resultSelector");
  17642. return source1.Provider.CreateQuery<TResult>(
  17643. Expression.Call(
  17644. null,
  17645. #if CRIPPLED_REFLECTION
  17646. 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>>))),
  17647. #else
  17648. ((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)),
  17649. #endif
  17650. source1.Expression,
  17651. GetSourceExpression(source2),
  17652. GetSourceExpression(source3),
  17653. GetSourceExpression(source4),
  17654. GetSourceExpression(source5),
  17655. GetSourceExpression(source6),
  17656. GetSourceExpression(source7),
  17657. GetSourceExpression(source8),
  17658. GetSourceExpression(source9),
  17659. GetSourceExpression(source10),
  17660. GetSourceExpression(source11),
  17661. GetSourceExpression(source12),
  17662. GetSourceExpression(source13),
  17663. GetSourceExpression(source14),
  17664. GetSourceExpression(source15),
  17665. GetSourceExpression(source16),
  17666. resultSelector
  17667. )
  17668. );
  17669. }
  17670. #endif
  17671. /// <summary>
  17672. /// 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.
  17673. /// </summary>
  17674. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17675. /// <param name="action">Action to convert to an asynchronous action.</param>
  17676. /// <returns>Asynchronous action.</returns>
  17677. /// <exception cref="T:System.ArgumentNullException">
  17678. /// <paramref name="action" /> is null.</exception>
  17679. public static Func<IQbservable<Unit>> ToAsync(this IQbservableProvider provider, Expression<Action> action)
  17680. {
  17681. if (provider == null)
  17682. throw new ArgumentNullException("provider");
  17683. if (action == null)
  17684. throw new ArgumentNullException("action");
  17685. #if CRIPPLED_REFLECTION
  17686. var m = InfoOf(() => Qbservable.ToAsync(default(IQbservableProvider), default(Expression<Action>)));
  17687. #else
  17688. var m = (MethodInfo)MethodInfo.GetCurrentMethod();
  17689. #endif
  17690. return () => provider.CreateQuery<Unit>(
  17691. Expression.Invoke(
  17692. Expression.Call(
  17693. null,
  17694. m,
  17695. Expression.Constant(provider, typeof(IQbservableProvider)),
  17696. action
  17697. )
  17698. )
  17699. );
  17700. }
  17701. /// <summary>
  17702. /// 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.
  17703. /// </summary>
  17704. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17705. /// <param name="action">Action to convert to an asynchronous action.</param>
  17706. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17707. /// <returns>Asynchronous action.</returns>
  17708. /// <exception cref="T:System.ArgumentNullException">
  17709. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17710. public static Func<IQbservable<Unit>> ToAsync(this IQbservableProvider provider, Expression<Action> action, IScheduler scheduler)
  17711. {
  17712. if (provider == null)
  17713. throw new ArgumentNullException("provider");
  17714. if (action == null)
  17715. throw new ArgumentNullException("action");
  17716. if (scheduler == null)
  17717. throw new ArgumentNullException("scheduler");
  17718. #if CRIPPLED_REFLECTION
  17719. var m = InfoOf(() => Qbservable.ToAsync(default(IQbservableProvider), default(Expression<Action>), default(IScheduler)));
  17720. #else
  17721. var m = (MethodInfo)MethodInfo.GetCurrentMethod();
  17722. #endif
  17723. return () => provider.CreateQuery<Unit>(
  17724. Expression.Invoke(
  17725. Expression.Call(
  17726. null,
  17727. m,
  17728. Expression.Constant(provider, typeof(IQbservableProvider)),
  17729. action,
  17730. Expression.Constant(scheduler, typeof(IScheduler))
  17731. )
  17732. )
  17733. );
  17734. }
  17735. /// <summary>
  17736. /// 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.
  17737. /// </summary>
  17738. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17739. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17740. /// <param name="action">Action to convert to an asynchronous action.</param>
  17741. /// <returns>Asynchronous action.</returns>
  17742. /// <exception cref="T:System.ArgumentNullException">
  17743. /// <paramref name="action" /> is null.</exception>
  17744. public static Func<TArg1, IQbservable<Unit>> ToAsync<TArg1>(this IQbservableProvider provider, Expression<Action<TArg1>> action)
  17745. {
  17746. if (provider == null)
  17747. throw new ArgumentNullException("provider");
  17748. if (action == null)
  17749. throw new ArgumentNullException("action");
  17750. #if CRIPPLED_REFLECTION
  17751. var m = InfoOf(() => Qbservable.ToAsync<TArg1>(default(IQbservableProvider), default(Expression<Action<TArg1>>)));
  17752. #else
  17753. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1));
  17754. #endif
  17755. return (t1) => provider.CreateQuery<Unit>(
  17756. Expression.Invoke(
  17757. Expression.Call(
  17758. null,
  17759. m,
  17760. Expression.Constant(provider, typeof(IQbservableProvider)),
  17761. action
  17762. ),
  17763. Expression.Constant(t1, typeof(TArg1))
  17764. )
  17765. );
  17766. }
  17767. /// <summary>
  17768. /// 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.
  17769. /// </summary>
  17770. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17771. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17772. /// <param name="action">Action to convert to an asynchronous action.</param>
  17773. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17774. /// <returns>Asynchronous action.</returns>
  17775. /// <exception cref="T:System.ArgumentNullException">
  17776. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17777. public static Func<TArg1, IQbservable<Unit>> ToAsync<TArg1>(this IQbservableProvider provider, Expression<Action<TArg1>> action, IScheduler scheduler)
  17778. {
  17779. if (provider == null)
  17780. throw new ArgumentNullException("provider");
  17781. if (action == null)
  17782. throw new ArgumentNullException("action");
  17783. if (scheduler == null)
  17784. throw new ArgumentNullException("scheduler");
  17785. #if CRIPPLED_REFLECTION
  17786. var m = InfoOf(() => Qbservable.ToAsync<TArg1>(default(IQbservableProvider), default(Expression<Action<TArg1>>), default(IScheduler)));
  17787. #else
  17788. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1));
  17789. #endif
  17790. return (t1) => provider.CreateQuery<Unit>(
  17791. Expression.Invoke(
  17792. Expression.Call(
  17793. null,
  17794. m,
  17795. Expression.Constant(provider, typeof(IQbservableProvider)),
  17796. action,
  17797. Expression.Constant(scheduler, typeof(IScheduler))
  17798. ),
  17799. Expression.Constant(t1, typeof(TArg1))
  17800. )
  17801. );
  17802. }
  17803. /// <summary>
  17804. /// 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.
  17805. /// </summary>
  17806. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17807. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17808. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17809. /// <param name="action">Action to convert to an asynchronous action.</param>
  17810. /// <returns>Asynchronous action.</returns>
  17811. /// <exception cref="T:System.ArgumentNullException">
  17812. /// <paramref name="action" /> is null.</exception>
  17813. public static Func<TArg1, TArg2, IQbservable<Unit>> ToAsync<TArg1, TArg2>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2>> action)
  17814. {
  17815. if (provider == null)
  17816. throw new ArgumentNullException("provider");
  17817. if (action == null)
  17818. throw new ArgumentNullException("action");
  17819. #if CRIPPLED_REFLECTION
  17820. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2>>)));
  17821. #else
  17822. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2));
  17823. #endif
  17824. return (t1, t2) => provider.CreateQuery<Unit>(
  17825. Expression.Invoke(
  17826. Expression.Call(
  17827. null,
  17828. m,
  17829. Expression.Constant(provider, typeof(IQbservableProvider)),
  17830. action
  17831. ),
  17832. Expression.Constant(t1, typeof(TArg1)),
  17833. Expression.Constant(t2, typeof(TArg2))
  17834. )
  17835. );
  17836. }
  17837. /// <summary>
  17838. /// 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.
  17839. /// </summary>
  17840. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17841. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17842. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17843. /// <param name="action">Action to convert to an asynchronous action.</param>
  17844. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17845. /// <returns>Asynchronous action.</returns>
  17846. /// <exception cref="T:System.ArgumentNullException">
  17847. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17848. public static Func<TArg1, TArg2, IQbservable<Unit>> ToAsync<TArg1, TArg2>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2>> action, IScheduler scheduler)
  17849. {
  17850. if (provider == null)
  17851. throw new ArgumentNullException("provider");
  17852. if (action == null)
  17853. throw new ArgumentNullException("action");
  17854. if (scheduler == null)
  17855. throw new ArgumentNullException("scheduler");
  17856. #if CRIPPLED_REFLECTION
  17857. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2>>), default(IScheduler)));
  17858. #else
  17859. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2));
  17860. #endif
  17861. return (t1, t2) => provider.CreateQuery<Unit>(
  17862. Expression.Invoke(
  17863. Expression.Call(
  17864. null,
  17865. m,
  17866. Expression.Constant(provider, typeof(IQbservableProvider)),
  17867. action,
  17868. Expression.Constant(scheduler, typeof(IScheduler))
  17869. ),
  17870. Expression.Constant(t1, typeof(TArg1)),
  17871. Expression.Constant(t2, typeof(TArg2))
  17872. )
  17873. );
  17874. }
  17875. /// <summary>
  17876. /// 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.
  17877. /// </summary>
  17878. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17879. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17880. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17881. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17882. /// <param name="action">Action to convert to an asynchronous action.</param>
  17883. /// <returns>Asynchronous action.</returns>
  17884. /// <exception cref="T:System.ArgumentNullException">
  17885. /// <paramref name="action" /> is null.</exception>
  17886. public static Func<TArg1, TArg2, TArg3, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3>> action)
  17887. {
  17888. if (provider == null)
  17889. throw new ArgumentNullException("provider");
  17890. if (action == null)
  17891. throw new ArgumentNullException("action");
  17892. #if CRIPPLED_REFLECTION
  17893. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3>>)));
  17894. #else
  17895. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3));
  17896. #endif
  17897. return (t1, t2, t3) => provider.CreateQuery<Unit>(
  17898. Expression.Invoke(
  17899. Expression.Call(
  17900. null,
  17901. m,
  17902. Expression.Constant(provider, typeof(IQbservableProvider)),
  17903. action
  17904. ),
  17905. Expression.Constant(t1, typeof(TArg1)),
  17906. Expression.Constant(t2, typeof(TArg2)),
  17907. Expression.Constant(t3, typeof(TArg3))
  17908. )
  17909. );
  17910. }
  17911. /// <summary>
  17912. /// 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.
  17913. /// </summary>
  17914. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17915. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17916. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17917. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17918. /// <param name="action">Action to convert to an asynchronous action.</param>
  17919. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17920. /// <returns>Asynchronous action.</returns>
  17921. /// <exception cref="T:System.ArgumentNullException">
  17922. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17923. public static Func<TArg1, TArg2, TArg3, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3>> action, IScheduler scheduler)
  17924. {
  17925. if (provider == null)
  17926. throw new ArgumentNullException("provider");
  17927. if (action == null)
  17928. throw new ArgumentNullException("action");
  17929. if (scheduler == null)
  17930. throw new ArgumentNullException("scheduler");
  17931. #if CRIPPLED_REFLECTION
  17932. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3>>), default(IScheduler)));
  17933. #else
  17934. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3));
  17935. #endif
  17936. return (t1, t2, t3) => provider.CreateQuery<Unit>(
  17937. Expression.Invoke(
  17938. Expression.Call(
  17939. null,
  17940. m,
  17941. Expression.Constant(provider, typeof(IQbservableProvider)),
  17942. action,
  17943. Expression.Constant(scheduler, typeof(IScheduler))
  17944. ),
  17945. Expression.Constant(t1, typeof(TArg1)),
  17946. Expression.Constant(t2, typeof(TArg2)),
  17947. Expression.Constant(t3, typeof(TArg3))
  17948. )
  17949. );
  17950. }
  17951. /// <summary>
  17952. /// 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.
  17953. /// </summary>
  17954. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17955. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17956. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17957. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17958. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17959. /// <param name="action">Action to convert to an asynchronous action.</param>
  17960. /// <returns>Asynchronous action.</returns>
  17961. /// <exception cref="T:System.ArgumentNullException">
  17962. /// <paramref name="action" /> is null.</exception>
  17963. public static Func<TArg1, TArg2, TArg3, TArg4, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3, TArg4>> action)
  17964. {
  17965. if (provider == null)
  17966. throw new ArgumentNullException("provider");
  17967. if (action == null)
  17968. throw new ArgumentNullException("action");
  17969. #if CRIPPLED_REFLECTION
  17970. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4>>)));
  17971. #else
  17972. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4));
  17973. #endif
  17974. return (t1, t2, t3, t4) => provider.CreateQuery<Unit>(
  17975. Expression.Invoke(
  17976. Expression.Call(
  17977. null,
  17978. m,
  17979. Expression.Constant(provider, typeof(IQbservableProvider)),
  17980. action
  17981. ),
  17982. Expression.Constant(t1, typeof(TArg1)),
  17983. Expression.Constant(t2, typeof(TArg2)),
  17984. Expression.Constant(t3, typeof(TArg3)),
  17985. Expression.Constant(t4, typeof(TArg4))
  17986. )
  17987. );
  17988. }
  17989. /// <summary>
  17990. /// 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.
  17991. /// </summary>
  17992. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17993. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17994. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17995. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17996. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17997. /// <param name="action">Action to convert to an asynchronous action.</param>
  17998. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17999. /// <returns>Asynchronous action.</returns>
  18000. /// <exception cref="T:System.ArgumentNullException">
  18001. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18002. 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)
  18003. {
  18004. if (provider == null)
  18005. throw new ArgumentNullException("provider");
  18006. if (action == null)
  18007. throw new ArgumentNullException("action");
  18008. if (scheduler == null)
  18009. throw new ArgumentNullException("scheduler");
  18010. #if CRIPPLED_REFLECTION
  18011. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4>>), default(IScheduler)));
  18012. #else
  18013. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4));
  18014. #endif
  18015. return (t1, t2, t3, t4) => provider.CreateQuery<Unit>(
  18016. Expression.Invoke(
  18017. Expression.Call(
  18018. null,
  18019. m,
  18020. Expression.Constant(provider, typeof(IQbservableProvider)),
  18021. action,
  18022. Expression.Constant(scheduler, typeof(IScheduler))
  18023. ),
  18024. Expression.Constant(t1, typeof(TArg1)),
  18025. Expression.Constant(t2, typeof(TArg2)),
  18026. Expression.Constant(t3, typeof(TArg3)),
  18027. Expression.Constant(t4, typeof(TArg4))
  18028. )
  18029. );
  18030. }
  18031. #if !NO_LARGEARITY
  18032. /// <summary>
  18033. /// 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.
  18034. /// </summary>
  18035. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18036. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18037. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18038. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18039. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18040. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18041. /// <param name="action">Action to convert to an asynchronous action.</param>
  18042. /// <returns>Asynchronous action.</returns>
  18043. /// <exception cref="T:System.ArgumentNullException">
  18044. /// <paramref name="action" /> is null.</exception>
  18045. 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)
  18046. {
  18047. if (provider == null)
  18048. throw new ArgumentNullException("provider");
  18049. if (action == null)
  18050. throw new ArgumentNullException("action");
  18051. #if CRIPPLED_REFLECTION
  18052. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5>>)));
  18053. #else
  18054. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5));
  18055. #endif
  18056. return (t1, t2, t3, t4, t5) => provider.CreateQuery<Unit>(
  18057. Expression.Invoke(
  18058. Expression.Call(
  18059. null,
  18060. m,
  18061. Expression.Constant(provider, typeof(IQbservableProvider)),
  18062. action
  18063. ),
  18064. Expression.Constant(t1, typeof(TArg1)),
  18065. Expression.Constant(t2, typeof(TArg2)),
  18066. Expression.Constant(t3, typeof(TArg3)),
  18067. Expression.Constant(t4, typeof(TArg4)),
  18068. Expression.Constant(t5, typeof(TArg5))
  18069. )
  18070. );
  18071. }
  18072. /// <summary>
  18073. /// 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.
  18074. /// </summary>
  18075. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18076. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18077. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18078. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18079. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18080. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18081. /// <param name="action">Action to convert to an asynchronous action.</param>
  18082. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18083. /// <returns>Asynchronous action.</returns>
  18084. /// <exception cref="T:System.ArgumentNullException">
  18085. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18086. 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)
  18087. {
  18088. if (provider == null)
  18089. throw new ArgumentNullException("provider");
  18090. if (action == null)
  18091. throw new ArgumentNullException("action");
  18092. if (scheduler == null)
  18093. throw new ArgumentNullException("scheduler");
  18094. #if CRIPPLED_REFLECTION
  18095. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5>>), default(IScheduler)));
  18096. #else
  18097. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5));
  18098. #endif
  18099. return (t1, t2, t3, t4, t5) => provider.CreateQuery<Unit>(
  18100. Expression.Invoke(
  18101. Expression.Call(
  18102. null,
  18103. m,
  18104. Expression.Constant(provider, typeof(IQbservableProvider)),
  18105. action,
  18106. Expression.Constant(scheduler, typeof(IScheduler))
  18107. ),
  18108. Expression.Constant(t1, typeof(TArg1)),
  18109. Expression.Constant(t2, typeof(TArg2)),
  18110. Expression.Constant(t3, typeof(TArg3)),
  18111. Expression.Constant(t4, typeof(TArg4)),
  18112. Expression.Constant(t5, typeof(TArg5))
  18113. )
  18114. );
  18115. }
  18116. /// <summary>
  18117. /// 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.
  18118. /// </summary>
  18119. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18120. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18121. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18122. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18123. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18124. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18125. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18126. /// <param name="action">Action to convert to an asynchronous action.</param>
  18127. /// <returns>Asynchronous action.</returns>
  18128. /// <exception cref="T:System.ArgumentNullException">
  18129. /// <paramref name="action" /> is null.</exception>
  18130. 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)
  18131. {
  18132. if (provider == null)
  18133. throw new ArgumentNullException("provider");
  18134. if (action == null)
  18135. throw new ArgumentNullException("action");
  18136. #if CRIPPLED_REFLECTION
  18137. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>>)));
  18138. #else
  18139. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6));
  18140. #endif
  18141. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<Unit>(
  18142. Expression.Invoke(
  18143. Expression.Call(
  18144. null,
  18145. m,
  18146. Expression.Constant(provider, typeof(IQbservableProvider)),
  18147. action
  18148. ),
  18149. Expression.Constant(t1, typeof(TArg1)),
  18150. Expression.Constant(t2, typeof(TArg2)),
  18151. Expression.Constant(t3, typeof(TArg3)),
  18152. Expression.Constant(t4, typeof(TArg4)),
  18153. Expression.Constant(t5, typeof(TArg5)),
  18154. Expression.Constant(t6, typeof(TArg6))
  18155. )
  18156. );
  18157. }
  18158. /// <summary>
  18159. /// 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.
  18160. /// </summary>
  18161. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18162. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18163. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18164. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18165. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18166. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18167. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18168. /// <param name="action">Action to convert to an asynchronous action.</param>
  18169. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18170. /// <returns>Asynchronous action.</returns>
  18171. /// <exception cref="T:System.ArgumentNullException">
  18172. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18173. 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)
  18174. {
  18175. if (provider == null)
  18176. throw new ArgumentNullException("provider");
  18177. if (action == null)
  18178. throw new ArgumentNullException("action");
  18179. if (scheduler == null)
  18180. throw new ArgumentNullException("scheduler");
  18181. #if CRIPPLED_REFLECTION
  18182. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>>), default(IScheduler)));
  18183. #else
  18184. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6));
  18185. #endif
  18186. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<Unit>(
  18187. Expression.Invoke(
  18188. Expression.Call(
  18189. null,
  18190. m,
  18191. Expression.Constant(provider, typeof(IQbservableProvider)),
  18192. action,
  18193. Expression.Constant(scheduler, typeof(IScheduler))
  18194. ),
  18195. Expression.Constant(t1, typeof(TArg1)),
  18196. Expression.Constant(t2, typeof(TArg2)),
  18197. Expression.Constant(t3, typeof(TArg3)),
  18198. Expression.Constant(t4, typeof(TArg4)),
  18199. Expression.Constant(t5, typeof(TArg5)),
  18200. Expression.Constant(t6, typeof(TArg6))
  18201. )
  18202. );
  18203. }
  18204. /// <summary>
  18205. /// 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.
  18206. /// </summary>
  18207. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18208. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18209. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18210. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18211. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18212. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18213. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18214. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18215. /// <param name="action">Action to convert to an asynchronous action.</param>
  18216. /// <returns>Asynchronous action.</returns>
  18217. /// <exception cref="T:System.ArgumentNullException">
  18218. /// <paramref name="action" /> is null.</exception>
  18219. 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)
  18220. {
  18221. if (provider == null)
  18222. throw new ArgumentNullException("provider");
  18223. if (action == null)
  18224. throw new ArgumentNullException("action");
  18225. #if CRIPPLED_REFLECTION
  18226. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7>>)));
  18227. #else
  18228. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7));
  18229. #endif
  18230. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<Unit>(
  18231. Expression.Invoke(
  18232. Expression.Call(
  18233. null,
  18234. m,
  18235. Expression.Constant(provider, typeof(IQbservableProvider)),
  18236. action
  18237. ),
  18238. Expression.Constant(t1, typeof(TArg1)),
  18239. Expression.Constant(t2, typeof(TArg2)),
  18240. Expression.Constant(t3, typeof(TArg3)),
  18241. Expression.Constant(t4, typeof(TArg4)),
  18242. Expression.Constant(t5, typeof(TArg5)),
  18243. Expression.Constant(t6, typeof(TArg6)),
  18244. Expression.Constant(t7, typeof(TArg7))
  18245. )
  18246. );
  18247. }
  18248. /// <summary>
  18249. /// 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.
  18250. /// </summary>
  18251. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18252. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18253. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18254. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18255. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18256. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18257. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18258. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18259. /// <param name="action">Action to convert to an asynchronous action.</param>
  18260. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18261. /// <returns>Asynchronous action.</returns>
  18262. /// <exception cref="T:System.ArgumentNullException">
  18263. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18264. 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)
  18265. {
  18266. if (provider == null)
  18267. throw new ArgumentNullException("provider");
  18268. if (action == null)
  18269. throw new ArgumentNullException("action");
  18270. if (scheduler == null)
  18271. throw new ArgumentNullException("scheduler");
  18272. #if CRIPPLED_REFLECTION
  18273. 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)));
  18274. #else
  18275. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7));
  18276. #endif
  18277. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<Unit>(
  18278. Expression.Invoke(
  18279. Expression.Call(
  18280. null,
  18281. m,
  18282. Expression.Constant(provider, typeof(IQbservableProvider)),
  18283. action,
  18284. Expression.Constant(scheduler, typeof(IScheduler))
  18285. ),
  18286. Expression.Constant(t1, typeof(TArg1)),
  18287. Expression.Constant(t2, typeof(TArg2)),
  18288. Expression.Constant(t3, typeof(TArg3)),
  18289. Expression.Constant(t4, typeof(TArg4)),
  18290. Expression.Constant(t5, typeof(TArg5)),
  18291. Expression.Constant(t6, typeof(TArg6)),
  18292. Expression.Constant(t7, typeof(TArg7))
  18293. )
  18294. );
  18295. }
  18296. /// <summary>
  18297. /// 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.
  18298. /// </summary>
  18299. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18300. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18301. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18302. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18303. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18304. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18305. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18306. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18307. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18308. /// <param name="action">Action to convert to an asynchronous action.</param>
  18309. /// <returns>Asynchronous action.</returns>
  18310. /// <exception cref="T:System.ArgumentNullException">
  18311. /// <paramref name="action" /> is null.</exception>
  18312. 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)
  18313. {
  18314. if (provider == null)
  18315. throw new ArgumentNullException("provider");
  18316. if (action == null)
  18317. throw new ArgumentNullException("action");
  18318. #if CRIPPLED_REFLECTION
  18319. 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>>)));
  18320. #else
  18321. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8));
  18322. #endif
  18323. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<Unit>(
  18324. Expression.Invoke(
  18325. Expression.Call(
  18326. null,
  18327. m,
  18328. Expression.Constant(provider, typeof(IQbservableProvider)),
  18329. action
  18330. ),
  18331. Expression.Constant(t1, typeof(TArg1)),
  18332. Expression.Constant(t2, typeof(TArg2)),
  18333. Expression.Constant(t3, typeof(TArg3)),
  18334. Expression.Constant(t4, typeof(TArg4)),
  18335. Expression.Constant(t5, typeof(TArg5)),
  18336. Expression.Constant(t6, typeof(TArg6)),
  18337. Expression.Constant(t7, typeof(TArg7)),
  18338. Expression.Constant(t8, typeof(TArg8))
  18339. )
  18340. );
  18341. }
  18342. /// <summary>
  18343. /// 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.
  18344. /// </summary>
  18345. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18346. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18347. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18348. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18349. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18350. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18351. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18352. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18353. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18354. /// <param name="action">Action to convert to an asynchronous action.</param>
  18355. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18356. /// <returns>Asynchronous action.</returns>
  18357. /// <exception cref="T:System.ArgumentNullException">
  18358. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18359. 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)
  18360. {
  18361. if (provider == null)
  18362. throw new ArgumentNullException("provider");
  18363. if (action == null)
  18364. throw new ArgumentNullException("action");
  18365. if (scheduler == null)
  18366. throw new ArgumentNullException("scheduler");
  18367. #if CRIPPLED_REFLECTION
  18368. 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)));
  18369. #else
  18370. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8));
  18371. #endif
  18372. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<Unit>(
  18373. Expression.Invoke(
  18374. Expression.Call(
  18375. null,
  18376. m,
  18377. Expression.Constant(provider, typeof(IQbservableProvider)),
  18378. action,
  18379. Expression.Constant(scheduler, typeof(IScheduler))
  18380. ),
  18381. Expression.Constant(t1, typeof(TArg1)),
  18382. Expression.Constant(t2, typeof(TArg2)),
  18383. Expression.Constant(t3, typeof(TArg3)),
  18384. Expression.Constant(t4, typeof(TArg4)),
  18385. Expression.Constant(t5, typeof(TArg5)),
  18386. Expression.Constant(t6, typeof(TArg6)),
  18387. Expression.Constant(t7, typeof(TArg7)),
  18388. Expression.Constant(t8, typeof(TArg8))
  18389. )
  18390. );
  18391. }
  18392. /// <summary>
  18393. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  18394. /// </summary>
  18395. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18396. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18397. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18398. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18399. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18400. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18401. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18402. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18403. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18404. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18405. /// <param name="action">Action to convert to an asynchronous action.</param>
  18406. /// <returns>Asynchronous action.</returns>
  18407. /// <exception cref="T:System.ArgumentNullException">
  18408. /// <paramref name="action" /> is null.</exception>
  18409. 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)
  18410. {
  18411. if (provider == null)
  18412. throw new ArgumentNullException("provider");
  18413. if (action == null)
  18414. throw new ArgumentNullException("action");
  18415. #if CRIPPLED_REFLECTION
  18416. 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>>)));
  18417. #else
  18418. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9));
  18419. #endif
  18420. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<Unit>(
  18421. Expression.Invoke(
  18422. Expression.Call(
  18423. null,
  18424. m,
  18425. Expression.Constant(provider, typeof(IQbservableProvider)),
  18426. action
  18427. ),
  18428. Expression.Constant(t1, typeof(TArg1)),
  18429. Expression.Constant(t2, typeof(TArg2)),
  18430. Expression.Constant(t3, typeof(TArg3)),
  18431. Expression.Constant(t4, typeof(TArg4)),
  18432. Expression.Constant(t5, typeof(TArg5)),
  18433. Expression.Constant(t6, typeof(TArg6)),
  18434. Expression.Constant(t7, typeof(TArg7)),
  18435. Expression.Constant(t8, typeof(TArg8)),
  18436. Expression.Constant(t9, typeof(TArg9))
  18437. )
  18438. );
  18439. }
  18440. /// <summary>
  18441. /// 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.
  18442. /// </summary>
  18443. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18444. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18445. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18446. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18447. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18448. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18449. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18450. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18451. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18452. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18453. /// <param name="action">Action to convert to an asynchronous action.</param>
  18454. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18455. /// <returns>Asynchronous action.</returns>
  18456. /// <exception cref="T:System.ArgumentNullException">
  18457. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18458. 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)
  18459. {
  18460. if (provider == null)
  18461. throw new ArgumentNullException("provider");
  18462. if (action == null)
  18463. throw new ArgumentNullException("action");
  18464. if (scheduler == null)
  18465. throw new ArgumentNullException("scheduler");
  18466. #if CRIPPLED_REFLECTION
  18467. 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)));
  18468. #else
  18469. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9));
  18470. #endif
  18471. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<Unit>(
  18472. Expression.Invoke(
  18473. Expression.Call(
  18474. null,
  18475. m,
  18476. Expression.Constant(provider, typeof(IQbservableProvider)),
  18477. action,
  18478. Expression.Constant(scheduler, typeof(IScheduler))
  18479. ),
  18480. Expression.Constant(t1, typeof(TArg1)),
  18481. Expression.Constant(t2, typeof(TArg2)),
  18482. Expression.Constant(t3, typeof(TArg3)),
  18483. Expression.Constant(t4, typeof(TArg4)),
  18484. Expression.Constant(t5, typeof(TArg5)),
  18485. Expression.Constant(t6, typeof(TArg6)),
  18486. Expression.Constant(t7, typeof(TArg7)),
  18487. Expression.Constant(t8, typeof(TArg8)),
  18488. Expression.Constant(t9, typeof(TArg9))
  18489. )
  18490. );
  18491. }
  18492. /// <summary>
  18493. /// 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.
  18494. /// </summary>
  18495. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18496. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18497. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18498. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18499. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18500. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18501. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18502. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18503. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18504. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18505. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18506. /// <param name="action">Action to convert to an asynchronous action.</param>
  18507. /// <returns>Asynchronous action.</returns>
  18508. /// <exception cref="T:System.ArgumentNullException">
  18509. /// <paramref name="action" /> is null.</exception>
  18510. 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)
  18511. {
  18512. if (provider == null)
  18513. throw new ArgumentNullException("provider");
  18514. if (action == null)
  18515. throw new ArgumentNullException("action");
  18516. #if CRIPPLED_REFLECTION
  18517. 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>>)));
  18518. #else
  18519. 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));
  18520. #endif
  18521. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<Unit>(
  18522. Expression.Invoke(
  18523. Expression.Call(
  18524. null,
  18525. m,
  18526. Expression.Constant(provider, typeof(IQbservableProvider)),
  18527. action
  18528. ),
  18529. Expression.Constant(t1, typeof(TArg1)),
  18530. Expression.Constant(t2, typeof(TArg2)),
  18531. Expression.Constant(t3, typeof(TArg3)),
  18532. Expression.Constant(t4, typeof(TArg4)),
  18533. Expression.Constant(t5, typeof(TArg5)),
  18534. Expression.Constant(t6, typeof(TArg6)),
  18535. Expression.Constant(t7, typeof(TArg7)),
  18536. Expression.Constant(t8, typeof(TArg8)),
  18537. Expression.Constant(t9, typeof(TArg9)),
  18538. Expression.Constant(t10, typeof(TArg10))
  18539. )
  18540. );
  18541. }
  18542. /// <summary>
  18543. /// 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.
  18544. /// </summary>
  18545. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18546. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18547. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18548. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18549. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18550. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18551. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18552. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18553. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18554. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18555. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18556. /// <param name="action">Action to convert to an asynchronous action.</param>
  18557. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18558. /// <returns>Asynchronous action.</returns>
  18559. /// <exception cref="T:System.ArgumentNullException">
  18560. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18561. 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)
  18562. {
  18563. if (provider == null)
  18564. throw new ArgumentNullException("provider");
  18565. if (action == null)
  18566. throw new ArgumentNullException("action");
  18567. if (scheduler == null)
  18568. throw new ArgumentNullException("scheduler");
  18569. #if CRIPPLED_REFLECTION
  18570. 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)));
  18571. #else
  18572. 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));
  18573. #endif
  18574. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<Unit>(
  18575. Expression.Invoke(
  18576. Expression.Call(
  18577. null,
  18578. m,
  18579. Expression.Constant(provider, typeof(IQbservableProvider)),
  18580. action,
  18581. Expression.Constant(scheduler, typeof(IScheduler))
  18582. ),
  18583. Expression.Constant(t1, typeof(TArg1)),
  18584. Expression.Constant(t2, typeof(TArg2)),
  18585. Expression.Constant(t3, typeof(TArg3)),
  18586. Expression.Constant(t4, typeof(TArg4)),
  18587. Expression.Constant(t5, typeof(TArg5)),
  18588. Expression.Constant(t6, typeof(TArg6)),
  18589. Expression.Constant(t7, typeof(TArg7)),
  18590. Expression.Constant(t8, typeof(TArg8)),
  18591. Expression.Constant(t9, typeof(TArg9)),
  18592. Expression.Constant(t10, typeof(TArg10))
  18593. )
  18594. );
  18595. }
  18596. /// <summary>
  18597. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  18598. /// </summary>
  18599. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18600. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18601. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18602. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18603. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18604. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18605. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18606. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18607. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18608. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18609. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18610. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18611. /// <param name="action">Action to convert to an asynchronous action.</param>
  18612. /// <returns>Asynchronous action.</returns>
  18613. /// <exception cref="T:System.ArgumentNullException">
  18614. /// <paramref name="action" /> is null.</exception>
  18615. 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)
  18616. {
  18617. if (provider == null)
  18618. throw new ArgumentNullException("provider");
  18619. if (action == null)
  18620. throw new ArgumentNullException("action");
  18621. #if CRIPPLED_REFLECTION
  18622. 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>>)));
  18623. #else
  18624. 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));
  18625. #endif
  18626. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<Unit>(
  18627. Expression.Invoke(
  18628. Expression.Call(
  18629. null,
  18630. m,
  18631. Expression.Constant(provider, typeof(IQbservableProvider)),
  18632. action
  18633. ),
  18634. Expression.Constant(t1, typeof(TArg1)),
  18635. Expression.Constant(t2, typeof(TArg2)),
  18636. Expression.Constant(t3, typeof(TArg3)),
  18637. Expression.Constant(t4, typeof(TArg4)),
  18638. Expression.Constant(t5, typeof(TArg5)),
  18639. Expression.Constant(t6, typeof(TArg6)),
  18640. Expression.Constant(t7, typeof(TArg7)),
  18641. Expression.Constant(t8, typeof(TArg8)),
  18642. Expression.Constant(t9, typeof(TArg9)),
  18643. Expression.Constant(t10, typeof(TArg10)),
  18644. Expression.Constant(t11, typeof(TArg11))
  18645. )
  18646. );
  18647. }
  18648. /// <summary>
  18649. /// 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.
  18650. /// </summary>
  18651. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18652. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18653. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18654. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18655. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18656. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18657. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18658. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18659. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18660. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18661. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18662. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18663. /// <param name="action">Action to convert to an asynchronous action.</param>
  18664. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18665. /// <returns>Asynchronous action.</returns>
  18666. /// <exception cref="T:System.ArgumentNullException">
  18667. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18668. 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)
  18669. {
  18670. if (provider == null)
  18671. throw new ArgumentNullException("provider");
  18672. if (action == null)
  18673. throw new ArgumentNullException("action");
  18674. if (scheduler == null)
  18675. throw new ArgumentNullException("scheduler");
  18676. #if CRIPPLED_REFLECTION
  18677. 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)));
  18678. #else
  18679. 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));
  18680. #endif
  18681. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<Unit>(
  18682. Expression.Invoke(
  18683. Expression.Call(
  18684. null,
  18685. m,
  18686. Expression.Constant(provider, typeof(IQbservableProvider)),
  18687. action,
  18688. Expression.Constant(scheduler, typeof(IScheduler))
  18689. ),
  18690. Expression.Constant(t1, typeof(TArg1)),
  18691. Expression.Constant(t2, typeof(TArg2)),
  18692. Expression.Constant(t3, typeof(TArg3)),
  18693. Expression.Constant(t4, typeof(TArg4)),
  18694. Expression.Constant(t5, typeof(TArg5)),
  18695. Expression.Constant(t6, typeof(TArg6)),
  18696. Expression.Constant(t7, typeof(TArg7)),
  18697. Expression.Constant(t8, typeof(TArg8)),
  18698. Expression.Constant(t9, typeof(TArg9)),
  18699. Expression.Constant(t10, typeof(TArg10)),
  18700. Expression.Constant(t11, typeof(TArg11))
  18701. )
  18702. );
  18703. }
  18704. /// <summary>
  18705. /// 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.
  18706. /// </summary>
  18707. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18708. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18709. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18710. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18711. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18712. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18713. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18714. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18715. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18716. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18717. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18718. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18719. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18720. /// <param name="action">Action to convert to an asynchronous action.</param>
  18721. /// <returns>Asynchronous action.</returns>
  18722. /// <exception cref="T:System.ArgumentNullException">
  18723. /// <paramref name="action" /> is null.</exception>
  18724. 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)
  18725. {
  18726. if (provider == null)
  18727. throw new ArgumentNullException("provider");
  18728. if (action == null)
  18729. throw new ArgumentNullException("action");
  18730. #if CRIPPLED_REFLECTION
  18731. 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>>)));
  18732. #else
  18733. 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));
  18734. #endif
  18735. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<Unit>(
  18736. Expression.Invoke(
  18737. Expression.Call(
  18738. null,
  18739. m,
  18740. Expression.Constant(provider, typeof(IQbservableProvider)),
  18741. action
  18742. ),
  18743. Expression.Constant(t1, typeof(TArg1)),
  18744. Expression.Constant(t2, typeof(TArg2)),
  18745. Expression.Constant(t3, typeof(TArg3)),
  18746. Expression.Constant(t4, typeof(TArg4)),
  18747. Expression.Constant(t5, typeof(TArg5)),
  18748. Expression.Constant(t6, typeof(TArg6)),
  18749. Expression.Constant(t7, typeof(TArg7)),
  18750. Expression.Constant(t8, typeof(TArg8)),
  18751. Expression.Constant(t9, typeof(TArg9)),
  18752. Expression.Constant(t10, typeof(TArg10)),
  18753. Expression.Constant(t11, typeof(TArg11)),
  18754. Expression.Constant(t12, typeof(TArg12))
  18755. )
  18756. );
  18757. }
  18758. /// <summary>
  18759. /// 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.
  18760. /// </summary>
  18761. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18762. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18763. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18764. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18765. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18766. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18767. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18768. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18769. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18770. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18771. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18772. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18773. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18774. /// <param name="action">Action to convert to an asynchronous action.</param>
  18775. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18776. /// <returns>Asynchronous action.</returns>
  18777. /// <exception cref="T:System.ArgumentNullException">
  18778. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18779. 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)
  18780. {
  18781. if (provider == null)
  18782. throw new ArgumentNullException("provider");
  18783. if (action == null)
  18784. throw new ArgumentNullException("action");
  18785. if (scheduler == null)
  18786. throw new ArgumentNullException("scheduler");
  18787. #if CRIPPLED_REFLECTION
  18788. 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)));
  18789. #else
  18790. 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));
  18791. #endif
  18792. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<Unit>(
  18793. Expression.Invoke(
  18794. Expression.Call(
  18795. null,
  18796. m,
  18797. Expression.Constant(provider, typeof(IQbservableProvider)),
  18798. action,
  18799. Expression.Constant(scheduler, typeof(IScheduler))
  18800. ),
  18801. Expression.Constant(t1, typeof(TArg1)),
  18802. Expression.Constant(t2, typeof(TArg2)),
  18803. Expression.Constant(t3, typeof(TArg3)),
  18804. Expression.Constant(t4, typeof(TArg4)),
  18805. Expression.Constant(t5, typeof(TArg5)),
  18806. Expression.Constant(t6, typeof(TArg6)),
  18807. Expression.Constant(t7, typeof(TArg7)),
  18808. Expression.Constant(t8, typeof(TArg8)),
  18809. Expression.Constant(t9, typeof(TArg9)),
  18810. Expression.Constant(t10, typeof(TArg10)),
  18811. Expression.Constant(t11, typeof(TArg11)),
  18812. Expression.Constant(t12, typeof(TArg12))
  18813. )
  18814. );
  18815. }
  18816. /// <summary>
  18817. /// 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.
  18818. /// </summary>
  18819. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18820. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18821. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18822. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18823. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18824. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18825. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18826. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18827. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18828. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18829. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18830. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18831. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18832. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18833. /// <param name="action">Action to convert to an asynchronous action.</param>
  18834. /// <returns>Asynchronous action.</returns>
  18835. /// <exception cref="T:System.ArgumentNullException">
  18836. /// <paramref name="action" /> is null.</exception>
  18837. 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)
  18838. {
  18839. if (provider == null)
  18840. throw new ArgumentNullException("provider");
  18841. if (action == null)
  18842. throw new ArgumentNullException("action");
  18843. #if CRIPPLED_REFLECTION
  18844. 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>>)));
  18845. #else
  18846. 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));
  18847. #endif
  18848. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<Unit>(
  18849. Expression.Invoke(
  18850. Expression.Call(
  18851. null,
  18852. m,
  18853. Expression.Constant(provider, typeof(IQbservableProvider)),
  18854. action
  18855. ),
  18856. Expression.Constant(t1, typeof(TArg1)),
  18857. Expression.Constant(t2, typeof(TArg2)),
  18858. Expression.Constant(t3, typeof(TArg3)),
  18859. Expression.Constant(t4, typeof(TArg4)),
  18860. Expression.Constant(t5, typeof(TArg5)),
  18861. Expression.Constant(t6, typeof(TArg6)),
  18862. Expression.Constant(t7, typeof(TArg7)),
  18863. Expression.Constant(t8, typeof(TArg8)),
  18864. Expression.Constant(t9, typeof(TArg9)),
  18865. Expression.Constant(t10, typeof(TArg10)),
  18866. Expression.Constant(t11, typeof(TArg11)),
  18867. Expression.Constant(t12, typeof(TArg12)),
  18868. Expression.Constant(t13, typeof(TArg13))
  18869. )
  18870. );
  18871. }
  18872. /// <summary>
  18873. /// 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.
  18874. /// </summary>
  18875. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18876. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18877. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18878. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18879. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18880. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18881. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18882. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18883. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18884. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18885. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18886. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18887. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18888. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18889. /// <param name="action">Action to convert to an asynchronous action.</param>
  18890. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18891. /// <returns>Asynchronous action.</returns>
  18892. /// <exception cref="T:System.ArgumentNullException">
  18893. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18894. 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)
  18895. {
  18896. if (provider == null)
  18897. throw new ArgumentNullException("provider");
  18898. if (action == null)
  18899. throw new ArgumentNullException("action");
  18900. if (scheduler == null)
  18901. throw new ArgumentNullException("scheduler");
  18902. #if CRIPPLED_REFLECTION
  18903. 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)));
  18904. #else
  18905. 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));
  18906. #endif
  18907. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<Unit>(
  18908. Expression.Invoke(
  18909. Expression.Call(
  18910. null,
  18911. m,
  18912. Expression.Constant(provider, typeof(IQbservableProvider)),
  18913. action,
  18914. Expression.Constant(scheduler, typeof(IScheduler))
  18915. ),
  18916. Expression.Constant(t1, typeof(TArg1)),
  18917. Expression.Constant(t2, typeof(TArg2)),
  18918. Expression.Constant(t3, typeof(TArg3)),
  18919. Expression.Constant(t4, typeof(TArg4)),
  18920. Expression.Constant(t5, typeof(TArg5)),
  18921. Expression.Constant(t6, typeof(TArg6)),
  18922. Expression.Constant(t7, typeof(TArg7)),
  18923. Expression.Constant(t8, typeof(TArg8)),
  18924. Expression.Constant(t9, typeof(TArg9)),
  18925. Expression.Constant(t10, typeof(TArg10)),
  18926. Expression.Constant(t11, typeof(TArg11)),
  18927. Expression.Constant(t12, typeof(TArg12)),
  18928. Expression.Constant(t13, typeof(TArg13))
  18929. )
  18930. );
  18931. }
  18932. /// <summary>
  18933. /// 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.
  18934. /// </summary>
  18935. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18936. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18937. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18938. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18939. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18940. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18941. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18942. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18943. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18944. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18945. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18946. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18947. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18948. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18949. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  18950. /// <param name="action">Action to convert to an asynchronous action.</param>
  18951. /// <returns>Asynchronous action.</returns>
  18952. /// <exception cref="T:System.ArgumentNullException">
  18953. /// <paramref name="action" /> is null.</exception>
  18954. 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)
  18955. {
  18956. if (provider == null)
  18957. throw new ArgumentNullException("provider");
  18958. if (action == null)
  18959. throw new ArgumentNullException("action");
  18960. #if CRIPPLED_REFLECTION
  18961. 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>>)));
  18962. #else
  18963. 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));
  18964. #endif
  18965. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<Unit>(
  18966. Expression.Invoke(
  18967. Expression.Call(
  18968. null,
  18969. m,
  18970. Expression.Constant(provider, typeof(IQbservableProvider)),
  18971. action
  18972. ),
  18973. Expression.Constant(t1, typeof(TArg1)),
  18974. Expression.Constant(t2, typeof(TArg2)),
  18975. Expression.Constant(t3, typeof(TArg3)),
  18976. Expression.Constant(t4, typeof(TArg4)),
  18977. Expression.Constant(t5, typeof(TArg5)),
  18978. Expression.Constant(t6, typeof(TArg6)),
  18979. Expression.Constant(t7, typeof(TArg7)),
  18980. Expression.Constant(t8, typeof(TArg8)),
  18981. Expression.Constant(t9, typeof(TArg9)),
  18982. Expression.Constant(t10, typeof(TArg10)),
  18983. Expression.Constant(t11, typeof(TArg11)),
  18984. Expression.Constant(t12, typeof(TArg12)),
  18985. Expression.Constant(t13, typeof(TArg13)),
  18986. Expression.Constant(t14, typeof(TArg14))
  18987. )
  18988. );
  18989. }
  18990. /// <summary>
  18991. /// 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.
  18992. /// </summary>
  18993. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18994. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18995. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18996. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18997. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18998. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18999. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  19000. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  19001. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  19002. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  19003. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  19004. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  19005. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  19006. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  19007. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  19008. /// <param name="action">Action to convert to an asynchronous action.</param>
  19009. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  19010. /// <returns>Asynchronous action.</returns>
  19011. /// <exception cref="T:System.ArgumentNullException">
  19012. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  19013. 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)
  19014. {
  19015. if (provider == null)
  19016. throw new ArgumentNullException("provider");
  19017. if (action == null)
  19018. throw new ArgumentNullException("action");
  19019. if (scheduler == null)
  19020. throw new ArgumentNullException("scheduler");
  19021. #if CRIPPLED_REFLECTION
  19022. 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)));
  19023. #else
  19024. 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));
  19025. #endif
  19026. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<Unit>(
  19027. Expression.Invoke(
  19028. Expression.Call(
  19029. null,
  19030. m,
  19031. Expression.Constant(provider, typeof(IQbservableProvider)),
  19032. action,
  19033. Expression.Constant(scheduler, typeof(IScheduler))
  19034. ),
  19035. Expression.Constant(t1, typeof(TArg1)),
  19036. Expression.Constant(t2, typeof(TArg2)),
  19037. Expression.Constant(t3, typeof(TArg3)),
  19038. Expression.Constant(t4, typeof(TArg4)),
  19039. Expression.Constant(t5, typeof(TArg5)),
  19040. Expression.Constant(t6, typeof(TArg6)),
  19041. Expression.Constant(t7, typeof(TArg7)),
  19042. Expression.Constant(t8, typeof(TArg8)),
  19043. Expression.Constant(t9, typeof(TArg9)),
  19044. Expression.Constant(t10, typeof(TArg10)),
  19045. Expression.Constant(t11, typeof(TArg11)),
  19046. Expression.Constant(t12, typeof(TArg12)),
  19047. Expression.Constant(t13, typeof(TArg13)),
  19048. Expression.Constant(t14, typeof(TArg14))
  19049. )
  19050. );
  19051. }
  19052. /// <summary>
  19053. /// 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.
  19054. /// </summary>
  19055. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19056. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  19057. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  19058. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  19059. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  19060. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  19061. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  19062. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  19063. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  19064. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  19065. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  19066. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  19067. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  19068. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  19069. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  19070. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the action.</typeparam>
  19071. /// <param name="action">Action to convert to an asynchronous action.</param>
  19072. /// <returns>Asynchronous action.</returns>
  19073. /// <exception cref="T:System.ArgumentNullException">
  19074. /// <paramref name="action" /> is null.</exception>
  19075. 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)
  19076. {
  19077. if (provider == null)
  19078. throw new ArgumentNullException("provider");
  19079. if (action == null)
  19080. throw new ArgumentNullException("action");
  19081. #if CRIPPLED_REFLECTION
  19082. 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>>)));
  19083. #else
  19084. 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));
  19085. #endif
  19086. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) => provider.CreateQuery<Unit>(
  19087. Expression.Invoke(
  19088. Expression.Call(
  19089. null,
  19090. m,
  19091. Expression.Constant(provider, typeof(IQbservableProvider)),
  19092. action
  19093. ),
  19094. Expression.Constant(t1, typeof(TArg1)),
  19095. Expression.Constant(t2, typeof(TArg2)),
  19096. Expression.Constant(t3, typeof(TArg3)),
  19097. Expression.Constant(t4, typeof(TArg4)),
  19098. Expression.Constant(t5, typeof(TArg5)),
  19099. Expression.Constant(t6, typeof(TArg6)),
  19100. Expression.Constant(t7, typeof(TArg7)),
  19101. Expression.Constant(t8, typeof(TArg8)),
  19102. Expression.Constant(t9, typeof(TArg9)),
  19103. Expression.Constant(t10, typeof(TArg10)),
  19104. Expression.Constant(t11, typeof(TArg11)),
  19105. Expression.Constant(t12, typeof(TArg12)),
  19106. Expression.Constant(t13, typeof(TArg13)),
  19107. Expression.Constant(t14, typeof(TArg14)),
  19108. Expression.Constant(t15, typeof(TArg15))
  19109. )
  19110. );
  19111. }
  19112. /// <summary>
  19113. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  19114. /// </summary>
  19115. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19116. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  19117. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  19118. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  19119. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  19120. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  19121. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  19122. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  19123. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  19124. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  19125. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  19126. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  19127. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  19128. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  19129. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  19130. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the action.</typeparam>
  19131. /// <param name="action">Action to convert to an asynchronous action.</param>
  19132. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  19133. /// <returns>Asynchronous action.</returns>
  19134. /// <exception cref="T:System.ArgumentNullException">
  19135. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  19136. 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)
  19137. {
  19138. if (provider == null)
  19139. throw new ArgumentNullException("provider");
  19140. if (action == null)
  19141. throw new ArgumentNullException("action");
  19142. if (scheduler == null)
  19143. throw new ArgumentNullException("scheduler");
  19144. #if CRIPPLED_REFLECTION
  19145. 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)));
  19146. #else
  19147. 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));
  19148. #endif
  19149. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) => provider.CreateQuery<Unit>(
  19150. Expression.Invoke(
  19151. Expression.Call(
  19152. null,
  19153. m,
  19154. Expression.Constant(provider, typeof(IQbservableProvider)),
  19155. action,
  19156. Expression.Constant(scheduler, typeof(IScheduler))
  19157. ),
  19158. Expression.Constant(t1, typeof(TArg1)),
  19159. Expression.Constant(t2, typeof(TArg2)),
  19160. Expression.Constant(t3, typeof(TArg3)),
  19161. Expression.Constant(t4, typeof(TArg4)),
  19162. Expression.Constant(t5, typeof(TArg5)),
  19163. Expression.Constant(t6, typeof(TArg6)),
  19164. Expression.Constant(t7, typeof(TArg7)),
  19165. Expression.Constant(t8, typeof(TArg8)),
  19166. Expression.Constant(t9, typeof(TArg9)),
  19167. Expression.Constant(t10, typeof(TArg10)),
  19168. Expression.Constant(t11, typeof(TArg11)),
  19169. Expression.Constant(t12, typeof(TArg12)),
  19170. Expression.Constant(t13, typeof(TArg13)),
  19171. Expression.Constant(t14, typeof(TArg14)),
  19172. Expression.Constant(t15, typeof(TArg15))
  19173. )
  19174. );
  19175. }
  19176. /// <summary>
  19177. /// 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.
  19178. /// </summary>
  19179. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19180. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  19181. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  19182. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  19183. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  19184. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  19185. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  19186. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  19187. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  19188. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  19189. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  19190. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  19191. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  19192. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  19193. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  19194. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the action.</typeparam>
  19195. /// <typeparam name="TArg16">The type of the sixteenth argument passed to the action.</typeparam>
  19196. /// <param name="action">Action to convert to an asynchronous action.</param>
  19197. /// <returns>Asynchronous action.</returns>
  19198. /// <exception cref="T:System.ArgumentNullException">
  19199. /// <paramref name="action" /> is null.</exception>
  19200. 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)
  19201. {
  19202. if (provider == null)
  19203. throw new ArgumentNullException("provider");
  19204. if (action == null)
  19205. throw new ArgumentNullException("action");
  19206. #if CRIPPLED_REFLECTION
  19207. 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>>)));
  19208. #else
  19209. 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));
  19210. #endif
  19211. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) => provider.CreateQuery<Unit>(
  19212. Expression.Invoke(
  19213. Expression.Call(
  19214. null,
  19215. m,
  19216. Expression.Constant(provider, typeof(IQbservableProvider)),
  19217. action
  19218. ),
  19219. Expression.Constant(t1, typeof(TArg1)),
  19220. Expression.Constant(t2, typeof(TArg2)),
  19221. Expression.Constant(t3, typeof(TArg3)),
  19222. Expression.Constant(t4, typeof(TArg4)),
  19223. Expression.Constant(t5, typeof(TArg5)),
  19224. Expression.Constant(t6, typeof(TArg6)),
  19225. Expression.Constant(t7, typeof(TArg7)),
  19226. Expression.Constant(t8, typeof(TArg8)),
  19227. Expression.Constant(t9, typeof(TArg9)),
  19228. Expression.Constant(t10, typeof(TArg10)),
  19229. Expression.Constant(t11, typeof(TArg11)),
  19230. Expression.Constant(t12, typeof(TArg12)),
  19231. Expression.Constant(t13, typeof(TArg13)),
  19232. Expression.Constant(t14, typeof(TArg14)),
  19233. Expression.Constant(t15, typeof(TArg15)),
  19234. Expression.Constant(t16, typeof(TArg16))
  19235. )
  19236. );
  19237. }
  19238. /// <summary>
  19239. /// 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.
  19240. /// </summary>
  19241. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19242. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  19243. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  19244. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  19245. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  19246. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  19247. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  19248. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  19249. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  19250. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  19251. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  19252. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  19253. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  19254. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  19255. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  19256. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the action.</typeparam>
  19257. /// <typeparam name="TArg16">The type of the sixteenth argument passed to the action.</typeparam>
  19258. /// <param name="action">Action to convert to an asynchronous action.</param>
  19259. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  19260. /// <returns>Asynchronous action.</returns>
  19261. /// <exception cref="T:System.ArgumentNullException">
  19262. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  19263. 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)
  19264. {
  19265. if (provider == null)
  19266. throw new ArgumentNullException("provider");
  19267. if (action == null)
  19268. throw new ArgumentNullException("action");
  19269. if (scheduler == null)
  19270. throw new ArgumentNullException("scheduler");
  19271. #if CRIPPLED_REFLECTION
  19272. 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)));
  19273. #else
  19274. 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));
  19275. #endif
  19276. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) => provider.CreateQuery<Unit>(
  19277. Expression.Invoke(
  19278. Expression.Call(
  19279. null,
  19280. m,
  19281. Expression.Constant(provider, typeof(IQbservableProvider)),
  19282. action,
  19283. Expression.Constant(scheduler, typeof(IScheduler))
  19284. ),
  19285. Expression.Constant(t1, typeof(TArg1)),
  19286. Expression.Constant(t2, typeof(TArg2)),
  19287. Expression.Constant(t3, typeof(TArg3)),
  19288. Expression.Constant(t4, typeof(TArg4)),
  19289. Expression.Constant(t5, typeof(TArg5)),
  19290. Expression.Constant(t6, typeof(TArg6)),
  19291. Expression.Constant(t7, typeof(TArg7)),
  19292. Expression.Constant(t8, typeof(TArg8)),
  19293. Expression.Constant(t9, typeof(TArg9)),
  19294. Expression.Constant(t10, typeof(TArg10)),
  19295. Expression.Constant(t11, typeof(TArg11)),
  19296. Expression.Constant(t12, typeof(TArg12)),
  19297. Expression.Constant(t13, typeof(TArg13)),
  19298. Expression.Constant(t14, typeof(TArg14)),
  19299. Expression.Constant(t15, typeof(TArg15)),
  19300. Expression.Constant(t16, typeof(TArg16))
  19301. )
  19302. );
  19303. }
  19304. #endif
  19305. /// <summary>
  19306. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19307. /// </summary>
  19308. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19309. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19310. /// <param name="function">Function to convert to an asynchronous function.</param>
  19311. /// <returns>Asynchronous function.</returns>
  19312. /// <exception cref="T:System.ArgumentNullException">
  19313. /// <paramref name="function" /> is null.</exception>
  19314. public static Func<IQbservable<TResult>> ToAsync<TResult>(this IQbservableProvider provider, Expression<Func<TResult>> function)
  19315. {
  19316. if (provider == null)
  19317. throw new ArgumentNullException("provider");
  19318. if (function == null)
  19319. throw new ArgumentNullException("function");
  19320. #if CRIPPLED_REFLECTION
  19321. var m = InfoOf(() => Qbservable.ToAsync<TResult>(default(IQbservableProvider), default(Expression<Func<TResult>>)));
  19322. #else
  19323. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult));
  19324. #endif
  19325. return () => provider.CreateQuery<TResult>(
  19326. Expression.Invoke(
  19327. Expression.Call(
  19328. null,
  19329. m,
  19330. Expression.Constant(provider, typeof(IQbservableProvider)),
  19331. function
  19332. )
  19333. )
  19334. );
  19335. }
  19336. /// <summary>
  19337. /// 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.
  19338. /// </summary>
  19339. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19340. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19341. /// <param name="function">Function to convert to an asynchronous function.</param>
  19342. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19343. /// <returns>Asynchronous function.</returns>
  19344. /// <exception cref="T:System.ArgumentNullException">
  19345. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19346. public static Func<IQbservable<TResult>> ToAsync<TResult>(this IQbservableProvider provider, Expression<Func<TResult>> function, IScheduler scheduler)
  19347. {
  19348. if (provider == null)
  19349. throw new ArgumentNullException("provider");
  19350. if (function == null)
  19351. throw new ArgumentNullException("function");
  19352. if (scheduler == null)
  19353. throw new ArgumentNullException("scheduler");
  19354. #if CRIPPLED_REFLECTION
  19355. var m = InfoOf(() => Qbservable.ToAsync<TResult>(default(IQbservableProvider), default(Expression<Func<TResult>>), default(IScheduler)));
  19356. #else
  19357. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult));
  19358. #endif
  19359. return () => provider.CreateQuery<TResult>(
  19360. Expression.Invoke(
  19361. Expression.Call(
  19362. null,
  19363. m,
  19364. Expression.Constant(provider, typeof(IQbservableProvider)),
  19365. function,
  19366. Expression.Constant(scheduler, typeof(IScheduler))
  19367. )
  19368. )
  19369. );
  19370. }
  19371. /// <summary>
  19372. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19373. /// </summary>
  19374. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19375. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19376. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19377. /// <param name="function">Function to convert to an asynchronous function.</param>
  19378. /// <returns>Asynchronous function.</returns>
  19379. /// <exception cref="T:System.ArgumentNullException">
  19380. /// <paramref name="function" /> is null.</exception>
  19381. public static Func<TArg1, IQbservable<TResult>> ToAsync<TArg1, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TResult>> function)
  19382. {
  19383. if (provider == null)
  19384. throw new ArgumentNullException("provider");
  19385. if (function == null)
  19386. throw new ArgumentNullException("function");
  19387. #if CRIPPLED_REFLECTION
  19388. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TResult>>)));
  19389. #else
  19390. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TResult));
  19391. #endif
  19392. return (t1) => provider.CreateQuery<TResult>(
  19393. Expression.Invoke(
  19394. Expression.Call(
  19395. null,
  19396. m,
  19397. Expression.Constant(provider, typeof(IQbservableProvider)),
  19398. function
  19399. ),
  19400. Expression.Constant(t1, typeof(TArg1))
  19401. )
  19402. );
  19403. }
  19404. /// <summary>
  19405. /// 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.
  19406. /// </summary>
  19407. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19408. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19409. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19410. /// <param name="function">Function to convert to an asynchronous function.</param>
  19411. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19412. /// <returns>Asynchronous function.</returns>
  19413. /// <exception cref="T:System.ArgumentNullException">
  19414. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19415. public static Func<TArg1, IQbservable<TResult>> ToAsync<TArg1, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TResult>> function, IScheduler scheduler)
  19416. {
  19417. if (provider == null)
  19418. throw new ArgumentNullException("provider");
  19419. if (function == null)
  19420. throw new ArgumentNullException("function");
  19421. if (scheduler == null)
  19422. throw new ArgumentNullException("scheduler");
  19423. #if CRIPPLED_REFLECTION
  19424. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TResult>>), default(IScheduler)));
  19425. #else
  19426. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TResult));
  19427. #endif
  19428. return (t1) => provider.CreateQuery<TResult>(
  19429. Expression.Invoke(
  19430. Expression.Call(
  19431. null,
  19432. m,
  19433. Expression.Constant(provider, typeof(IQbservableProvider)),
  19434. function,
  19435. Expression.Constant(scheduler, typeof(IScheduler))
  19436. ),
  19437. Expression.Constant(t1, typeof(TArg1))
  19438. )
  19439. );
  19440. }
  19441. /// <summary>
  19442. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19443. /// </summary>
  19444. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19445. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19446. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19447. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19448. /// <param name="function">Function to convert to an asynchronous function.</param>
  19449. /// <returns>Asynchronous function.</returns>
  19450. /// <exception cref="T:System.ArgumentNullException">
  19451. /// <paramref name="function" /> is null.</exception>
  19452. public static Func<TArg1, TArg2, IQbservable<TResult>> ToAsync<TArg1, TArg2, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TResult>> function)
  19453. {
  19454. if (provider == null)
  19455. throw new ArgumentNullException("provider");
  19456. if (function == null)
  19457. throw new ArgumentNullException("function");
  19458. #if CRIPPLED_REFLECTION
  19459. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TResult>>)));
  19460. #else
  19461. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TResult));
  19462. #endif
  19463. return (t1, t2) => provider.CreateQuery<TResult>(
  19464. Expression.Invoke(
  19465. Expression.Call(
  19466. null,
  19467. m,
  19468. Expression.Constant(provider, typeof(IQbservableProvider)),
  19469. function
  19470. ),
  19471. Expression.Constant(t1, typeof(TArg1)),
  19472. Expression.Constant(t2, typeof(TArg2))
  19473. )
  19474. );
  19475. }
  19476. /// <summary>
  19477. /// 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.
  19478. /// </summary>
  19479. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19480. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19481. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19482. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19483. /// <param name="function">Function to convert to an asynchronous function.</param>
  19484. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19485. /// <returns>Asynchronous function.</returns>
  19486. /// <exception cref="T:System.ArgumentNullException">
  19487. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19488. public static Func<TArg1, TArg2, IQbservable<TResult>> ToAsync<TArg1, TArg2, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TResult>> function, IScheduler scheduler)
  19489. {
  19490. if (provider == null)
  19491. throw new ArgumentNullException("provider");
  19492. if (function == null)
  19493. throw new ArgumentNullException("function");
  19494. if (scheduler == null)
  19495. throw new ArgumentNullException("scheduler");
  19496. #if CRIPPLED_REFLECTION
  19497. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TResult>>), default(IScheduler)));
  19498. #else
  19499. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TResult));
  19500. #endif
  19501. return (t1, t2) => provider.CreateQuery<TResult>(
  19502. Expression.Invoke(
  19503. Expression.Call(
  19504. null,
  19505. m,
  19506. Expression.Constant(provider, typeof(IQbservableProvider)),
  19507. function,
  19508. Expression.Constant(scheduler, typeof(IScheduler))
  19509. ),
  19510. Expression.Constant(t1, typeof(TArg1)),
  19511. Expression.Constant(t2, typeof(TArg2))
  19512. )
  19513. );
  19514. }
  19515. /// <summary>
  19516. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19517. /// </summary>
  19518. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19519. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19520. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19521. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19522. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19523. /// <param name="function">Function to convert to an asynchronous function.</param>
  19524. /// <returns>Asynchronous function.</returns>
  19525. /// <exception cref="T:System.ArgumentNullException">
  19526. /// <paramref name="function" /> is null.</exception>
  19527. public static Func<TArg1, TArg2, TArg3, IQbservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TResult>> function)
  19528. {
  19529. if (provider == null)
  19530. throw new ArgumentNullException("provider");
  19531. if (function == null)
  19532. throw new ArgumentNullException("function");
  19533. #if CRIPPLED_REFLECTION
  19534. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TResult>>)));
  19535. #else
  19536. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TResult));
  19537. #endif
  19538. return (t1, t2, t3) => provider.CreateQuery<TResult>(
  19539. Expression.Invoke(
  19540. Expression.Call(
  19541. null,
  19542. m,
  19543. Expression.Constant(provider, typeof(IQbservableProvider)),
  19544. function
  19545. ),
  19546. Expression.Constant(t1, typeof(TArg1)),
  19547. Expression.Constant(t2, typeof(TArg2)),
  19548. Expression.Constant(t3, typeof(TArg3))
  19549. )
  19550. );
  19551. }
  19552. /// <summary>
  19553. /// 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.
  19554. /// </summary>
  19555. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19556. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19557. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19558. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19559. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19560. /// <param name="function">Function to convert to an asynchronous function.</param>
  19561. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19562. /// <returns>Asynchronous function.</returns>
  19563. /// <exception cref="T:System.ArgumentNullException">
  19564. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19565. 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)
  19566. {
  19567. if (provider == null)
  19568. throw new ArgumentNullException("provider");
  19569. if (function == null)
  19570. throw new ArgumentNullException("function");
  19571. if (scheduler == null)
  19572. throw new ArgumentNullException("scheduler");
  19573. #if CRIPPLED_REFLECTION
  19574. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TResult>>), default(IScheduler)));
  19575. #else
  19576. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TResult));
  19577. #endif
  19578. return (t1, t2, t3) => provider.CreateQuery<TResult>(
  19579. Expression.Invoke(
  19580. Expression.Call(
  19581. null,
  19582. m,
  19583. Expression.Constant(provider, typeof(IQbservableProvider)),
  19584. function,
  19585. Expression.Constant(scheduler, typeof(IScheduler))
  19586. ),
  19587. Expression.Constant(t1, typeof(TArg1)),
  19588. Expression.Constant(t2, typeof(TArg2)),
  19589. Expression.Constant(t3, typeof(TArg3))
  19590. )
  19591. );
  19592. }
  19593. /// <summary>
  19594. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19595. /// </summary>
  19596. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19597. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19598. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19599. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19600. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19601. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19602. /// <param name="function">Function to convert to an asynchronous function.</param>
  19603. /// <returns>Asynchronous function.</returns>
  19604. /// <exception cref="T:System.ArgumentNullException">
  19605. /// <paramref name="function" /> is null.</exception>
  19606. 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)
  19607. {
  19608. if (provider == null)
  19609. throw new ArgumentNullException("provider");
  19610. if (function == null)
  19611. throw new ArgumentNullException("function");
  19612. #if CRIPPLED_REFLECTION
  19613. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TResult>>)));
  19614. #else
  19615. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TResult));
  19616. #endif
  19617. return (t1, t2, t3, t4) => provider.CreateQuery<TResult>(
  19618. Expression.Invoke(
  19619. Expression.Call(
  19620. null,
  19621. m,
  19622. Expression.Constant(provider, typeof(IQbservableProvider)),
  19623. function
  19624. ),
  19625. Expression.Constant(t1, typeof(TArg1)),
  19626. Expression.Constant(t2, typeof(TArg2)),
  19627. Expression.Constant(t3, typeof(TArg3)),
  19628. Expression.Constant(t4, typeof(TArg4))
  19629. )
  19630. );
  19631. }
  19632. /// <summary>
  19633. /// 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.
  19634. /// </summary>
  19635. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19636. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19637. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19638. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19639. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19640. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19641. /// <param name="function">Function to convert to an asynchronous function.</param>
  19642. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19643. /// <returns>Asynchronous function.</returns>
  19644. /// <exception cref="T:System.ArgumentNullException">
  19645. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19646. 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)
  19647. {
  19648. if (provider == null)
  19649. throw new ArgumentNullException("provider");
  19650. if (function == null)
  19651. throw new ArgumentNullException("function");
  19652. if (scheduler == null)
  19653. throw new ArgumentNullException("scheduler");
  19654. #if CRIPPLED_REFLECTION
  19655. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TResult>>), default(IScheduler)));
  19656. #else
  19657. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TResult));
  19658. #endif
  19659. return (t1, t2, t3, t4) => provider.CreateQuery<TResult>(
  19660. Expression.Invoke(
  19661. Expression.Call(
  19662. null,
  19663. m,
  19664. Expression.Constant(provider, typeof(IQbservableProvider)),
  19665. function,
  19666. Expression.Constant(scheduler, typeof(IScheduler))
  19667. ),
  19668. Expression.Constant(t1, typeof(TArg1)),
  19669. Expression.Constant(t2, typeof(TArg2)),
  19670. Expression.Constant(t3, typeof(TArg3)),
  19671. Expression.Constant(t4, typeof(TArg4))
  19672. )
  19673. );
  19674. }
  19675. #if !NO_LARGEARITY
  19676. /// <summary>
  19677. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19678. /// </summary>
  19679. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19680. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19681. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19682. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19683. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19684. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19685. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19686. /// <param name="function">Function to convert to an asynchronous function.</param>
  19687. /// <returns>Asynchronous function.</returns>
  19688. /// <exception cref="T:System.ArgumentNullException">
  19689. /// <paramref name="function" /> is null.</exception>
  19690. 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)
  19691. {
  19692. if (provider == null)
  19693. throw new ArgumentNullException("provider");
  19694. if (function == null)
  19695. throw new ArgumentNullException("function");
  19696. #if CRIPPLED_REFLECTION
  19697. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>>)));
  19698. #else
  19699. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TResult));
  19700. #endif
  19701. return (t1, t2, t3, t4, t5) => provider.CreateQuery<TResult>(
  19702. Expression.Invoke(
  19703. Expression.Call(
  19704. null,
  19705. m,
  19706. Expression.Constant(provider, typeof(IQbservableProvider)),
  19707. function
  19708. ),
  19709. Expression.Constant(t1, typeof(TArg1)),
  19710. Expression.Constant(t2, typeof(TArg2)),
  19711. Expression.Constant(t3, typeof(TArg3)),
  19712. Expression.Constant(t4, typeof(TArg4)),
  19713. Expression.Constant(t5, typeof(TArg5))
  19714. )
  19715. );
  19716. }
  19717. /// <summary>
  19718. /// 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.
  19719. /// </summary>
  19720. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19721. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19722. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19723. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19724. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19725. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19726. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19727. /// <param name="function">Function to convert to an asynchronous function.</param>
  19728. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19729. /// <returns>Asynchronous function.</returns>
  19730. /// <exception cref="T:System.ArgumentNullException">
  19731. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19732. 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)
  19733. {
  19734. if (provider == null)
  19735. throw new ArgumentNullException("provider");
  19736. if (function == null)
  19737. throw new ArgumentNullException("function");
  19738. if (scheduler == null)
  19739. throw new ArgumentNullException("scheduler");
  19740. #if CRIPPLED_REFLECTION
  19741. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>>), default(IScheduler)));
  19742. #else
  19743. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TResult));
  19744. #endif
  19745. return (t1, t2, t3, t4, t5) => provider.CreateQuery<TResult>(
  19746. Expression.Invoke(
  19747. Expression.Call(
  19748. null,
  19749. m,
  19750. Expression.Constant(provider, typeof(IQbservableProvider)),
  19751. function,
  19752. Expression.Constant(scheduler, typeof(IScheduler))
  19753. ),
  19754. Expression.Constant(t1, typeof(TArg1)),
  19755. Expression.Constant(t2, typeof(TArg2)),
  19756. Expression.Constant(t3, typeof(TArg3)),
  19757. Expression.Constant(t4, typeof(TArg4)),
  19758. Expression.Constant(t5, typeof(TArg5))
  19759. )
  19760. );
  19761. }
  19762. /// <summary>
  19763. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19764. /// </summary>
  19765. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19766. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19767. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19768. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19769. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19770. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19771. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19772. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19773. /// <param name="function">Function to convert to an asynchronous function.</param>
  19774. /// <returns>Asynchronous function.</returns>
  19775. /// <exception cref="T:System.ArgumentNullException">
  19776. /// <paramref name="function" /> is null.</exception>
  19777. 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)
  19778. {
  19779. if (provider == null)
  19780. throw new ArgumentNullException("provider");
  19781. if (function == null)
  19782. throw new ArgumentNullException("function");
  19783. #if CRIPPLED_REFLECTION
  19784. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TResult>>)));
  19785. #else
  19786. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TResult));
  19787. #endif
  19788. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<TResult>(
  19789. Expression.Invoke(
  19790. Expression.Call(
  19791. null,
  19792. m,
  19793. Expression.Constant(provider, typeof(IQbservableProvider)),
  19794. function
  19795. ),
  19796. Expression.Constant(t1, typeof(TArg1)),
  19797. Expression.Constant(t2, typeof(TArg2)),
  19798. Expression.Constant(t3, typeof(TArg3)),
  19799. Expression.Constant(t4, typeof(TArg4)),
  19800. Expression.Constant(t5, typeof(TArg5)),
  19801. Expression.Constant(t6, typeof(TArg6))
  19802. )
  19803. );
  19804. }
  19805. /// <summary>
  19806. /// 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.
  19807. /// </summary>
  19808. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19809. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19810. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19811. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19812. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19813. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19814. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19815. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19816. /// <param name="function">Function to convert to an asynchronous function.</param>
  19817. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19818. /// <returns>Asynchronous function.</returns>
  19819. /// <exception cref="T:System.ArgumentNullException">
  19820. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19821. 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)
  19822. {
  19823. if (provider == null)
  19824. throw new ArgumentNullException("provider");
  19825. if (function == null)
  19826. throw new ArgumentNullException("function");
  19827. if (scheduler == null)
  19828. throw new ArgumentNullException("scheduler");
  19829. #if CRIPPLED_REFLECTION
  19830. 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)));
  19831. #else
  19832. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TResult));
  19833. #endif
  19834. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<TResult>(
  19835. Expression.Invoke(
  19836. Expression.Call(
  19837. null,
  19838. m,
  19839. Expression.Constant(provider, typeof(IQbservableProvider)),
  19840. function,
  19841. Expression.Constant(scheduler, typeof(IScheduler))
  19842. ),
  19843. Expression.Constant(t1, typeof(TArg1)),
  19844. Expression.Constant(t2, typeof(TArg2)),
  19845. Expression.Constant(t3, typeof(TArg3)),
  19846. Expression.Constant(t4, typeof(TArg4)),
  19847. Expression.Constant(t5, typeof(TArg5)),
  19848. Expression.Constant(t6, typeof(TArg6))
  19849. )
  19850. );
  19851. }
  19852. /// <summary>
  19853. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19854. /// </summary>
  19855. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19856. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19857. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19858. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19859. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19860. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19861. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19862. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19863. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19864. /// <param name="function">Function to convert to an asynchronous function.</param>
  19865. /// <returns>Asynchronous function.</returns>
  19866. /// <exception cref="T:System.ArgumentNullException">
  19867. /// <paramref name="function" /> is null.</exception>
  19868. 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)
  19869. {
  19870. if (provider == null)
  19871. throw new ArgumentNullException("provider");
  19872. if (function == null)
  19873. throw new ArgumentNullException("function");
  19874. #if CRIPPLED_REFLECTION
  19875. 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>>)));
  19876. #else
  19877. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TResult));
  19878. #endif
  19879. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<TResult>(
  19880. Expression.Invoke(
  19881. Expression.Call(
  19882. null,
  19883. m,
  19884. Expression.Constant(provider, typeof(IQbservableProvider)),
  19885. function
  19886. ),
  19887. Expression.Constant(t1, typeof(TArg1)),
  19888. Expression.Constant(t2, typeof(TArg2)),
  19889. Expression.Constant(t3, typeof(TArg3)),
  19890. Expression.Constant(t4, typeof(TArg4)),
  19891. Expression.Constant(t5, typeof(TArg5)),
  19892. Expression.Constant(t6, typeof(TArg6)),
  19893. Expression.Constant(t7, typeof(TArg7))
  19894. )
  19895. );
  19896. }
  19897. /// <summary>
  19898. /// 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.
  19899. /// </summary>
  19900. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19901. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19902. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19903. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19904. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19905. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19906. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19907. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19908. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19909. /// <param name="function">Function to convert to an asynchronous function.</param>
  19910. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19911. /// <returns>Asynchronous function.</returns>
  19912. /// <exception cref="T:System.ArgumentNullException">
  19913. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19914. 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)
  19915. {
  19916. if (provider == null)
  19917. throw new ArgumentNullException("provider");
  19918. if (function == null)
  19919. throw new ArgumentNullException("function");
  19920. if (scheduler == null)
  19921. throw new ArgumentNullException("scheduler");
  19922. #if CRIPPLED_REFLECTION
  19923. 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)));
  19924. #else
  19925. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TResult));
  19926. #endif
  19927. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<TResult>(
  19928. Expression.Invoke(
  19929. Expression.Call(
  19930. null,
  19931. m,
  19932. Expression.Constant(provider, typeof(IQbservableProvider)),
  19933. function,
  19934. Expression.Constant(scheduler, typeof(IScheduler))
  19935. ),
  19936. Expression.Constant(t1, typeof(TArg1)),
  19937. Expression.Constant(t2, typeof(TArg2)),
  19938. Expression.Constant(t3, typeof(TArg3)),
  19939. Expression.Constant(t4, typeof(TArg4)),
  19940. Expression.Constant(t5, typeof(TArg5)),
  19941. Expression.Constant(t6, typeof(TArg6)),
  19942. Expression.Constant(t7, typeof(TArg7))
  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.
  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="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19957. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19958. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19959. /// <param name="function">Function to convert to an asynchronous function.</param>
  19960. /// <returns>Asynchronous function.</returns>
  19961. /// <exception cref="T:System.ArgumentNullException">
  19962. /// <paramref name="function" /> is null.</exception>
  19963. 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)
  19964. {
  19965. if (provider == null)
  19966. throw new ArgumentNullException("provider");
  19967. if (function == null)
  19968. throw new ArgumentNullException("function");
  19969. #if CRIPPLED_REFLECTION
  19970. 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>>)));
  19971. #else
  19972. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TResult));
  19973. #endif
  19974. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<TResult>(
  19975. Expression.Invoke(
  19976. Expression.Call(
  19977. null,
  19978. m,
  19979. Expression.Constant(provider, typeof(IQbservableProvider)),
  19980. function
  19981. ),
  19982. Expression.Constant(t1, typeof(TArg1)),
  19983. Expression.Constant(t2, typeof(TArg2)),
  19984. Expression.Constant(t3, typeof(TArg3)),
  19985. Expression.Constant(t4, typeof(TArg4)),
  19986. Expression.Constant(t5, typeof(TArg5)),
  19987. Expression.Constant(t6, typeof(TArg6)),
  19988. Expression.Constant(t7, typeof(TArg7)),
  19989. Expression.Constant(t8, typeof(TArg8))
  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 on the specified scheduler.
  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="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20005. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20006. /// <param name="function">Function to convert to an asynchronous function.</param>
  20007. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20008. /// <returns>Asynchronous function.</returns>
  20009. /// <exception cref="T:System.ArgumentNullException">
  20010. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20011. 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)
  20012. {
  20013. if (provider == null)
  20014. throw new ArgumentNullException("provider");
  20015. if (function == null)
  20016. throw new ArgumentNullException("function");
  20017. if (scheduler == null)
  20018. throw new ArgumentNullException("scheduler");
  20019. #if CRIPPLED_REFLECTION
  20020. 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)));
  20021. #else
  20022. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TResult));
  20023. #endif
  20024. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<TResult>(
  20025. Expression.Invoke(
  20026. Expression.Call(
  20027. null,
  20028. m,
  20029. Expression.Constant(provider, typeof(IQbservableProvider)),
  20030. function,
  20031. Expression.Constant(scheduler, typeof(IScheduler))
  20032. ),
  20033. Expression.Constant(t1, typeof(TArg1)),
  20034. Expression.Constant(t2, typeof(TArg2)),
  20035. Expression.Constant(t3, typeof(TArg3)),
  20036. Expression.Constant(t4, typeof(TArg4)),
  20037. Expression.Constant(t5, typeof(TArg5)),
  20038. Expression.Constant(t6, typeof(TArg6)),
  20039. Expression.Constant(t7, typeof(TArg7)),
  20040. Expression.Constant(t8, typeof(TArg8))
  20041. )
  20042. );
  20043. }
  20044. /// <summary>
  20045. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20046. /// </summary>
  20047. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20048. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20049. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20050. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20051. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20052. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20053. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20054. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20055. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20056. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20057. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20058. /// <param name="function">Function to convert to an asynchronous function.</param>
  20059. /// <returns>Asynchronous function.</returns>
  20060. /// <exception cref="T:System.ArgumentNullException">
  20061. /// <paramref name="function" /> is null.</exception>
  20062. 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)
  20063. {
  20064. if (provider == null)
  20065. throw new ArgumentNullException("provider");
  20066. if (function == null)
  20067. throw new ArgumentNullException("function");
  20068. #if CRIPPLED_REFLECTION
  20069. 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>>)));
  20070. #else
  20071. 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));
  20072. #endif
  20073. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<TResult>(
  20074. Expression.Invoke(
  20075. Expression.Call(
  20076. null,
  20077. m,
  20078. Expression.Constant(provider, typeof(IQbservableProvider)),
  20079. function
  20080. ),
  20081. Expression.Constant(t1, typeof(TArg1)),
  20082. Expression.Constant(t2, typeof(TArg2)),
  20083. Expression.Constant(t3, typeof(TArg3)),
  20084. Expression.Constant(t4, typeof(TArg4)),
  20085. Expression.Constant(t5, typeof(TArg5)),
  20086. Expression.Constant(t6, typeof(TArg6)),
  20087. Expression.Constant(t7, typeof(TArg7)),
  20088. Expression.Constant(t8, typeof(TArg8)),
  20089. Expression.Constant(t9, typeof(TArg9))
  20090. )
  20091. );
  20092. }
  20093. /// <summary>
  20094. /// 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.
  20095. /// </summary>
  20096. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20097. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20098. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20099. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20100. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20101. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20102. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20103. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20104. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20105. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20106. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20107. /// <param name="function">Function to convert to an asynchronous function.</param>
  20108. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20109. /// <returns>Asynchronous function.</returns>
  20110. /// <exception cref="T:System.ArgumentNullException">
  20111. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20112. 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)
  20113. {
  20114. if (provider == null)
  20115. throw new ArgumentNullException("provider");
  20116. if (function == null)
  20117. throw new ArgumentNullException("function");
  20118. if (scheduler == null)
  20119. throw new ArgumentNullException("scheduler");
  20120. #if CRIPPLED_REFLECTION
  20121. 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)));
  20122. #else
  20123. 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));
  20124. #endif
  20125. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<TResult>(
  20126. Expression.Invoke(
  20127. Expression.Call(
  20128. null,
  20129. m,
  20130. Expression.Constant(provider, typeof(IQbservableProvider)),
  20131. function,
  20132. Expression.Constant(scheduler, typeof(IScheduler))
  20133. ),
  20134. Expression.Constant(t1, typeof(TArg1)),
  20135. Expression.Constant(t2, typeof(TArg2)),
  20136. Expression.Constant(t3, typeof(TArg3)),
  20137. Expression.Constant(t4, typeof(TArg4)),
  20138. Expression.Constant(t5, typeof(TArg5)),
  20139. Expression.Constant(t6, typeof(TArg6)),
  20140. Expression.Constant(t7, typeof(TArg7)),
  20141. Expression.Constant(t8, typeof(TArg8)),
  20142. Expression.Constant(t9, typeof(TArg9))
  20143. )
  20144. );
  20145. }
  20146. /// <summary>
  20147. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20148. /// </summary>
  20149. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20150. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20151. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20152. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20153. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20154. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20155. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20156. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20157. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20158. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20159. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20160. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20161. /// <param name="function">Function to convert to an asynchronous function.</param>
  20162. /// <returns>Asynchronous function.</returns>
  20163. /// <exception cref="T:System.ArgumentNullException">
  20164. /// <paramref name="function" /> is null.</exception>
  20165. 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)
  20166. {
  20167. if (provider == null)
  20168. throw new ArgumentNullException("provider");
  20169. if (function == null)
  20170. throw new ArgumentNullException("function");
  20171. #if CRIPPLED_REFLECTION
  20172. 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>>)));
  20173. #else
  20174. 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));
  20175. #endif
  20176. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<TResult>(
  20177. Expression.Invoke(
  20178. Expression.Call(
  20179. null,
  20180. m,
  20181. Expression.Constant(provider, typeof(IQbservableProvider)),
  20182. function
  20183. ),
  20184. Expression.Constant(t1, typeof(TArg1)),
  20185. Expression.Constant(t2, typeof(TArg2)),
  20186. Expression.Constant(t3, typeof(TArg3)),
  20187. Expression.Constant(t4, typeof(TArg4)),
  20188. Expression.Constant(t5, typeof(TArg5)),
  20189. Expression.Constant(t6, typeof(TArg6)),
  20190. Expression.Constant(t7, typeof(TArg7)),
  20191. Expression.Constant(t8, typeof(TArg8)),
  20192. Expression.Constant(t9, typeof(TArg9)),
  20193. Expression.Constant(t10, typeof(TArg10))
  20194. )
  20195. );
  20196. }
  20197. /// <summary>
  20198. /// 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.
  20199. /// </summary>
  20200. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20201. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20202. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20203. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20204. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20205. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20206. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20207. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20208. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20209. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20210. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20211. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20212. /// <param name="function">Function to convert to an asynchronous function.</param>
  20213. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20214. /// <returns>Asynchronous function.</returns>
  20215. /// <exception cref="T:System.ArgumentNullException">
  20216. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20217. 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)
  20218. {
  20219. if (provider == null)
  20220. throw new ArgumentNullException("provider");
  20221. if (function == null)
  20222. throw new ArgumentNullException("function");
  20223. if (scheduler == null)
  20224. throw new ArgumentNullException("scheduler");
  20225. #if CRIPPLED_REFLECTION
  20226. 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)));
  20227. #else
  20228. 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));
  20229. #endif
  20230. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<TResult>(
  20231. Expression.Invoke(
  20232. Expression.Call(
  20233. null,
  20234. m,
  20235. Expression.Constant(provider, typeof(IQbservableProvider)),
  20236. function,
  20237. Expression.Constant(scheduler, typeof(IScheduler))
  20238. ),
  20239. Expression.Constant(t1, typeof(TArg1)),
  20240. Expression.Constant(t2, typeof(TArg2)),
  20241. Expression.Constant(t3, typeof(TArg3)),
  20242. Expression.Constant(t4, typeof(TArg4)),
  20243. Expression.Constant(t5, typeof(TArg5)),
  20244. Expression.Constant(t6, typeof(TArg6)),
  20245. Expression.Constant(t7, typeof(TArg7)),
  20246. Expression.Constant(t8, typeof(TArg8)),
  20247. Expression.Constant(t9, typeof(TArg9)),
  20248. Expression.Constant(t10, typeof(TArg10))
  20249. )
  20250. );
  20251. }
  20252. /// <summary>
  20253. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20254. /// </summary>
  20255. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20256. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20257. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20258. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20259. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20260. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20261. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20262. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20263. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20264. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20265. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20266. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20267. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20268. /// <param name="function">Function to convert to an asynchronous function.</param>
  20269. /// <returns>Asynchronous function.</returns>
  20270. /// <exception cref="T:System.ArgumentNullException">
  20271. /// <paramref name="function" /> is null.</exception>
  20272. 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)
  20273. {
  20274. if (provider == null)
  20275. throw new ArgumentNullException("provider");
  20276. if (function == null)
  20277. throw new ArgumentNullException("function");
  20278. #if CRIPPLED_REFLECTION
  20279. 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>>)));
  20280. #else
  20281. 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));
  20282. #endif
  20283. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<TResult>(
  20284. Expression.Invoke(
  20285. Expression.Call(
  20286. null,
  20287. m,
  20288. Expression.Constant(provider, typeof(IQbservableProvider)),
  20289. function
  20290. ),
  20291. Expression.Constant(t1, typeof(TArg1)),
  20292. Expression.Constant(t2, typeof(TArg2)),
  20293. Expression.Constant(t3, typeof(TArg3)),
  20294. Expression.Constant(t4, typeof(TArg4)),
  20295. Expression.Constant(t5, typeof(TArg5)),
  20296. Expression.Constant(t6, typeof(TArg6)),
  20297. Expression.Constant(t7, typeof(TArg7)),
  20298. Expression.Constant(t8, typeof(TArg8)),
  20299. Expression.Constant(t9, typeof(TArg9)),
  20300. Expression.Constant(t10, typeof(TArg10)),
  20301. Expression.Constant(t11, typeof(TArg11))
  20302. )
  20303. );
  20304. }
  20305. /// <summary>
  20306. /// 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.
  20307. /// </summary>
  20308. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20309. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20310. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20311. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20312. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20313. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20314. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20315. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20316. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20317. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20318. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20319. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20320. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20321. /// <param name="function">Function to convert to an asynchronous function.</param>
  20322. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20323. /// <returns>Asynchronous function.</returns>
  20324. /// <exception cref="T:System.ArgumentNullException">
  20325. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20326. 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)
  20327. {
  20328. if (provider == null)
  20329. throw new ArgumentNullException("provider");
  20330. if (function == null)
  20331. throw new ArgumentNullException("function");
  20332. if (scheduler == null)
  20333. throw new ArgumentNullException("scheduler");
  20334. #if CRIPPLED_REFLECTION
  20335. 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)));
  20336. #else
  20337. 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));
  20338. #endif
  20339. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<TResult>(
  20340. Expression.Invoke(
  20341. Expression.Call(
  20342. null,
  20343. m,
  20344. Expression.Constant(provider, typeof(IQbservableProvider)),
  20345. function,
  20346. Expression.Constant(scheduler, typeof(IScheduler))
  20347. ),
  20348. Expression.Constant(t1, typeof(TArg1)),
  20349. Expression.Constant(t2, typeof(TArg2)),
  20350. Expression.Constant(t3, typeof(TArg3)),
  20351. Expression.Constant(t4, typeof(TArg4)),
  20352. Expression.Constant(t5, typeof(TArg5)),
  20353. Expression.Constant(t6, typeof(TArg6)),
  20354. Expression.Constant(t7, typeof(TArg7)),
  20355. Expression.Constant(t8, typeof(TArg8)),
  20356. Expression.Constant(t9, typeof(TArg9)),
  20357. Expression.Constant(t10, typeof(TArg10)),
  20358. Expression.Constant(t11, typeof(TArg11))
  20359. )
  20360. );
  20361. }
  20362. /// <summary>
  20363. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20364. /// </summary>
  20365. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20366. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20367. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20368. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20369. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20370. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20371. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20372. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20373. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20374. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20375. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20376. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20377. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20378. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20379. /// <param name="function">Function to convert to an asynchronous function.</param>
  20380. /// <returns>Asynchronous function.</returns>
  20381. /// <exception cref="T:System.ArgumentNullException">
  20382. /// <paramref name="function" /> is null.</exception>
  20383. 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)
  20384. {
  20385. if (provider == null)
  20386. throw new ArgumentNullException("provider");
  20387. if (function == null)
  20388. throw new ArgumentNullException("function");
  20389. #if CRIPPLED_REFLECTION
  20390. 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>>)));
  20391. #else
  20392. 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));
  20393. #endif
  20394. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<TResult>(
  20395. Expression.Invoke(
  20396. Expression.Call(
  20397. null,
  20398. m,
  20399. Expression.Constant(provider, typeof(IQbservableProvider)),
  20400. function
  20401. ),
  20402. Expression.Constant(t1, typeof(TArg1)),
  20403. Expression.Constant(t2, typeof(TArg2)),
  20404. Expression.Constant(t3, typeof(TArg3)),
  20405. Expression.Constant(t4, typeof(TArg4)),
  20406. Expression.Constant(t5, typeof(TArg5)),
  20407. Expression.Constant(t6, typeof(TArg6)),
  20408. Expression.Constant(t7, typeof(TArg7)),
  20409. Expression.Constant(t8, typeof(TArg8)),
  20410. Expression.Constant(t9, typeof(TArg9)),
  20411. Expression.Constant(t10, typeof(TArg10)),
  20412. Expression.Constant(t11, typeof(TArg11)),
  20413. Expression.Constant(t12, typeof(TArg12))
  20414. )
  20415. );
  20416. }
  20417. /// <summary>
  20418. /// 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.
  20419. /// </summary>
  20420. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20421. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20422. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20423. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20424. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20425. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20426. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20427. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20428. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20429. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20430. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20431. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20432. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20433. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20434. /// <param name="function">Function to convert to an asynchronous function.</param>
  20435. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20436. /// <returns>Asynchronous function.</returns>
  20437. /// <exception cref="T:System.ArgumentNullException">
  20438. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20439. 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)
  20440. {
  20441. if (provider == null)
  20442. throw new ArgumentNullException("provider");
  20443. if (function == null)
  20444. throw new ArgumentNullException("function");
  20445. if (scheduler == null)
  20446. throw new ArgumentNullException("scheduler");
  20447. #if CRIPPLED_REFLECTION
  20448. 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)));
  20449. #else
  20450. 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));
  20451. #endif
  20452. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<TResult>(
  20453. Expression.Invoke(
  20454. Expression.Call(
  20455. null,
  20456. m,
  20457. Expression.Constant(provider, typeof(IQbservableProvider)),
  20458. function,
  20459. Expression.Constant(scheduler, typeof(IScheduler))
  20460. ),
  20461. Expression.Constant(t1, typeof(TArg1)),
  20462. Expression.Constant(t2, typeof(TArg2)),
  20463. Expression.Constant(t3, typeof(TArg3)),
  20464. Expression.Constant(t4, typeof(TArg4)),
  20465. Expression.Constant(t5, typeof(TArg5)),
  20466. Expression.Constant(t6, typeof(TArg6)),
  20467. Expression.Constant(t7, typeof(TArg7)),
  20468. Expression.Constant(t8, typeof(TArg8)),
  20469. Expression.Constant(t9, typeof(TArg9)),
  20470. Expression.Constant(t10, typeof(TArg10)),
  20471. Expression.Constant(t11, typeof(TArg11)),
  20472. Expression.Constant(t12, typeof(TArg12))
  20473. )
  20474. );
  20475. }
  20476. /// <summary>
  20477. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20478. /// </summary>
  20479. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20480. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20481. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20482. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20483. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20484. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20485. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20486. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20487. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20488. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20489. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20490. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20491. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20492. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20493. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20494. /// <param name="function">Function to convert to an asynchronous function.</param>
  20495. /// <returns>Asynchronous function.</returns>
  20496. /// <exception cref="T:System.ArgumentNullException">
  20497. /// <paramref name="function" /> is null.</exception>
  20498. 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)
  20499. {
  20500. if (provider == null)
  20501. throw new ArgumentNullException("provider");
  20502. if (function == null)
  20503. throw new ArgumentNullException("function");
  20504. #if CRIPPLED_REFLECTION
  20505. 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>>)));
  20506. #else
  20507. 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));
  20508. #endif
  20509. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<TResult>(
  20510. Expression.Invoke(
  20511. Expression.Call(
  20512. null,
  20513. m,
  20514. Expression.Constant(provider, typeof(IQbservableProvider)),
  20515. function
  20516. ),
  20517. Expression.Constant(t1, typeof(TArg1)),
  20518. Expression.Constant(t2, typeof(TArg2)),
  20519. Expression.Constant(t3, typeof(TArg3)),
  20520. Expression.Constant(t4, typeof(TArg4)),
  20521. Expression.Constant(t5, typeof(TArg5)),
  20522. Expression.Constant(t6, typeof(TArg6)),
  20523. Expression.Constant(t7, typeof(TArg7)),
  20524. Expression.Constant(t8, typeof(TArg8)),
  20525. Expression.Constant(t9, typeof(TArg9)),
  20526. Expression.Constant(t10, typeof(TArg10)),
  20527. Expression.Constant(t11, typeof(TArg11)),
  20528. Expression.Constant(t12, typeof(TArg12)),
  20529. Expression.Constant(t13, typeof(TArg13))
  20530. )
  20531. );
  20532. }
  20533. /// <summary>
  20534. /// 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.
  20535. /// </summary>
  20536. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20537. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20538. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20539. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20540. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20541. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20542. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20543. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20544. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20545. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20546. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20547. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20548. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20549. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20550. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20551. /// <param name="function">Function to convert to an asynchronous function.</param>
  20552. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20553. /// <returns>Asynchronous function.</returns>
  20554. /// <exception cref="T:System.ArgumentNullException">
  20555. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20556. 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)
  20557. {
  20558. if (provider == null)
  20559. throw new ArgumentNullException("provider");
  20560. if (function == null)
  20561. throw new ArgumentNullException("function");
  20562. if (scheduler == null)
  20563. throw new ArgumentNullException("scheduler");
  20564. #if CRIPPLED_REFLECTION
  20565. 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)));
  20566. #else
  20567. 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));
  20568. #endif
  20569. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<TResult>(
  20570. Expression.Invoke(
  20571. Expression.Call(
  20572. null,
  20573. m,
  20574. Expression.Constant(provider, typeof(IQbservableProvider)),
  20575. function,
  20576. Expression.Constant(scheduler, typeof(IScheduler))
  20577. ),
  20578. Expression.Constant(t1, typeof(TArg1)),
  20579. Expression.Constant(t2, typeof(TArg2)),
  20580. Expression.Constant(t3, typeof(TArg3)),
  20581. Expression.Constant(t4, typeof(TArg4)),
  20582. Expression.Constant(t5, typeof(TArg5)),
  20583. Expression.Constant(t6, typeof(TArg6)),
  20584. Expression.Constant(t7, typeof(TArg7)),
  20585. Expression.Constant(t8, typeof(TArg8)),
  20586. Expression.Constant(t9, typeof(TArg9)),
  20587. Expression.Constant(t10, typeof(TArg10)),
  20588. Expression.Constant(t11, typeof(TArg11)),
  20589. Expression.Constant(t12, typeof(TArg12)),
  20590. Expression.Constant(t13, typeof(TArg13))
  20591. )
  20592. );
  20593. }
  20594. /// <summary>
  20595. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20596. /// </summary>
  20597. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20598. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20599. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20600. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20601. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20602. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20603. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20604. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20605. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20606. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20607. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20608. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20609. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20610. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20611. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20612. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20613. /// <param name="function">Function to convert to an asynchronous function.</param>
  20614. /// <returns>Asynchronous function.</returns>
  20615. /// <exception cref="T:System.ArgumentNullException">
  20616. /// <paramref name="function" /> is null.</exception>
  20617. 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)
  20618. {
  20619. if (provider == null)
  20620. throw new ArgumentNullException("provider");
  20621. if (function == null)
  20622. throw new ArgumentNullException("function");
  20623. #if CRIPPLED_REFLECTION
  20624. 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>>)));
  20625. #else
  20626. 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));
  20627. #endif
  20628. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<TResult>(
  20629. Expression.Invoke(
  20630. Expression.Call(
  20631. null,
  20632. m,
  20633. Expression.Constant(provider, typeof(IQbservableProvider)),
  20634. function
  20635. ),
  20636. Expression.Constant(t1, typeof(TArg1)),
  20637. Expression.Constant(t2, typeof(TArg2)),
  20638. Expression.Constant(t3, typeof(TArg3)),
  20639. Expression.Constant(t4, typeof(TArg4)),
  20640. Expression.Constant(t5, typeof(TArg5)),
  20641. Expression.Constant(t6, typeof(TArg6)),
  20642. Expression.Constant(t7, typeof(TArg7)),
  20643. Expression.Constant(t8, typeof(TArg8)),
  20644. Expression.Constant(t9, typeof(TArg9)),
  20645. Expression.Constant(t10, typeof(TArg10)),
  20646. Expression.Constant(t11, typeof(TArg11)),
  20647. Expression.Constant(t12, typeof(TArg12)),
  20648. Expression.Constant(t13, typeof(TArg13)),
  20649. Expression.Constant(t14, typeof(TArg14))
  20650. )
  20651. );
  20652. }
  20653. /// <summary>
  20654. /// 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.
  20655. /// </summary>
  20656. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20657. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20658. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20659. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20660. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20661. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20662. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20663. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20664. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20665. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20666. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20667. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20668. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20669. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20670. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20671. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20672. /// <param name="function">Function to convert to an asynchronous function.</param>
  20673. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20674. /// <returns>Asynchronous function.</returns>
  20675. /// <exception cref="T:System.ArgumentNullException">
  20676. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20677. 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)
  20678. {
  20679. if (provider == null)
  20680. throw new ArgumentNullException("provider");
  20681. if (function == null)
  20682. throw new ArgumentNullException("function");
  20683. if (scheduler == null)
  20684. throw new ArgumentNullException("scheduler");
  20685. #if CRIPPLED_REFLECTION
  20686. 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)));
  20687. #else
  20688. 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));
  20689. #endif
  20690. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<TResult>(
  20691. Expression.Invoke(
  20692. Expression.Call(
  20693. null,
  20694. m,
  20695. Expression.Constant(provider, typeof(IQbservableProvider)),
  20696. function,
  20697. Expression.Constant(scheduler, typeof(IScheduler))
  20698. ),
  20699. Expression.Constant(t1, typeof(TArg1)),
  20700. Expression.Constant(t2, typeof(TArg2)),
  20701. Expression.Constant(t3, typeof(TArg3)),
  20702. Expression.Constant(t4, typeof(TArg4)),
  20703. Expression.Constant(t5, typeof(TArg5)),
  20704. Expression.Constant(t6, typeof(TArg6)),
  20705. Expression.Constant(t7, typeof(TArg7)),
  20706. Expression.Constant(t8, typeof(TArg8)),
  20707. Expression.Constant(t9, typeof(TArg9)),
  20708. Expression.Constant(t10, typeof(TArg10)),
  20709. Expression.Constant(t11, typeof(TArg11)),
  20710. Expression.Constant(t12, typeof(TArg12)),
  20711. Expression.Constant(t13, typeof(TArg13)),
  20712. Expression.Constant(t14, typeof(TArg14))
  20713. )
  20714. );
  20715. }
  20716. /// <summary>
  20717. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20718. /// </summary>
  20719. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20720. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20721. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20722. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20723. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20724. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20725. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20726. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20727. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20728. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20729. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20730. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20731. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20732. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20733. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20734. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the function.</typeparam>
  20735. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20736. /// <param name="function">Function to convert to an asynchronous function.</param>
  20737. /// <returns>Asynchronous function.</returns>
  20738. /// <exception cref="T:System.ArgumentNullException">
  20739. /// <paramref name="function" /> is null.</exception>
  20740. 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)
  20741. {
  20742. if (provider == null)
  20743. throw new ArgumentNullException("provider");
  20744. if (function == null)
  20745. throw new ArgumentNullException("function");
  20746. #if CRIPPLED_REFLECTION
  20747. 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>>)));
  20748. #else
  20749. 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));
  20750. #endif
  20751. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) => provider.CreateQuery<TResult>(
  20752. Expression.Invoke(
  20753. Expression.Call(
  20754. null,
  20755. m,
  20756. Expression.Constant(provider, typeof(IQbservableProvider)),
  20757. function
  20758. ),
  20759. Expression.Constant(t1, typeof(TArg1)),
  20760. Expression.Constant(t2, typeof(TArg2)),
  20761. Expression.Constant(t3, typeof(TArg3)),
  20762. Expression.Constant(t4, typeof(TArg4)),
  20763. Expression.Constant(t5, typeof(TArg5)),
  20764. Expression.Constant(t6, typeof(TArg6)),
  20765. Expression.Constant(t7, typeof(TArg7)),
  20766. Expression.Constant(t8, typeof(TArg8)),
  20767. Expression.Constant(t9, typeof(TArg9)),
  20768. Expression.Constant(t10, typeof(TArg10)),
  20769. Expression.Constant(t11, typeof(TArg11)),
  20770. Expression.Constant(t12, typeof(TArg12)),
  20771. Expression.Constant(t13, typeof(TArg13)),
  20772. Expression.Constant(t14, typeof(TArg14)),
  20773. Expression.Constant(t15, typeof(TArg15))
  20774. )
  20775. );
  20776. }
  20777. /// <summary>
  20778. /// 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.
  20779. /// </summary>
  20780. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20781. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20782. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20783. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20784. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20785. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20786. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20787. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20788. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20789. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20790. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20791. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20792. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20793. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20794. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20795. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the function.</typeparam>
  20796. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20797. /// <param name="function">Function to convert to an asynchronous function.</param>
  20798. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20799. /// <returns>Asynchronous function.</returns>
  20800. /// <exception cref="T:System.ArgumentNullException">
  20801. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20802. 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)
  20803. {
  20804. if (provider == null)
  20805. throw new ArgumentNullException("provider");
  20806. if (function == null)
  20807. throw new ArgumentNullException("function");
  20808. if (scheduler == null)
  20809. throw new ArgumentNullException("scheduler");
  20810. #if CRIPPLED_REFLECTION
  20811. 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)));
  20812. #else
  20813. 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));
  20814. #endif
  20815. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) => provider.CreateQuery<TResult>(
  20816. Expression.Invoke(
  20817. Expression.Call(
  20818. null,
  20819. m,
  20820. Expression.Constant(provider, typeof(IQbservableProvider)),
  20821. function,
  20822. Expression.Constant(scheduler, typeof(IScheduler))
  20823. ),
  20824. Expression.Constant(t1, typeof(TArg1)),
  20825. Expression.Constant(t2, typeof(TArg2)),
  20826. Expression.Constant(t3, typeof(TArg3)),
  20827. Expression.Constant(t4, typeof(TArg4)),
  20828. Expression.Constant(t5, typeof(TArg5)),
  20829. Expression.Constant(t6, typeof(TArg6)),
  20830. Expression.Constant(t7, typeof(TArg7)),
  20831. Expression.Constant(t8, typeof(TArg8)),
  20832. Expression.Constant(t9, typeof(TArg9)),
  20833. Expression.Constant(t10, typeof(TArg10)),
  20834. Expression.Constant(t11, typeof(TArg11)),
  20835. Expression.Constant(t12, typeof(TArg12)),
  20836. Expression.Constant(t13, typeof(TArg13)),
  20837. Expression.Constant(t14, typeof(TArg14)),
  20838. Expression.Constant(t15, typeof(TArg15))
  20839. )
  20840. );
  20841. }
  20842. /// <summary>
  20843. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20844. /// </summary>
  20845. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20846. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20847. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20848. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20849. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20850. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20851. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20852. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20853. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20854. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20855. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20856. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20857. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20858. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20859. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20860. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the function.</typeparam>
  20861. /// <typeparam name="TArg16">The type of the sixteenth argument passed to the function.</typeparam>
  20862. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20863. /// <param name="function">Function to convert to an asynchronous function.</param>
  20864. /// <returns>Asynchronous function.</returns>
  20865. /// <exception cref="T:System.ArgumentNullException">
  20866. /// <paramref name="function" /> is null.</exception>
  20867. 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)
  20868. {
  20869. if (provider == null)
  20870. throw new ArgumentNullException("provider");
  20871. if (function == null)
  20872. throw new ArgumentNullException("function");
  20873. #if CRIPPLED_REFLECTION
  20874. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TArg16, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TArg16, TResult>>)));
  20875. #else
  20876. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10), typeof(TArg11), typeof(TArg12), typeof(TArg13), typeof(TArg14), typeof(TArg15), typeof(TArg16), typeof(TResult));
  20877. #endif
  20878. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) => provider.CreateQuery<TResult>(
  20879. Expression.Invoke(
  20880. Expression.Call(
  20881. null,
  20882. m,
  20883. Expression.Constant(provider, typeof(IQbservableProvider)),
  20884. function
  20885. ),
  20886. Expression.Constant(t1, typeof(TArg1)),
  20887. Expression.Constant(t2, typeof(TArg2)),
  20888. Expression.Constant(t3, typeof(TArg3)),
  20889. Expression.Constant(t4, typeof(TArg4)),
  20890. Expression.Constant(t5, typeof(TArg5)),
  20891. Expression.Constant(t6, typeof(TArg6)),
  20892. Expression.Constant(t7, typeof(TArg7)),
  20893. Expression.Constant(t8, typeof(TArg8)),
  20894. Expression.Constant(t9, typeof(TArg9)),
  20895. Expression.Constant(t10, typeof(TArg10)),
  20896. Expression.Constant(t11, typeof(TArg11)),
  20897. Expression.Constant(t12, typeof(TArg12)),
  20898. Expression.Constant(t13, typeof(TArg13)),
  20899. Expression.Constant(t14, typeof(TArg14)),
  20900. Expression.Constant(t15, typeof(TArg15)),
  20901. Expression.Constant(t16, typeof(TArg16))
  20902. )
  20903. );
  20904. }
  20905. /// <summary>
  20906. /// 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.
  20907. /// </summary>
  20908. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20909. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20910. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20911. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20912. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20913. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20914. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20915. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20916. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20917. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20918. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20919. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20920. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20921. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20922. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20923. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the function.</typeparam>
  20924. /// <typeparam name="TArg16">The type of the sixteenth argument passed to the function.</typeparam>
  20925. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20926. /// <param name="function">Function to convert to an asynchronous function.</param>
  20927. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20928. /// <returns>Asynchronous function.</returns>
  20929. /// <exception cref="T:System.ArgumentNullException">
  20930. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20931. 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)
  20932. {
  20933. if (provider == null)
  20934. throw new ArgumentNullException("provider");
  20935. if (function == null)
  20936. throw new ArgumentNullException("function");
  20937. if (scheduler == null)
  20938. throw new ArgumentNullException("scheduler");
  20939. #if CRIPPLED_REFLECTION
  20940. 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)));
  20941. #else
  20942. 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));
  20943. #endif
  20944. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) => provider.CreateQuery<TResult>(
  20945. Expression.Invoke(
  20946. Expression.Call(
  20947. null,
  20948. m,
  20949. Expression.Constant(provider, typeof(IQbservableProvider)),
  20950. function,
  20951. Expression.Constant(scheduler, typeof(IScheduler))
  20952. ),
  20953. Expression.Constant(t1, typeof(TArg1)),
  20954. Expression.Constant(t2, typeof(TArg2)),
  20955. Expression.Constant(t3, typeof(TArg3)),
  20956. Expression.Constant(t4, typeof(TArg4)),
  20957. Expression.Constant(t5, typeof(TArg5)),
  20958. Expression.Constant(t6, typeof(TArg6)),
  20959. Expression.Constant(t7, typeof(TArg7)),
  20960. Expression.Constant(t8, typeof(TArg8)),
  20961. Expression.Constant(t9, typeof(TArg9)),
  20962. Expression.Constant(t10, typeof(TArg10)),
  20963. Expression.Constant(t11, typeof(TArg11)),
  20964. Expression.Constant(t12, typeof(TArg12)),
  20965. Expression.Constant(t13, typeof(TArg13)),
  20966. Expression.Constant(t14, typeof(TArg14)),
  20967. Expression.Constant(t15, typeof(TArg15)),
  20968. Expression.Constant(t16, typeof(TArg16))
  20969. )
  20970. );
  20971. }
  20972. #endif
  20973. /// <summary>
  20974. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20975. /// </summary>
  20976. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20977. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20978. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20979. /// <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>
  20980. /// <exception cref="T:System.ArgumentNullException">
  20981. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20982. /// <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>
  20983. #if PREFERASYNC
  20984. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20985. #endif
  20986. public static Func<IQbservable<Unit>> FromAsyncPattern(this IQbservableProvider provider, Expression<Func<AsyncCallback, object, IAsyncResult>> begin, Expression<Action<IAsyncResult>>end)
  20987. {
  20988. if (provider == null)
  20989. throw new ArgumentNullException("provider");
  20990. if (begin == null)
  20991. throw new ArgumentNullException("begin");
  20992. if (end == null)
  20993. throw new ArgumentNullException("end");
  20994. #if CRIPPLED_REFLECTION
  20995. var m = InfoOf(() => Qbservable.FromAsyncPattern(default(IQbservableProvider), default(Expression<Func<AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  20996. #else
  20997. var m = (MethodInfo)MethodInfo.GetCurrentMethod();
  20998. #endif
  20999. return () => provider.CreateQuery<Unit>(
  21000. Expression.Invoke(
  21001. Expression.Call(
  21002. null,
  21003. m,
  21004. Expression.Constant(provider, typeof(IQbservableProvider)),
  21005. begin,
  21006. end
  21007. )
  21008. )
  21009. );
  21010. }
  21011. /// <summary>
  21012. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21013. /// </summary>
  21014. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21015. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21016. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21017. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21018. /// <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>
  21019. /// <exception cref="T:System.ArgumentNullException">
  21020. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21021. /// <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>
  21022. #if PREFERASYNC
  21023. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21024. #endif
  21025. public static Func<TArg1, IQbservable<Unit>> FromAsyncPattern<TArg1>(this IQbservableProvider provider, Expression<Func<TArg1, AsyncCallback, object, IAsyncResult>> begin, Expression<Action<IAsyncResult>>end)
  21026. {
  21027. if (provider == null)
  21028. throw new ArgumentNullException("provider");
  21029. if (begin == null)
  21030. throw new ArgumentNullException("begin");
  21031. if (end == null)
  21032. throw new ArgumentNullException("end");
  21033. #if CRIPPLED_REFLECTION
  21034. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1>(default(IQbservableProvider), default(Expression<Func<TArg1, AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  21035. #else
  21036. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1));
  21037. #endif
  21038. return (t1) => provider.CreateQuery<Unit>(
  21039. Expression.Invoke(
  21040. Expression.Call(
  21041. null,
  21042. m,
  21043. Expression.Constant(provider, typeof(IQbservableProvider)),
  21044. begin,
  21045. end
  21046. ),
  21047. Expression.Constant(t1, typeof(TArg1))
  21048. )
  21049. );
  21050. }
  21051. /// <summary>
  21052. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21053. /// </summary>
  21054. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21055. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21056. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21057. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21058. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21059. /// <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>
  21060. /// <exception cref="T:System.ArgumentNullException">
  21061. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21062. /// <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>
  21063. #if PREFERASYNC
  21064. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21065. #endif
  21066. 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)
  21067. {
  21068. if (provider == null)
  21069. throw new ArgumentNullException("provider");
  21070. if (begin == null)
  21071. throw new ArgumentNullException("begin");
  21072. if (end == null)
  21073. throw new ArgumentNullException("end");
  21074. #if CRIPPLED_REFLECTION
  21075. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  21076. #else
  21077. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2));
  21078. #endif
  21079. return (t1, t2) => provider.CreateQuery<Unit>(
  21080. Expression.Invoke(
  21081. Expression.Call(
  21082. null,
  21083. m,
  21084. Expression.Constant(provider, typeof(IQbservableProvider)),
  21085. begin,
  21086. end
  21087. ),
  21088. Expression.Constant(t1, typeof(TArg1)),
  21089. Expression.Constant(t2, typeof(TArg2))
  21090. )
  21091. );
  21092. }
  21093. #if !NO_LARGEARITY
  21094. /// <summary>
  21095. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21096. /// </summary>
  21097. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21098. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21099. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21100. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21101. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21102. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21103. /// <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>
  21104. /// <exception cref="T:System.ArgumentNullException">
  21105. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21106. /// <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>
  21107. #if PREFERASYNC
  21108. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21109. #endif
  21110. 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)
  21111. {
  21112. if (provider == null)
  21113. throw new ArgumentNullException("provider");
  21114. if (begin == null)
  21115. throw new ArgumentNullException("begin");
  21116. if (end == null)
  21117. throw new ArgumentNullException("end");
  21118. #if CRIPPLED_REFLECTION
  21119. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TArg3>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  21120. #else
  21121. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3));
  21122. #endif
  21123. return (t1, t2, t3) => provider.CreateQuery<Unit>(
  21124. Expression.Invoke(
  21125. Expression.Call(
  21126. null,
  21127. m,
  21128. Expression.Constant(provider, typeof(IQbservableProvider)),
  21129. begin,
  21130. end
  21131. ),
  21132. Expression.Constant(t1, typeof(TArg1)),
  21133. Expression.Constant(t2, typeof(TArg2)),
  21134. Expression.Constant(t3, typeof(TArg3))
  21135. )
  21136. );
  21137. }
  21138. /// <summary>
  21139. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21140. /// </summary>
  21141. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21142. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21143. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21144. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21145. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21146. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21147. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21148. /// <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>
  21149. /// <exception cref="T:System.ArgumentNullException">
  21150. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21151. /// <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>
  21152. #if PREFERASYNC
  21153. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21154. #endif
  21155. 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)
  21156. {
  21157. if (provider == null)
  21158. throw new ArgumentNullException("provider");
  21159. if (begin == null)
  21160. throw new ArgumentNullException("begin");
  21161. if (end == null)
  21162. throw new ArgumentNullException("end");
  21163. #if CRIPPLED_REFLECTION
  21164. 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>>)));
  21165. #else
  21166. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4));
  21167. #endif
  21168. return (t1, t2, t3, t4) => provider.CreateQuery<Unit>(
  21169. Expression.Invoke(
  21170. Expression.Call(
  21171. null,
  21172. m,
  21173. Expression.Constant(provider, typeof(IQbservableProvider)),
  21174. begin,
  21175. end
  21176. ),
  21177. Expression.Constant(t1, typeof(TArg1)),
  21178. Expression.Constant(t2, typeof(TArg2)),
  21179. Expression.Constant(t3, typeof(TArg3)),
  21180. Expression.Constant(t4, typeof(TArg4))
  21181. )
  21182. );
  21183. }
  21184. /// <summary>
  21185. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21186. /// </summary>
  21187. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21188. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21189. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21190. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21191. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21192. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21193. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21194. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21195. /// <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>
  21196. /// <exception cref="T:System.ArgumentNullException">
  21197. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21198. /// <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>
  21199. #if PREFERASYNC
  21200. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21201. #endif
  21202. 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)
  21203. {
  21204. if (provider == null)
  21205. throw new ArgumentNullException("provider");
  21206. if (begin == null)
  21207. throw new ArgumentNullException("begin");
  21208. if (end == null)
  21209. throw new ArgumentNullException("end");
  21210. #if CRIPPLED_REFLECTION
  21211. 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>>)));
  21212. #else
  21213. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5));
  21214. #endif
  21215. return (t1, t2, t3, t4, t5) => provider.CreateQuery<Unit>(
  21216. Expression.Invoke(
  21217. Expression.Call(
  21218. null,
  21219. m,
  21220. Expression.Constant(provider, typeof(IQbservableProvider)),
  21221. begin,
  21222. end
  21223. ),
  21224. Expression.Constant(t1, typeof(TArg1)),
  21225. Expression.Constant(t2, typeof(TArg2)),
  21226. Expression.Constant(t3, typeof(TArg3)),
  21227. Expression.Constant(t4, typeof(TArg4)),
  21228. Expression.Constant(t5, typeof(TArg5))
  21229. )
  21230. );
  21231. }
  21232. /// <summary>
  21233. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21234. /// </summary>
  21235. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21236. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21237. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21238. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21239. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21240. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21241. /// <typeparam name="TArg6">The type of the sixth 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, 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)
  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, TArg4, TArg5, TArg6>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  21261. #else
  21262. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6));
  21263. #endif
  21264. return (t1, t2, t3, t4, t5, t6) => 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. Expression.Constant(t4, typeof(TArg4)),
  21277. Expression.Constant(t5, typeof(TArg5)),
  21278. Expression.Constant(t6, typeof(TArg6))
  21279. )
  21280. );
  21281. }
  21282. /// <summary>
  21283. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21284. /// </summary>
  21285. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21286. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21287. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21288. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21289. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21290. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21291. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21292. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21293. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21294. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21295. /// <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>
  21296. /// <exception cref="T:System.ArgumentNullException">
  21297. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21298. /// <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>
  21299. #if PREFERASYNC
  21300. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21301. #endif
  21302. 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)
  21303. {
  21304. if (provider == null)
  21305. throw new ArgumentNullException("provider");
  21306. if (begin == null)
  21307. throw new ArgumentNullException("begin");
  21308. if (end == null)
  21309. throw new ArgumentNullException("end");
  21310. #if CRIPPLED_REFLECTION
  21311. 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>>)));
  21312. #else
  21313. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7));
  21314. #endif
  21315. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<Unit>(
  21316. Expression.Invoke(
  21317. Expression.Call(
  21318. null,
  21319. m,
  21320. Expression.Constant(provider, typeof(IQbservableProvider)),
  21321. begin,
  21322. end
  21323. ),
  21324. Expression.Constant(t1, typeof(TArg1)),
  21325. Expression.Constant(t2, typeof(TArg2)),
  21326. Expression.Constant(t3, typeof(TArg3)),
  21327. Expression.Constant(t4, typeof(TArg4)),
  21328. Expression.Constant(t5, typeof(TArg5)),
  21329. Expression.Constant(t6, typeof(TArg6)),
  21330. Expression.Constant(t7, typeof(TArg7))
  21331. )
  21332. );
  21333. }
  21334. /// <summary>
  21335. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21336. /// </summary>
  21337. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21338. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21339. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21340. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21341. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21342. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21343. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21344. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21345. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21346. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21347. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21348. /// <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>
  21349. /// <exception cref="T:System.ArgumentNullException">
  21350. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21351. /// <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>
  21352. #if PREFERASYNC
  21353. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21354. #endif
  21355. 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)
  21356. {
  21357. if (provider == null)
  21358. throw new ArgumentNullException("provider");
  21359. if (begin == null)
  21360. throw new ArgumentNullException("begin");
  21361. if (end == null)
  21362. throw new ArgumentNullException("end");
  21363. #if CRIPPLED_REFLECTION
  21364. 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>>)));
  21365. #else
  21366. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8));
  21367. #endif
  21368. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<Unit>(
  21369. Expression.Invoke(
  21370. Expression.Call(
  21371. null,
  21372. m,
  21373. Expression.Constant(provider, typeof(IQbservableProvider)),
  21374. begin,
  21375. end
  21376. ),
  21377. Expression.Constant(t1, typeof(TArg1)),
  21378. Expression.Constant(t2, typeof(TArg2)),
  21379. Expression.Constant(t3, typeof(TArg3)),
  21380. Expression.Constant(t4, typeof(TArg4)),
  21381. Expression.Constant(t5, typeof(TArg5)),
  21382. Expression.Constant(t6, typeof(TArg6)),
  21383. Expression.Constant(t7, typeof(TArg7)),
  21384. Expression.Constant(t8, typeof(TArg8))
  21385. )
  21386. );
  21387. }
  21388. /// <summary>
  21389. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21390. /// </summary>
  21391. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21392. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21393. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21394. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21395. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21396. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21397. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21398. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21399. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21400. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21401. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21402. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21403. /// <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>
  21404. /// <exception cref="T:System.ArgumentNullException">
  21405. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21406. /// <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>
  21407. #if PREFERASYNC
  21408. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21409. #endif
  21410. 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)
  21411. {
  21412. if (provider == null)
  21413. throw new ArgumentNullException("provider");
  21414. if (begin == null)
  21415. throw new ArgumentNullException("begin");
  21416. if (end == null)
  21417. throw new ArgumentNullException("end");
  21418. #if CRIPPLED_REFLECTION
  21419. 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>>)));
  21420. #else
  21421. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9));
  21422. #endif
  21423. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<Unit>(
  21424. Expression.Invoke(
  21425. Expression.Call(
  21426. null,
  21427. m,
  21428. Expression.Constant(provider, typeof(IQbservableProvider)),
  21429. begin,
  21430. end
  21431. ),
  21432. Expression.Constant(t1, typeof(TArg1)),
  21433. Expression.Constant(t2, typeof(TArg2)),
  21434. Expression.Constant(t3, typeof(TArg3)),
  21435. Expression.Constant(t4, typeof(TArg4)),
  21436. Expression.Constant(t5, typeof(TArg5)),
  21437. Expression.Constant(t6, typeof(TArg6)),
  21438. Expression.Constant(t7, typeof(TArg7)),
  21439. Expression.Constant(t8, typeof(TArg8)),
  21440. Expression.Constant(t9, typeof(TArg9))
  21441. )
  21442. );
  21443. }
  21444. /// <summary>
  21445. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21446. /// </summary>
  21447. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21448. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21449. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21450. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21451. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21452. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21453. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21454. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21455. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21456. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21457. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21458. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21459. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21460. /// <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>
  21461. /// <exception cref="T:System.ArgumentNullException">
  21462. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21463. /// <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>
  21464. #if PREFERASYNC
  21465. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21466. #endif
  21467. 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)
  21468. {
  21469. if (provider == null)
  21470. throw new ArgumentNullException("provider");
  21471. if (begin == null)
  21472. throw new ArgumentNullException("begin");
  21473. if (end == null)
  21474. throw new ArgumentNullException("end");
  21475. #if CRIPPLED_REFLECTION
  21476. 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>>)));
  21477. #else
  21478. 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));
  21479. #endif
  21480. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<Unit>(
  21481. Expression.Invoke(
  21482. Expression.Call(
  21483. null,
  21484. m,
  21485. Expression.Constant(provider, typeof(IQbservableProvider)),
  21486. begin,
  21487. end
  21488. ),
  21489. Expression.Constant(t1, typeof(TArg1)),
  21490. Expression.Constant(t2, typeof(TArg2)),
  21491. Expression.Constant(t3, typeof(TArg3)),
  21492. Expression.Constant(t4, typeof(TArg4)),
  21493. Expression.Constant(t5, typeof(TArg5)),
  21494. Expression.Constant(t6, typeof(TArg6)),
  21495. Expression.Constant(t7, typeof(TArg7)),
  21496. Expression.Constant(t8, typeof(TArg8)),
  21497. Expression.Constant(t9, typeof(TArg9)),
  21498. Expression.Constant(t10, typeof(TArg10))
  21499. )
  21500. );
  21501. }
  21502. /// <summary>
  21503. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21504. /// </summary>
  21505. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21506. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21507. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21508. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21509. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21510. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21511. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21512. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21513. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21514. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21515. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21516. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  21517. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21518. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21519. /// <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>
  21520. /// <exception cref="T:System.ArgumentNullException">
  21521. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21522. /// <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>
  21523. #if PREFERASYNC
  21524. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21525. #endif
  21526. 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)
  21527. {
  21528. if (provider == null)
  21529. throw new ArgumentNullException("provider");
  21530. if (begin == null)
  21531. throw new ArgumentNullException("begin");
  21532. if (end == null)
  21533. throw new ArgumentNullException("end");
  21534. #if CRIPPLED_REFLECTION
  21535. 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>>)));
  21536. #else
  21537. 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));
  21538. #endif
  21539. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<Unit>(
  21540. Expression.Invoke(
  21541. Expression.Call(
  21542. null,
  21543. m,
  21544. Expression.Constant(provider, typeof(IQbservableProvider)),
  21545. begin,
  21546. end
  21547. ),
  21548. Expression.Constant(t1, typeof(TArg1)),
  21549. Expression.Constant(t2, typeof(TArg2)),
  21550. Expression.Constant(t3, typeof(TArg3)),
  21551. Expression.Constant(t4, typeof(TArg4)),
  21552. Expression.Constant(t5, typeof(TArg5)),
  21553. Expression.Constant(t6, typeof(TArg6)),
  21554. Expression.Constant(t7, typeof(TArg7)),
  21555. Expression.Constant(t8, typeof(TArg8)),
  21556. Expression.Constant(t9, typeof(TArg9)),
  21557. Expression.Constant(t10, typeof(TArg10)),
  21558. Expression.Constant(t11, typeof(TArg11))
  21559. )
  21560. );
  21561. }
  21562. /// <summary>
  21563. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21564. /// </summary>
  21565. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21566. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21567. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21568. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21569. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21570. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21571. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21572. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21573. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21574. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21575. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21576. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  21577. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  21578. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21579. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21580. /// <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>
  21581. /// <exception cref="T:System.ArgumentNullException">
  21582. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21583. /// <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>
  21584. #if PREFERASYNC
  21585. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21586. #endif
  21587. 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)
  21588. {
  21589. if (provider == null)
  21590. throw new ArgumentNullException("provider");
  21591. if (begin == null)
  21592. throw new ArgumentNullException("begin");
  21593. if (end == null)
  21594. throw new ArgumentNullException("end");
  21595. #if CRIPPLED_REFLECTION
  21596. 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>>)));
  21597. #else
  21598. 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));
  21599. #endif
  21600. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<Unit>(
  21601. Expression.Invoke(
  21602. Expression.Call(
  21603. null,
  21604. m,
  21605. Expression.Constant(provider, typeof(IQbservableProvider)),
  21606. begin,
  21607. end
  21608. ),
  21609. Expression.Constant(t1, typeof(TArg1)),
  21610. Expression.Constant(t2, typeof(TArg2)),
  21611. Expression.Constant(t3, typeof(TArg3)),
  21612. Expression.Constant(t4, typeof(TArg4)),
  21613. Expression.Constant(t5, typeof(TArg5)),
  21614. Expression.Constant(t6, typeof(TArg6)),
  21615. Expression.Constant(t7, typeof(TArg7)),
  21616. Expression.Constant(t8, typeof(TArg8)),
  21617. Expression.Constant(t9, typeof(TArg9)),
  21618. Expression.Constant(t10, typeof(TArg10)),
  21619. Expression.Constant(t11, typeof(TArg11)),
  21620. Expression.Constant(t12, typeof(TArg12))
  21621. )
  21622. );
  21623. }
  21624. /// <summary>
  21625. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21626. /// </summary>
  21627. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21628. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21629. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21630. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21631. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21632. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21633. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21634. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21635. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21636. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21637. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21638. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  21639. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  21640. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the begin delegate.</typeparam>
  21641. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21642. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21643. /// <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>
  21644. /// <exception cref="T:System.ArgumentNullException">
  21645. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21646. /// <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>
  21647. #if PREFERASYNC
  21648. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21649. #endif
  21650. 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)
  21651. {
  21652. if (provider == null)
  21653. throw new ArgumentNullException("provider");
  21654. if (begin == null)
  21655. throw new ArgumentNullException("begin");
  21656. if (end == null)
  21657. throw new ArgumentNullException("end");
  21658. #if CRIPPLED_REFLECTION
  21659. 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>>)));
  21660. #else
  21661. 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));
  21662. #endif
  21663. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<Unit>(
  21664. Expression.Invoke(
  21665. Expression.Call(
  21666. null,
  21667. m,
  21668. Expression.Constant(provider, typeof(IQbservableProvider)),
  21669. begin,
  21670. end
  21671. ),
  21672. Expression.Constant(t1, typeof(TArg1)),
  21673. Expression.Constant(t2, typeof(TArg2)),
  21674. Expression.Constant(t3, typeof(TArg3)),
  21675. Expression.Constant(t4, typeof(TArg4)),
  21676. Expression.Constant(t5, typeof(TArg5)),
  21677. Expression.Constant(t6, typeof(TArg6)),
  21678. Expression.Constant(t7, typeof(TArg7)),
  21679. Expression.Constant(t8, typeof(TArg8)),
  21680. Expression.Constant(t9, typeof(TArg9)),
  21681. Expression.Constant(t10, typeof(TArg10)),
  21682. Expression.Constant(t11, typeof(TArg11)),
  21683. Expression.Constant(t12, typeof(TArg12)),
  21684. Expression.Constant(t13, typeof(TArg13))
  21685. )
  21686. );
  21687. }
  21688. /// <summary>
  21689. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21690. /// </summary>
  21691. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21692. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21693. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21694. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21695. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21696. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21697. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21698. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21699. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21700. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21701. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21702. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  21703. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  21704. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the begin delegate.</typeparam>
  21705. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the begin delegate.</typeparam>
  21706. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21707. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21708. /// <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>
  21709. /// <exception cref="T:System.ArgumentNullException">
  21710. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21711. /// <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>
  21712. #if PREFERASYNC
  21713. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21714. #endif
  21715. 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)
  21716. {
  21717. if (provider == null)
  21718. throw new ArgumentNullException("provider");
  21719. if (begin == null)
  21720. throw new ArgumentNullException("begin");
  21721. if (end == null)
  21722. throw new ArgumentNullException("end");
  21723. #if CRIPPLED_REFLECTION
  21724. 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>>)));
  21725. #else
  21726. 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));
  21727. #endif
  21728. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<Unit>(
  21729. Expression.Invoke(
  21730. Expression.Call(
  21731. null,
  21732. m,
  21733. Expression.Constant(provider, typeof(IQbservableProvider)),
  21734. begin,
  21735. end
  21736. ),
  21737. Expression.Constant(t1, typeof(TArg1)),
  21738. Expression.Constant(t2, typeof(TArg2)),
  21739. Expression.Constant(t3, typeof(TArg3)),
  21740. Expression.Constant(t4, typeof(TArg4)),
  21741. Expression.Constant(t5, typeof(TArg5)),
  21742. Expression.Constant(t6, typeof(TArg6)),
  21743. Expression.Constant(t7, typeof(TArg7)),
  21744. Expression.Constant(t8, typeof(TArg8)),
  21745. Expression.Constant(t9, typeof(TArg9)),
  21746. Expression.Constant(t10, typeof(TArg10)),
  21747. Expression.Constant(t11, typeof(TArg11)),
  21748. Expression.Constant(t12, typeof(TArg12)),
  21749. Expression.Constant(t13, typeof(TArg13)),
  21750. Expression.Constant(t14, typeof(TArg14))
  21751. )
  21752. );
  21753. }
  21754. #endif
  21755. /// <summary>
  21756. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21757. /// </summary>
  21758. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21759. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21760. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21761. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21762. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21763. /// <exception cref="T:System.ArgumentNullException">
  21764. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21765. /// <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>
  21766. #if PREFERASYNC
  21767. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21768. #endif
  21769. public static Func<IQbservable<TResult>> FromAsyncPattern<TResult>(this IQbservableProvider provider, Expression<Func<AsyncCallback, object, IAsyncResult>> begin, Expression<Func<IAsyncResult, TResult>>end)
  21770. {
  21771. if (provider == null)
  21772. throw new ArgumentNullException("provider");
  21773. if (begin == null)
  21774. throw new ArgumentNullException("begin");
  21775. if (end == null)
  21776. throw new ArgumentNullException("end");
  21777. #if CRIPPLED_REFLECTION
  21778. var m = InfoOf(() => Qbservable.FromAsyncPattern<TResult>(default(IQbservableProvider), default(Expression<Func<AsyncCallback, object, IAsyncResult>>), default(Expression<Func<IAsyncResult, TResult>>)));
  21779. #else
  21780. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult));
  21781. #endif
  21782. return () => provider.CreateQuery<TResult>(
  21783. Expression.Invoke(
  21784. Expression.Call(
  21785. null,
  21786. m,
  21787. Expression.Constant(provider, typeof(IQbservableProvider)),
  21788. begin,
  21789. end
  21790. )
  21791. )
  21792. );
  21793. }
  21794. /// <summary>
  21795. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21796. /// </summary>
  21797. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21798. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21799. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21800. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21801. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21802. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21803. /// <exception cref="T:System.ArgumentNullException">
  21804. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21805. /// <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>
  21806. #if PREFERASYNC
  21807. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21808. #endif
  21809. public static Func<TArg1, IQbservable<TResult>> FromAsyncPattern<TArg1, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, AsyncCallback, object, IAsyncResult>> begin, Expression<Func<IAsyncResult, TResult>>end)
  21810. {
  21811. if (provider == null)
  21812. throw new ArgumentNullException("provider");
  21813. if (begin == null)
  21814. throw new ArgumentNullException("begin");
  21815. if (end == null)
  21816. throw new ArgumentNullException("end");
  21817. #if CRIPPLED_REFLECTION
  21818. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, AsyncCallback, object, IAsyncResult>>), default(Expression<Func<IAsyncResult, TResult>>)));
  21819. #else
  21820. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TResult));
  21821. #endif
  21822. return (t1) => provider.CreateQuery<TResult>(
  21823. Expression.Invoke(
  21824. Expression.Call(
  21825. null,
  21826. m,
  21827. Expression.Constant(provider, typeof(IQbservableProvider)),
  21828. begin,
  21829. end
  21830. ),
  21831. Expression.Constant(t1, typeof(TArg1))
  21832. )
  21833. );
  21834. }
  21835. /// <summary>
  21836. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21837. /// </summary>
  21838. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21839. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21840. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21841. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21842. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21843. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21844. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21845. /// <exception cref="T:System.ArgumentNullException">
  21846. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21847. /// <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>
  21848. #if PREFERASYNC
  21849. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21850. #endif
  21851. 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)
  21852. {
  21853. if (provider == null)
  21854. throw new ArgumentNullException("provider");
  21855. if (begin == null)
  21856. throw new ArgumentNullException("begin");
  21857. if (end == null)
  21858. throw new ArgumentNullException("end");
  21859. #if CRIPPLED_REFLECTION
  21860. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, AsyncCallback, object, IAsyncResult>>), default(Expression<Func<IAsyncResult, TResult>>)));
  21861. #else
  21862. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TResult));
  21863. #endif
  21864. return (t1, t2) => provider.CreateQuery<TResult>(
  21865. Expression.Invoke(
  21866. Expression.Call(
  21867. null,
  21868. m,
  21869. Expression.Constant(provider, typeof(IQbservableProvider)),
  21870. begin,
  21871. end
  21872. ),
  21873. Expression.Constant(t1, typeof(TArg1)),
  21874. Expression.Constant(t2, typeof(TArg2))
  21875. )
  21876. );
  21877. }
  21878. #if !NO_LARGEARITY
  21879. /// <summary>
  21880. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21881. /// </summary>
  21882. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21883. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21884. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21885. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21886. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21887. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21888. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21889. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21890. /// <exception cref="T:System.ArgumentNullException">
  21891. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21892. /// <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>
  21893. #if PREFERASYNC
  21894. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21895. #endif
  21896. 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)
  21897. {
  21898. if (provider == null)
  21899. throw new ArgumentNullException("provider");
  21900. if (begin == null)
  21901. throw new ArgumentNullException("begin");
  21902. if (end == null)
  21903. throw new ArgumentNullException("end");
  21904. #if CRIPPLED_REFLECTION
  21905. 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>>)));
  21906. #else
  21907. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TResult));
  21908. #endif
  21909. return (t1, t2, t3) => provider.CreateQuery<TResult>(
  21910. Expression.Invoke(
  21911. Expression.Call(
  21912. null,
  21913. m,
  21914. Expression.Constant(provider, typeof(IQbservableProvider)),
  21915. begin,
  21916. end
  21917. ),
  21918. Expression.Constant(t1, typeof(TArg1)),
  21919. Expression.Constant(t2, typeof(TArg2)),
  21920. Expression.Constant(t3, typeof(TArg3))
  21921. )
  21922. );
  21923. }
  21924. /// <summary>
  21925. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21926. /// </summary>
  21927. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21928. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21929. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21930. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21931. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21932. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21933. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21934. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21935. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21936. /// <exception cref="T:System.ArgumentNullException">
  21937. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21938. /// <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>
  21939. #if PREFERASYNC
  21940. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21941. #endif
  21942. 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)
  21943. {
  21944. if (provider == null)
  21945. throw new ArgumentNullException("provider");
  21946. if (begin == null)
  21947. throw new ArgumentNullException("begin");
  21948. if (end == null)
  21949. throw new ArgumentNullException("end");
  21950. #if CRIPPLED_REFLECTION
  21951. 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>>)));
  21952. #else
  21953. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TResult));
  21954. #endif
  21955. return (t1, t2, t3, t4) => provider.CreateQuery<TResult>(
  21956. Expression.Invoke(
  21957. Expression.Call(
  21958. null,
  21959. m,
  21960. Expression.Constant(provider, typeof(IQbservableProvider)),
  21961. begin,
  21962. end
  21963. ),
  21964. Expression.Constant(t1, typeof(TArg1)),
  21965. Expression.Constant(t2, typeof(TArg2)),
  21966. Expression.Constant(t3, typeof(TArg3)),
  21967. Expression.Constant(t4, typeof(TArg4))
  21968. )
  21969. );
  21970. }
  21971. /// <summary>
  21972. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21973. /// </summary>
  21974. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21975. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21976. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21977. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21978. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21979. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21980. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21981. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21982. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21983. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21984. /// <exception cref="T:System.ArgumentNullException">
  21985. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21986. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  21987. #if PREFERASYNC
  21988. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21989. #endif
  21990. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, 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)
  21991. {
  21992. if (provider == null)
  21993. throw new ArgumentNullException("provider");
  21994. if (begin == null)
  21995. throw new ArgumentNullException("begin");
  21996. if (end == null)
  21997. throw new ArgumentNullException("end");
  21998. #if CRIPPLED_REFLECTION
  21999. 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>>)));
  22000. #else
  22001. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TResult));
  22002. #endif
  22003. return (t1, t2, t3, t4, t5) => provider.CreateQuery<TResult>(
  22004. Expression.Invoke(
  22005. Expression.Call(
  22006. null,
  22007. m,
  22008. Expression.Constant(provider, typeof(IQbservableProvider)),
  22009. begin,
  22010. end
  22011. ),
  22012. Expression.Constant(t1, typeof(TArg1)),
  22013. Expression.Constant(t2, typeof(TArg2)),
  22014. Expression.Constant(t3, typeof(TArg3)),
  22015. Expression.Constant(t4, typeof(TArg4)),
  22016. Expression.Constant(t5, typeof(TArg5))
  22017. )
  22018. );
  22019. }
  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="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22028. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22029. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22030. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22031. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22032. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22033. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22034. /// <exception cref="T:System.ArgumentNullException">
  22035. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22036. /// <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>
  22037. #if PREFERASYNC
  22038. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22039. #endif
  22040. 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)
  22041. {
  22042. if (provider == null)
  22043. throw new ArgumentNullException("provider");
  22044. if (begin == null)
  22045. throw new ArgumentNullException("begin");
  22046. if (end == null)
  22047. throw new ArgumentNullException("end");
  22048. #if CRIPPLED_REFLECTION
  22049. 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>>)));
  22050. #else
  22051. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TResult));
  22052. #endif
  22053. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<TResult>(
  22054. Expression.Invoke(
  22055. Expression.Call(
  22056. null,
  22057. m,
  22058. Expression.Constant(provider, typeof(IQbservableProvider)),
  22059. begin,
  22060. end
  22061. ),
  22062. Expression.Constant(t1, typeof(TArg1)),
  22063. Expression.Constant(t2, typeof(TArg2)),
  22064. Expression.Constant(t3, typeof(TArg3)),
  22065. Expression.Constant(t4, typeof(TArg4)),
  22066. Expression.Constant(t5, typeof(TArg5)),
  22067. Expression.Constant(t6, typeof(TArg6))
  22068. )
  22069. );
  22070. }
  22071. /// <summary>
  22072. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22073. /// </summary>
  22074. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  22075. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22076. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22077. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22078. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22079. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22080. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22081. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  22082. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22083. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22084. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22085. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22086. /// <exception cref="T:System.ArgumentNullException">
  22087. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22088. /// <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>
  22089. #if PREFERASYNC
  22090. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22091. #endif
  22092. 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)
  22093. {
  22094. if (provider == null)
  22095. throw new ArgumentNullException("provider");
  22096. if (begin == null)
  22097. throw new ArgumentNullException("begin");
  22098. if (end == null)
  22099. throw new ArgumentNullException("end");
  22100. #if CRIPPLED_REFLECTION
  22101. 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>>)));
  22102. #else
  22103. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TResult));
  22104. #endif
  22105. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<TResult>(
  22106. Expression.Invoke(
  22107. Expression.Call(
  22108. null,
  22109. m,
  22110. Expression.Constant(provider, typeof(IQbservableProvider)),
  22111. begin,
  22112. end
  22113. ),
  22114. Expression.Constant(t1, typeof(TArg1)),
  22115. Expression.Constant(t2, typeof(TArg2)),
  22116. Expression.Constant(t3, typeof(TArg3)),
  22117. Expression.Constant(t4, typeof(TArg4)),
  22118. Expression.Constant(t5, typeof(TArg5)),
  22119. Expression.Constant(t6, typeof(TArg6)),
  22120. Expression.Constant(t7, typeof(TArg7))
  22121. )
  22122. );
  22123. }
  22124. /// <summary>
  22125. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22126. /// </summary>
  22127. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  22128. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22129. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22130. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22131. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22132. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22133. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22134. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  22135. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  22136. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22137. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22138. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22139. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22140. /// <exception cref="T:System.ArgumentNullException">
  22141. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22142. /// <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>
  22143. #if PREFERASYNC
  22144. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22145. #endif
  22146. 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)
  22147. {
  22148. if (provider == null)
  22149. throw new ArgumentNullException("provider");
  22150. if (begin == null)
  22151. throw new ArgumentNullException("begin");
  22152. if (end == null)
  22153. throw new ArgumentNullException("end");
  22154. #if CRIPPLED_REFLECTION
  22155. 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>>)));
  22156. #else
  22157. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TResult));
  22158. #endif
  22159. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<TResult>(
  22160. Expression.Invoke(
  22161. Expression.Call(
  22162. null,
  22163. m,
  22164. Expression.Constant(provider, typeof(IQbservableProvider)),
  22165. begin,
  22166. end
  22167. ),
  22168. Expression.Constant(t1, typeof(TArg1)),
  22169. Expression.Constant(t2, typeof(TArg2)),
  22170. Expression.Constant(t3, typeof(TArg3)),
  22171. Expression.Constant(t4, typeof(TArg4)),
  22172. Expression.Constant(t5, typeof(TArg5)),
  22173. Expression.Constant(t6, typeof(TArg6)),
  22174. Expression.Constant(t7, typeof(TArg7)),
  22175. Expression.Constant(t8, typeof(TArg8))
  22176. )
  22177. );
  22178. }
  22179. /// <summary>
  22180. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22181. /// </summary>
  22182. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  22183. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22184. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22185. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22186. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22187. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22188. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22189. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  22190. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  22191. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  22192. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22193. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22194. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22195. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22196. /// <exception cref="T:System.ArgumentNullException">
  22197. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22198. /// <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>
  22199. #if PREFERASYNC
  22200. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22201. #endif
  22202. 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)
  22203. {
  22204. if (provider == null)
  22205. throw new ArgumentNullException("provider");
  22206. if (begin == null)
  22207. throw new ArgumentNullException("begin");
  22208. if (end == null)
  22209. throw new ArgumentNullException("end");
  22210. #if CRIPPLED_REFLECTION
  22211. 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>>)));
  22212. #else
  22213. 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));
  22214. #endif
  22215. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<TResult>(
  22216. Expression.Invoke(
  22217. Expression.Call(
  22218. null,
  22219. m,
  22220. Expression.Constant(provider, typeof(IQbservableProvider)),
  22221. begin,
  22222. end
  22223. ),
  22224. Expression.Constant(t1, typeof(TArg1)),
  22225. Expression.Constant(t2, typeof(TArg2)),
  22226. Expression.Constant(t3, typeof(TArg3)),
  22227. Expression.Constant(t4, typeof(TArg4)),
  22228. Expression.Constant(t5, typeof(TArg5)),
  22229. Expression.Constant(t6, typeof(TArg6)),
  22230. Expression.Constant(t7, typeof(TArg7)),
  22231. Expression.Constant(t8, typeof(TArg8)),
  22232. Expression.Constant(t9, typeof(TArg9))
  22233. )
  22234. );
  22235. }
  22236. /// <summary>
  22237. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22238. /// </summary>
  22239. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  22240. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22241. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22242. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22243. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22244. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22245. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22246. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  22247. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  22248. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  22249. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  22250. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22251. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22252. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22253. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22254. /// <exception cref="T:System.ArgumentNullException">
  22255. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22256. /// <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>
  22257. #if PREFERASYNC
  22258. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22259. #endif
  22260. 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)
  22261. {
  22262. if (provider == null)
  22263. throw new ArgumentNullException("provider");
  22264. if (begin == null)
  22265. throw new ArgumentNullException("begin");
  22266. if (end == null)
  22267. throw new ArgumentNullException("end");
  22268. #if CRIPPLED_REFLECTION
  22269. 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>>)));
  22270. #else
  22271. 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));
  22272. #endif
  22273. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<TResult>(
  22274. Expression.Invoke(
  22275. Expression.Call(
  22276. null,
  22277. m,
  22278. Expression.Constant(provider, typeof(IQbservableProvider)),
  22279. begin,
  22280. end
  22281. ),
  22282. Expression.Constant(t1, typeof(TArg1)),
  22283. Expression.Constant(t2, typeof(TArg2)),
  22284. Expression.Constant(t3, typeof(TArg3)),
  22285. Expression.Constant(t4, typeof(TArg4)),
  22286. Expression.Constant(t5, typeof(TArg5)),
  22287. Expression.Constant(t6, typeof(TArg6)),
  22288. Expression.Constant(t7, typeof(TArg7)),
  22289. Expression.Constant(t8, typeof(TArg8)),
  22290. Expression.Constant(t9, typeof(TArg9)),
  22291. Expression.Constant(t10, typeof(TArg10))
  22292. )
  22293. );
  22294. }
  22295. /// <summary>
  22296. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22297. /// </summary>
  22298. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  22299. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22300. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22301. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22302. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22303. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22304. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22305. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  22306. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  22307. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  22308. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  22309. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  22310. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22311. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22312. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22313. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22314. /// <exception cref="T:System.ArgumentNullException">
  22315. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22316. /// <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>
  22317. #if PREFERASYNC
  22318. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22319. #endif
  22320. 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)
  22321. {
  22322. if (provider == null)
  22323. throw new ArgumentNullException("provider");
  22324. if (begin == null)
  22325. throw new ArgumentNullException("begin");
  22326. if (end == null)
  22327. throw new ArgumentNullException("end");
  22328. #if CRIPPLED_REFLECTION
  22329. 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>>)));
  22330. #else
  22331. 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));
  22332. #endif
  22333. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<TResult>(
  22334. Expression.Invoke(
  22335. Expression.Call(
  22336. null,
  22337. m,
  22338. Expression.Constant(provider, typeof(IQbservableProvider)),
  22339. begin,
  22340. end
  22341. ),
  22342. Expression.Constant(t1, typeof(TArg1)),
  22343. Expression.Constant(t2, typeof(TArg2)),
  22344. Expression.Constant(t3, typeof(TArg3)),
  22345. Expression.Constant(t4, typeof(TArg4)),
  22346. Expression.Constant(t5, typeof(TArg5)),
  22347. Expression.Constant(t6, typeof(TArg6)),
  22348. Expression.Constant(t7, typeof(TArg7)),
  22349. Expression.Constant(t8, typeof(TArg8)),
  22350. Expression.Constant(t9, typeof(TArg9)),
  22351. Expression.Constant(t10, typeof(TArg10)),
  22352. Expression.Constant(t11, typeof(TArg11))
  22353. )
  22354. );
  22355. }
  22356. /// <summary>
  22357. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22358. /// </summary>
  22359. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  22360. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22361. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22362. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22363. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22364. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22365. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22366. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  22367. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  22368. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  22369. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  22370. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  22371. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  22372. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22373. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22374. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22375. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22376. /// <exception cref="T:System.ArgumentNullException">
  22377. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22378. /// <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>
  22379. #if PREFERASYNC
  22380. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22381. #endif
  22382. 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)
  22383. {
  22384. if (provider == null)
  22385. throw new ArgumentNullException("provider");
  22386. if (begin == null)
  22387. throw new ArgumentNullException("begin");
  22388. if (end == null)
  22389. throw new ArgumentNullException("end");
  22390. #if CRIPPLED_REFLECTION
  22391. 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>>)));
  22392. #else
  22393. 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));
  22394. #endif
  22395. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<TResult>(
  22396. Expression.Invoke(
  22397. Expression.Call(
  22398. null,
  22399. m,
  22400. Expression.Constant(provider, typeof(IQbservableProvider)),
  22401. begin,
  22402. end
  22403. ),
  22404. Expression.Constant(t1, typeof(TArg1)),
  22405. Expression.Constant(t2, typeof(TArg2)),
  22406. Expression.Constant(t3, typeof(TArg3)),
  22407. Expression.Constant(t4, typeof(TArg4)),
  22408. Expression.Constant(t5, typeof(TArg5)),
  22409. Expression.Constant(t6, typeof(TArg6)),
  22410. Expression.Constant(t7, typeof(TArg7)),
  22411. Expression.Constant(t8, typeof(TArg8)),
  22412. Expression.Constant(t9, typeof(TArg9)),
  22413. Expression.Constant(t10, typeof(TArg10)),
  22414. Expression.Constant(t11, typeof(TArg11)),
  22415. Expression.Constant(t12, typeof(TArg12))
  22416. )
  22417. );
  22418. }
  22419. /// <summary>
  22420. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22421. /// </summary>
  22422. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  22423. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22424. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22425. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22426. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22427. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22428. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22429. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  22430. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  22431. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  22432. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  22433. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  22434. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  22435. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the begin delegate.</typeparam>
  22436. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22437. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22438. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22439. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22440. /// <exception cref="T:System.ArgumentNullException">
  22441. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22442. /// <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>
  22443. #if PREFERASYNC
  22444. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22445. #endif
  22446. 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)
  22447. {
  22448. if (provider == null)
  22449. throw new ArgumentNullException("provider");
  22450. if (begin == null)
  22451. throw new ArgumentNullException("begin");
  22452. if (end == null)
  22453. throw new ArgumentNullException("end");
  22454. #if CRIPPLED_REFLECTION
  22455. 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>>)));
  22456. #else
  22457. 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));
  22458. #endif
  22459. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<TResult>(
  22460. Expression.Invoke(
  22461. Expression.Call(
  22462. null,
  22463. m,
  22464. Expression.Constant(provider, typeof(IQbservableProvider)),
  22465. begin,
  22466. end
  22467. ),
  22468. Expression.Constant(t1, typeof(TArg1)),
  22469. Expression.Constant(t2, typeof(TArg2)),
  22470. Expression.Constant(t3, typeof(TArg3)),
  22471. Expression.Constant(t4, typeof(TArg4)),
  22472. Expression.Constant(t5, typeof(TArg5)),
  22473. Expression.Constant(t6, typeof(TArg6)),
  22474. Expression.Constant(t7, typeof(TArg7)),
  22475. Expression.Constant(t8, typeof(TArg8)),
  22476. Expression.Constant(t9, typeof(TArg9)),
  22477. Expression.Constant(t10, typeof(TArg10)),
  22478. Expression.Constant(t11, typeof(TArg11)),
  22479. Expression.Constant(t12, typeof(TArg12)),
  22480. Expression.Constant(t13, typeof(TArg13))
  22481. )
  22482. );
  22483. }
  22484. /// <summary>
  22485. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22486. /// </summary>
  22487. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  22488. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22489. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22490. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22491. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22492. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22493. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22494. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  22495. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  22496. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  22497. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  22498. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  22499. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  22500. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the begin delegate.</typeparam>
  22501. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the begin delegate.</typeparam>
  22502. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22503. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22504. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22505. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22506. /// <exception cref="T:System.ArgumentNullException">
  22507. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22508. /// <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>
  22509. #if PREFERASYNC
  22510. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22511. #endif
  22512. 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)
  22513. {
  22514. if (provider == null)
  22515. throw new ArgumentNullException("provider");
  22516. if (begin == null)
  22517. throw new ArgumentNullException("begin");
  22518. if (end == null)
  22519. throw new ArgumentNullException("end");
  22520. #if CRIPPLED_REFLECTION
  22521. 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>>)));
  22522. #else
  22523. 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));
  22524. #endif
  22525. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<TResult>(
  22526. Expression.Invoke(
  22527. Expression.Call(
  22528. null,
  22529. m,
  22530. Expression.Constant(provider, typeof(IQbservableProvider)),
  22531. begin,
  22532. end
  22533. ),
  22534. Expression.Constant(t1, typeof(TArg1)),
  22535. Expression.Constant(t2, typeof(TArg2)),
  22536. Expression.Constant(t3, typeof(TArg3)),
  22537. Expression.Constant(t4, typeof(TArg4)),
  22538. Expression.Constant(t5, typeof(TArg5)),
  22539. Expression.Constant(t6, typeof(TArg6)),
  22540. Expression.Constant(t7, typeof(TArg7)),
  22541. Expression.Constant(t8, typeof(TArg8)),
  22542. Expression.Constant(t9, typeof(TArg9)),
  22543. Expression.Constant(t10, typeof(TArg10)),
  22544. Expression.Constant(t11, typeof(TArg11)),
  22545. Expression.Constant(t12, typeof(TArg12)),
  22546. Expression.Constant(t13, typeof(TArg13)),
  22547. Expression.Constant(t14, typeof(TArg14))
  22548. )
  22549. );
  22550. }
  22551. #endif
  22552. }
  22553. }
  22554. #endif
  22555. #pragma warning restore 1591