1
0

Qbservable.Generated.cs 1.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355
  1. /*
  2. * WARNING: Auto-generated file (11/21/2013 11:07:25 AM)
  3. * Run Rx's auto-homoiconizer tool to generate this file (in the HomoIcon directory).
  4. */
  5. #pragma warning disable 1591
  6. #if !NO_EXPRESSIONS
  7. using System;
  8. using System.Reactive.Concurrency;
  9. using System.Collections.Generic;
  10. using System.Reactive.Joins;
  11. using System.Linq;
  12. using System.Linq.Expressions;
  13. using System.Reflection;
  14. using System.Threading;
  15. using System.Reactive;
  16. using System.Reactive.Subjects;
  17. #if !NO_TPL
  18. using System.Threading.Tasks;
  19. #endif
  20. #if !NO_REMOTING
  21. using System.Runtime.Remoting.Lifetime;
  22. #endif
  23. namespace System.Reactive.Linq
  24. {
  25. public static partial class Qbservable
  26. {
  27. /// <summary>
  28. /// Applies an accumulator function over an observable sequence, returning the result of the aggregation as a single element in the result sequence.
  29. /// For aggregation behavior with incremental intermediate results, see <see cref="M:System.Reactive.Linq.Observable.Scan``1(System.IObservable{``0},System.Func{``0,``0,``0})" />.
  30. /// </summary>
  31. /// <typeparam name="TSource">The type of the elements in the source sequence and the result of the aggregation.</typeparam>
  32. /// <param name="source">An observable sequence to aggregate over.</param>
  33. /// <param name="accumulator">An accumulator function to be invoked on each element.</param>
  34. /// <returns>An observable sequence containing a single element with the final accumulator value.</returns>
  35. /// <exception cref="T:System.ArgumentNullException">
  36. /// <paramref name="source" /> or <paramref name="accumulator" /> is null.</exception>
  37. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  38. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  39. public static IQbservable<TSource> Aggregate<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, TSource, TSource>> accumulator)
  40. {
  41. if (source == null)
  42. throw new ArgumentNullException("source");
  43. if (accumulator == null)
  44. throw new ArgumentNullException("accumulator");
  45. return source.Provider.CreateQuery<TSource>(
  46. Expression.Call(
  47. null,
  48. #if CRIPPLED_REFLECTION
  49. InfoOf(() => Qbservable.Aggregate<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, TSource, TSource>>))),
  50. #else
  51. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  52. #endif
  53. source.Expression,
  54. accumulator
  55. )
  56. );
  57. }
  58. /// <summary>
  59. /// Applies an accumulator function over an observable sequence, returning the result of the aggregation as a single element in the result sequence. The specified seed value is used as the initial accumulator value.
  60. /// For aggregation behavior with incremental intermediate results, see <see cref="M:System.Reactive.Linq.Observable.Scan``2(System.IObservable{``0},``1,System.Func{``1,``0,``1})" />.
  61. /// </summary>
  62. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  63. /// <typeparam name="TAccumulate">The type of the result of the aggregation.</typeparam>
  64. /// <param name="source">An observable sequence to aggregate over.</param>
  65. /// <param name="seed">The initial accumulator value.</param>
  66. /// <param name="accumulator">An accumulator function to be invoked on each element.</param>
  67. /// <returns>An observable sequence containing a single element with the final accumulator value.</returns>
  68. /// <exception cref="T:System.ArgumentNullException">
  69. /// <paramref name="source" /> or <paramref name="accumulator" /> is null.</exception>
  70. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  71. public static IQbservable<TAccumulate> Aggregate<TSource, TAccumulate>(this IQbservable<TSource> source, TAccumulate seed, Expression<Func<TAccumulate, TSource, TAccumulate>> accumulator)
  72. {
  73. if (source == null)
  74. throw new ArgumentNullException("source");
  75. if (accumulator == null)
  76. throw new ArgumentNullException("accumulator");
  77. return source.Provider.CreateQuery<TAccumulate>(
  78. Expression.Call(
  79. null,
  80. #if CRIPPLED_REFLECTION
  81. InfoOf(() => Qbservable.Aggregate<TSource, TAccumulate>(default(IQbservable<TSource>), default(TAccumulate), default(Expression<Func<TAccumulate, TSource, TAccumulate>>))),
  82. #else
  83. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)),
  84. #endif
  85. source.Expression,
  86. Expression.Constant(seed, typeof(TAccumulate)),
  87. accumulator
  88. )
  89. );
  90. }
  91. /// <summary>
  92. /// Applies an accumulator function over an observable sequence, returning the result of the aggregation as a single element in the result sequence. The specified seed value is used as the initial accumulator value,
  93. /// and the specified result selector function is used to select the result value.
  94. /// </summary>
  95. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  96. /// <typeparam name="TAccumulate">The type of the accumulator value.</typeparam>
  97. /// <typeparam name="TResult">The type of the resulting value.</typeparam>
  98. /// <param name="source">An observable sequence to aggregate over.</param>
  99. /// <param name="seed">The initial accumulator value.</param>
  100. /// <param name="accumulator">An accumulator function to be invoked on each element.</param>
  101. /// <param name="resultSelector">A function to transform the final accumulator value into the result value.</param>
  102. /// <returns>An observable sequence containing a single element with the final accumulator value.</returns>
  103. /// <exception cref="T:System.ArgumentNullException">
  104. /// <paramref name="source" /> or <paramref name="accumulator" /> or <paramref name="resultSelector" /> is null.</exception>
  105. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  106. public static IQbservable<TResult> Aggregate<TSource, TAccumulate, TResult>(this IQbservable<TSource> source, TAccumulate seed, Expression<Func<TAccumulate, TSource, TAccumulate>> accumulator, Expression<Func<TAccumulate, TResult>> resultSelector)
  107. {
  108. if (source == null)
  109. throw new ArgumentNullException("source");
  110. if (accumulator == null)
  111. throw new ArgumentNullException("accumulator");
  112. if (resultSelector == null)
  113. throw new ArgumentNullException("resultSelector");
  114. return source.Provider.CreateQuery<TResult>(
  115. Expression.Call(
  116. null,
  117. #if CRIPPLED_REFLECTION
  118. InfoOf(() => Qbservable.Aggregate<TSource, TAccumulate, TResult>(default(IQbservable<TSource>), default(TAccumulate), default(Expression<Func<TAccumulate, TSource, TAccumulate>>), default(Expression<Func<TAccumulate, TResult>>))),
  119. #else
  120. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate), typeof(TResult)),
  121. #endif
  122. source.Expression,
  123. Expression.Constant(seed, typeof(TAccumulate)),
  124. accumulator,
  125. resultSelector
  126. )
  127. );
  128. }
  129. /// <summary>
  130. /// Determines whether all elements of an observable sequence satisfy a condition.
  131. /// </summary>
  132. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  133. /// <param name="source">An observable sequence whose elements to apply the predicate to.</param>
  134. /// <param name="predicate">A function to test each element for a condition.</param>
  135. /// <returns>An observable sequence containing a single element determining whether all elements in the source sequence pass the test in the specified predicate.</returns>
  136. /// <exception cref="T:System.ArgumentNullException">
  137. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  138. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  139. public static IQbservable<bool> All<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  140. {
  141. if (source == null)
  142. throw new ArgumentNullException("source");
  143. if (predicate == null)
  144. throw new ArgumentNullException("predicate");
  145. return source.Provider.CreateQuery<bool>(
  146. Expression.Call(
  147. null,
  148. #if CRIPPLED_REFLECTION
  149. InfoOf(() => Qbservable.All<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  150. #else
  151. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  152. #endif
  153. source.Expression,
  154. predicate
  155. )
  156. );
  157. }
  158. /// <summary>
  159. /// Propagates the observable sequence that reacts first.
  160. /// </summary>
  161. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  162. /// <param name="first">First observable sequence.</param>
  163. /// <param name="second">Second observable sequence.</param>
  164. /// <returns>An observable sequence that surfaces either of the given sequences, whichever reacted first.</returns>
  165. /// <exception cref="T:System.ArgumentNullException">
  166. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  167. public static IQbservable<TSource> Amb<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  168. {
  169. if (first == null)
  170. throw new ArgumentNullException("first");
  171. if (second == null)
  172. throw new ArgumentNullException("second");
  173. return first.Provider.CreateQuery<TSource>(
  174. Expression.Call(
  175. null,
  176. #if CRIPPLED_REFLECTION
  177. InfoOf(() => Qbservable.Amb<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  178. #else
  179. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  180. #endif
  181. first.Expression,
  182. GetSourceExpression(second)
  183. )
  184. );
  185. }
  186. /// <summary>
  187. /// Propagates the observable sequence that reacts first.
  188. /// </summary>
  189. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  190. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  191. /// <param name="sources">Observable sources competing to react first.</param>
  192. /// <returns>An observable sequence that surfaces any of the given sequences, whichever reacted first.</returns>
  193. /// <exception cref="T:System.ArgumentNullException">
  194. /// <paramref name="sources" /> is null.</exception>
  195. public static IQbservable<TSource> Amb<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  196. {
  197. if (provider == null)
  198. throw new ArgumentNullException("provider");
  199. if (sources == null)
  200. throw new ArgumentNullException("sources");
  201. return provider.CreateQuery<TSource>(
  202. Expression.Call(
  203. null,
  204. #if CRIPPLED_REFLECTION
  205. InfoOf(() => Qbservable.Amb<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  206. #else
  207. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  208. #endif
  209. Expression.Constant(provider, typeof(IQbservableProvider)),
  210. GetSourceExpression(sources)
  211. )
  212. );
  213. }
  214. /// <summary>
  215. /// Propagates the observable sequence that reacts first.
  216. /// </summary>
  217. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  218. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  219. /// <param name="sources">Observable sources competing to react first.</param>
  220. /// <returns>An observable sequence that surfaces any of the given sequences, whichever reacted first.</returns>
  221. /// <exception cref="T:System.ArgumentNullException">
  222. /// <paramref name="sources" /> is null.</exception>
  223. public static IQbservable<TSource> Amb<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  224. {
  225. if (provider == null)
  226. throw new ArgumentNullException("provider");
  227. if (sources == null)
  228. throw new ArgumentNullException("sources");
  229. return provider.CreateQuery<TSource>(
  230. Expression.Call(
  231. null,
  232. #if CRIPPLED_REFLECTION
  233. InfoOf(() => Qbservable.Amb<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  234. #else
  235. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  236. #endif
  237. Expression.Constant(provider, typeof(IQbservableProvider)),
  238. GetSourceExpression(sources)
  239. )
  240. );
  241. }
  242. /// <summary>
  243. /// Determines whether an observable sequence contains any elements.
  244. /// </summary>
  245. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  246. /// <param name="source">An observable sequence to check for non-emptiness.</param>
  247. /// <returns>An observable sequence containing a single element determining whether the source sequence contains any elements.</returns>
  248. /// <exception cref="T:System.ArgumentNullException">
  249. /// <paramref name="source" /> is null.</exception>
  250. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  251. public static IQbservable<bool> Any<TSource>(this IQbservable<TSource> source)
  252. {
  253. if (source == null)
  254. throw new ArgumentNullException("source");
  255. return source.Provider.CreateQuery<bool>(
  256. Expression.Call(
  257. null,
  258. #if CRIPPLED_REFLECTION
  259. InfoOf(() => Qbservable.Any<TSource>(default(IQbservable<TSource>))),
  260. #else
  261. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  262. #endif
  263. source.Expression
  264. )
  265. );
  266. }
  267. /// <summary>
  268. /// Determines whether any element of an observable sequence satisfies a condition.
  269. /// </summary>
  270. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  271. /// <param name="source">An observable sequence whose elements to apply the predicate to.</param>
  272. /// <param name="predicate">A function to test each element for a condition.</param>
  273. /// <returns>An observable sequence containing a single element determining whether any elements in the source sequence pass the test in the specified predicate.</returns>
  274. /// <exception cref="T:System.ArgumentNullException">
  275. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  276. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  277. public static IQbservable<bool> Any<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  278. {
  279. if (source == null)
  280. throw new ArgumentNullException("source");
  281. if (predicate == null)
  282. throw new ArgumentNullException("predicate");
  283. return source.Provider.CreateQuery<bool>(
  284. Expression.Call(
  285. null,
  286. #if CRIPPLED_REFLECTION
  287. InfoOf(() => Qbservable.Any<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  288. #else
  289. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  290. #endif
  291. source.Expression,
  292. predicate
  293. )
  294. );
  295. }
  296. /// <summary>
  297. /// Computes the average of an observable sequence of <see cref="T:System.Decimal" /> values.
  298. /// </summary>
  299. /// <param name="source">A sequence of <see cref="T:System.Decimal" /> values to calculate the average of.</param>
  300. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  301. /// <exception cref="T:System.ArgumentNullException">
  302. /// <paramref name="source" /> is null.</exception>
  303. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  304. /// <exception cref="T:System.OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="M:System.Decimal.MaxValue" />.</exception>
  305. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  306. public static IQbservable<decimal> Average(this IQbservable<decimal> source)
  307. {
  308. if (source == null)
  309. throw new ArgumentNullException("source");
  310. return source.Provider.CreateQuery<decimal>(
  311. Expression.Call(
  312. null,
  313. #if CRIPPLED_REFLECTION
  314. InfoOf(() => Qbservable.Average(default(IQbservable<decimal>))),
  315. #else
  316. (MethodInfo)MethodInfo.GetCurrentMethod(),
  317. #endif
  318. source.Expression
  319. )
  320. );
  321. }
  322. /// <summary>
  323. /// Computes the average of an observable sequence of <see cref="T:System.Double" /> values.
  324. /// </summary>
  325. /// <param name="source">A sequence of <see cref="T:System.Double" /> values to calculate the average of.</param>
  326. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  327. /// <exception cref="T:System.ArgumentNullException">
  328. /// <paramref name="source" /> is null.</exception>
  329. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  330. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  331. public static IQbservable<double> Average(this IQbservable<double> source)
  332. {
  333. if (source == null)
  334. throw new ArgumentNullException("source");
  335. return source.Provider.CreateQuery<double>(
  336. Expression.Call(
  337. null,
  338. #if CRIPPLED_REFLECTION
  339. InfoOf(() => Qbservable.Average(default(IQbservable<double>))),
  340. #else
  341. (MethodInfo)MethodInfo.GetCurrentMethod(),
  342. #endif
  343. source.Expression
  344. )
  345. );
  346. }
  347. /// <summary>
  348. /// Computes the average of an observable sequence of <see cref="T:System.Int32" /> values.
  349. /// </summary>
  350. /// <param name="source">A sequence of <see cref="T:System.Int32" /> values to calculate the average of.</param>
  351. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  352. /// <exception cref="T:System.ArgumentNullException">
  353. /// <paramref name="source" /> is null.</exception>
  354. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  355. /// <exception cref="T:System.OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue" />.</exception>
  356. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  357. public static IQbservable<double> Average(this IQbservable<int> source)
  358. {
  359. if (source == null)
  360. throw new ArgumentNullException("source");
  361. return source.Provider.CreateQuery<double>(
  362. Expression.Call(
  363. null,
  364. #if CRIPPLED_REFLECTION
  365. InfoOf(() => Qbservable.Average(default(IQbservable<int>))),
  366. #else
  367. (MethodInfo)MethodInfo.GetCurrentMethod(),
  368. #endif
  369. source.Expression
  370. )
  371. );
  372. }
  373. /// <summary>
  374. /// Computes the average of an observable sequence of <see cref="T:System.Int64" /> values.
  375. /// </summary>
  376. /// <param name="source">A sequence of <see cref="T:System.Int64" /> values to calculate the average of.</param>
  377. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  378. /// <exception cref="T:System.ArgumentNullException">
  379. /// <paramref name="source" /> is null.</exception>
  380. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  381. /// <exception cref="T:System.OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue" />.</exception>
  382. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  383. public static IQbservable<double> Average(this IQbservable<long> source)
  384. {
  385. if (source == null)
  386. throw new ArgumentNullException("source");
  387. return source.Provider.CreateQuery<double>(
  388. Expression.Call(
  389. null,
  390. #if CRIPPLED_REFLECTION
  391. InfoOf(() => Qbservable.Average(default(IQbservable<long>))),
  392. #else
  393. (MethodInfo)MethodInfo.GetCurrentMethod(),
  394. #endif
  395. source.Expression
  396. )
  397. );
  398. }
  399. /// <summary>
  400. /// Computes the average of an observable sequence of nullable <see cref="T:System.Decimal" /> values.
  401. /// </summary>
  402. /// <param name="source">A sequence of nullable <see cref="T:System.Decimal" /> values to calculate the average of.</param>
  403. /// <returns>An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
  404. /// <exception cref="T:System.ArgumentNullException">
  405. /// <paramref name="source" /> is null.</exception>
  406. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  407. /// <exception cref="T:System.OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="M:System.Decimal.MaxValue" />.</exception>
  408. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  409. public static IQbservable<decimal?> Average(this IQbservable<decimal?> source)
  410. {
  411. if (source == null)
  412. throw new ArgumentNullException("source");
  413. return source.Provider.CreateQuery<decimal?>(
  414. Expression.Call(
  415. null,
  416. #if CRIPPLED_REFLECTION
  417. InfoOf(() => Qbservable.Average(default(IQbservable<decimal?>))),
  418. #else
  419. (MethodInfo)MethodInfo.GetCurrentMethod(),
  420. #endif
  421. source.Expression
  422. )
  423. );
  424. }
  425. /// <summary>
  426. /// Computes the average of an observable sequence of nullable <see cref="T:System.Double" /> values.
  427. /// </summary>
  428. /// <param name="source">A sequence of nullable <see cref="T:System.Double" /> values to calculate the average of.</param>
  429. /// <returns>An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
  430. /// <exception cref="T:System.ArgumentNullException">
  431. /// <paramref name="source" /> is null.</exception>
  432. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  433. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  434. public static IQbservable<double?> Average(this IQbservable<double?> source)
  435. {
  436. if (source == null)
  437. throw new ArgumentNullException("source");
  438. return source.Provider.CreateQuery<double?>(
  439. Expression.Call(
  440. null,
  441. #if CRIPPLED_REFLECTION
  442. InfoOf(() => Qbservable.Average(default(IQbservable<double?>))),
  443. #else
  444. (MethodInfo)MethodInfo.GetCurrentMethod(),
  445. #endif
  446. source.Expression
  447. )
  448. );
  449. }
  450. /// <summary>
  451. /// Computes the average of an observable sequence of nullable <see cref="T:System.Int32" /> values.
  452. /// </summary>
  453. /// <param name="source">A sequence of nullable <see cref="T:System.Int32" /> values to calculate the average of.</param>
  454. /// <returns>An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
  455. /// <exception cref="T:System.ArgumentNullException">
  456. /// <paramref name="source" /> is null.</exception>
  457. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  458. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  459. /// <exception cref="T:System.OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue" />.</exception>
  460. public static IQbservable<double?> Average(this IQbservable<int?> source)
  461. {
  462. if (source == null)
  463. throw new ArgumentNullException("source");
  464. return source.Provider.CreateQuery<double?>(
  465. Expression.Call(
  466. null,
  467. #if CRIPPLED_REFLECTION
  468. InfoOf(() => Qbservable.Average(default(IQbservable<int?>))),
  469. #else
  470. (MethodInfo)MethodInfo.GetCurrentMethod(),
  471. #endif
  472. source.Expression
  473. )
  474. );
  475. }
  476. /// <summary>
  477. /// Computes the average of an observable sequence of nullable <see cref="T:System.Int64" /> values.
  478. /// </summary>
  479. /// <param name="source">A sequence of nullable <see cref="T:System.Int64" /> values to calculate the average of.</param>
  480. /// <returns>An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
  481. /// <exception cref="T:System.ArgumentNullException">
  482. /// <paramref name="source" /> is null.</exception>
  483. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  484. /// <exception cref="T:System.OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue" />.</exception>
  485. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  486. public static IQbservable<double?> Average(this IQbservable<long?> source)
  487. {
  488. if (source == null)
  489. throw new ArgumentNullException("source");
  490. return source.Provider.CreateQuery<double?>(
  491. Expression.Call(
  492. null,
  493. #if CRIPPLED_REFLECTION
  494. InfoOf(() => Qbservable.Average(default(IQbservable<long?>))),
  495. #else
  496. (MethodInfo)MethodInfo.GetCurrentMethod(),
  497. #endif
  498. source.Expression
  499. )
  500. );
  501. }
  502. /// <summary>
  503. /// Computes the average of an observable sequence of nullable <see cref="T:System.Single" /> values.
  504. /// </summary>
  505. /// <param name="source">A sequence of nullable <see cref="T:System.Single" /> values to calculate the average of.</param>
  506. /// <returns>An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
  507. /// <exception cref="T:System.ArgumentNullException">
  508. /// <paramref name="source" /> is null.</exception>
  509. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  510. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  511. public static IQbservable<float?> Average(this IQbservable<float?> source)
  512. {
  513. if (source == null)
  514. throw new ArgumentNullException("source");
  515. return source.Provider.CreateQuery<float?>(
  516. Expression.Call(
  517. null,
  518. #if CRIPPLED_REFLECTION
  519. InfoOf(() => Qbservable.Average(default(IQbservable<float?>))),
  520. #else
  521. (MethodInfo)MethodInfo.GetCurrentMethod(),
  522. #endif
  523. source.Expression
  524. )
  525. );
  526. }
  527. /// <summary>
  528. /// Computes the average of an observable sequence of <see cref="T:System.Single" /> values.
  529. /// </summary>
  530. /// <param name="source">A sequence of <see cref="T:System.Single" /> values to calculate the average of.</param>
  531. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  532. /// <exception cref="T:System.ArgumentNullException">
  533. /// <paramref name="source" /> is null.</exception>
  534. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  535. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  536. public static IQbservable<float> Average(this IQbservable<float> source)
  537. {
  538. if (source == null)
  539. throw new ArgumentNullException("source");
  540. return source.Provider.CreateQuery<float>(
  541. Expression.Call(
  542. null,
  543. #if CRIPPLED_REFLECTION
  544. InfoOf(() => Qbservable.Average(default(IQbservable<float>))),
  545. #else
  546. (MethodInfo)MethodInfo.GetCurrentMethod(),
  547. #endif
  548. source.Expression
  549. )
  550. );
  551. }
  552. /// <summary>
  553. /// Computes the average of an observable sequence of <see cref="T:System.Decimal" /> values that are obtained by invoking a transform function on each element of the input sequence.
  554. /// </summary>
  555. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  556. /// <param name="source">A sequence of values to calculate the average of.</param>
  557. /// <param name="selector">A transform function to apply to each element.</param>
  558. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  559. /// <exception cref="T:System.ArgumentNullException">
  560. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  561. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  562. /// <exception cref="T:System.OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="M:System.Decimal.MaxValue" />.</exception>
  563. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  564. public static IQbservable<decimal> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal>> selector)
  565. {
  566. if (source == null)
  567. throw new ArgumentNullException("source");
  568. if (selector == null)
  569. throw new ArgumentNullException("selector");
  570. return source.Provider.CreateQuery<decimal>(
  571. Expression.Call(
  572. null,
  573. #if CRIPPLED_REFLECTION
  574. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal>>))),
  575. #else
  576. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  577. #endif
  578. source.Expression,
  579. selector
  580. )
  581. );
  582. }
  583. /// <summary>
  584. /// Computes the average of an observable sequence of <see cref="T:System.Double" /> values that are obtained by invoking a transform function on each element of the input sequence.
  585. /// </summary>
  586. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  587. /// <param name="source">A sequence of values to calculate the average of.</param>
  588. /// <param name="selector">A transform function to apply to each element.</param>
  589. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  590. /// <exception cref="T:System.ArgumentNullException">
  591. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  592. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  593. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  594. public static IQbservable<double> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double>> selector)
  595. {
  596. if (source == null)
  597. throw new ArgumentNullException("source");
  598. if (selector == null)
  599. throw new ArgumentNullException("selector");
  600. return source.Provider.CreateQuery<double>(
  601. Expression.Call(
  602. null,
  603. #if CRIPPLED_REFLECTION
  604. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double>>))),
  605. #else
  606. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  607. #endif
  608. source.Expression,
  609. selector
  610. )
  611. );
  612. }
  613. /// <summary>
  614. /// Computes the average of an observable sequence of <see cref="T:System.Single" /> values that are obtained by invoking a transform function on each element of the input sequence.
  615. /// </summary>
  616. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  617. /// <param name="source">A sequence of values to calculate the average of.</param>
  618. /// <param name="selector">A transform function to apply to each element.</param>
  619. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  620. /// <exception cref="T:System.ArgumentNullException">
  621. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  622. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  623. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  624. public static IQbservable<float> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float>> selector)
  625. {
  626. if (source == null)
  627. throw new ArgumentNullException("source");
  628. if (selector == null)
  629. throw new ArgumentNullException("selector");
  630. return source.Provider.CreateQuery<float>(
  631. Expression.Call(
  632. null,
  633. #if CRIPPLED_REFLECTION
  634. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float>>))),
  635. #else
  636. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  637. #endif
  638. source.Expression,
  639. selector
  640. )
  641. );
  642. }
  643. /// <summary>
  644. /// Computes the average of an observable sequence of <see cref="T:System.Int32" /> values that are obtained by invoking a transform function on each element of the input sequence.
  645. /// </summary>
  646. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  647. /// <param name="source">A sequence of values to calculate the average of.</param>
  648. /// <param name="selector">A transform function to apply to each element.</param>
  649. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  650. /// <exception cref="T:System.ArgumentNullException">
  651. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  652. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  653. /// <exception cref="T:System.OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue" />.</exception>
  654. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  655. public static IQbservable<double> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int>> selector)
  656. {
  657. if (source == null)
  658. throw new ArgumentNullException("source");
  659. if (selector == null)
  660. throw new ArgumentNullException("selector");
  661. return source.Provider.CreateQuery<double>(
  662. Expression.Call(
  663. null,
  664. #if CRIPPLED_REFLECTION
  665. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int>>))),
  666. #else
  667. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  668. #endif
  669. source.Expression,
  670. selector
  671. )
  672. );
  673. }
  674. /// <summary>
  675. /// Computes the average of an observable sequence of <see cref="T:System.Int64" /> values that are obtained by invoking a transform function on each element of the input sequence.
  676. /// </summary>
  677. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  678. /// <param name="source">A sequence of values to calculate the average of.</param>
  679. /// <param name="selector">A transform function to apply to each element.</param>
  680. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  681. /// <exception cref="T:System.ArgumentNullException">
  682. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  683. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  684. /// <exception cref="T:System.OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue" />.</exception>
  685. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  686. public static IQbservable<double> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long>> selector)
  687. {
  688. if (source == null)
  689. throw new ArgumentNullException("source");
  690. if (selector == null)
  691. throw new ArgumentNullException("selector");
  692. return source.Provider.CreateQuery<double>(
  693. Expression.Call(
  694. null,
  695. #if CRIPPLED_REFLECTION
  696. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long>>))),
  697. #else
  698. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  699. #endif
  700. source.Expression,
  701. selector
  702. )
  703. );
  704. }
  705. /// <summary>
  706. /// Computes the average of an observable sequence of nullable <see cref="T:System.Decimal" /> values that are obtained by invoking a transform function on each element of the input sequence.
  707. /// </summary>
  708. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  709. /// <param name="source">A sequence of values to calculate the average of.</param>
  710. /// <param name="selector">A transform function to apply to each element.</param>
  711. /// <returns>An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
  712. /// <exception cref="T:System.ArgumentNullException">
  713. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  714. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  715. /// <exception cref="T:System.OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="M:System.Decimal.MaxValue" />.</exception>
  716. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  717. public static IQbservable<decimal?> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal?>> selector)
  718. {
  719. if (source == null)
  720. throw new ArgumentNullException("source");
  721. if (selector == null)
  722. throw new ArgumentNullException("selector");
  723. return source.Provider.CreateQuery<decimal?>(
  724. Expression.Call(
  725. null,
  726. #if CRIPPLED_REFLECTION
  727. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal?>>))),
  728. #else
  729. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  730. #endif
  731. source.Expression,
  732. selector
  733. )
  734. );
  735. }
  736. /// <summary>
  737. /// Computes the average of an observable sequence of nullable <see cref="T:System.Double" /> values that are obtained by invoking a transform function on each element of the input sequence.
  738. /// </summary>
  739. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  740. /// <param name="source">A sequence of values to calculate the average of.</param>
  741. /// <param name="selector">A transform function to apply to each element.</param>
  742. /// <returns>An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
  743. /// <exception cref="T:System.ArgumentNullException">
  744. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  745. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  746. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  747. public static IQbservable<double?> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double?>> selector)
  748. {
  749. if (source == null)
  750. throw new ArgumentNullException("source");
  751. if (selector == null)
  752. throw new ArgumentNullException("selector");
  753. return source.Provider.CreateQuery<double?>(
  754. Expression.Call(
  755. null,
  756. #if CRIPPLED_REFLECTION
  757. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double?>>))),
  758. #else
  759. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  760. #endif
  761. source.Expression,
  762. selector
  763. )
  764. );
  765. }
  766. /// <summary>
  767. /// Computes the average of an observable sequence of nullable <see cref="T:System.Single" /> values that are obtained by invoking a transform function on each element of the input sequence.
  768. /// </summary>
  769. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  770. /// <param name="source">A sequence of values to calculate the average of.</param>
  771. /// <param name="selector">A transform function to apply to each element.</param>
  772. /// <returns>An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
  773. /// <exception cref="T:System.ArgumentNullException">
  774. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  775. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  776. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  777. public static IQbservable<float?> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float?>> selector)
  778. {
  779. if (source == null)
  780. throw new ArgumentNullException("source");
  781. if (selector == null)
  782. throw new ArgumentNullException("selector");
  783. return source.Provider.CreateQuery<float?>(
  784. Expression.Call(
  785. null,
  786. #if CRIPPLED_REFLECTION
  787. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float?>>))),
  788. #else
  789. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  790. #endif
  791. source.Expression,
  792. selector
  793. )
  794. );
  795. }
  796. /// <summary>
  797. /// Computes the average of an observable sequence of nullable <see cref="T:System.Int32" /> values that are obtained by invoking a transform function on each element of the input sequence.
  798. /// </summary>
  799. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  800. /// <param name="source">A sequence of values to calculate the average of.</param>
  801. /// <param name="selector">A transform function to apply to each element.</param>
  802. /// <returns>An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
  803. /// <exception cref="T:System.ArgumentNullException">
  804. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  805. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  806. /// <exception cref="T:System.OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue" />.</exception>
  807. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  808. public static IQbservable<double?> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int?>> selector)
  809. {
  810. if (source == null)
  811. throw new ArgumentNullException("source");
  812. if (selector == null)
  813. throw new ArgumentNullException("selector");
  814. return source.Provider.CreateQuery<double?>(
  815. Expression.Call(
  816. null,
  817. #if CRIPPLED_REFLECTION
  818. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int?>>))),
  819. #else
  820. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  821. #endif
  822. source.Expression,
  823. selector
  824. )
  825. );
  826. }
  827. /// <summary>
  828. /// Computes the average of an observable sequence of nullable <see cref="T:System.Int64" /> values that are obtained by invoking a transform function on each element of the input sequence.
  829. /// </summary>
  830. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  831. /// <param name="source">A sequence of values to calculate the average of.</param>
  832. /// <param name="selector">A transform function to apply to each element.</param>
  833. /// <returns>An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
  834. /// <exception cref="T:System.ArgumentNullException">
  835. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  836. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  837. /// <exception cref="T:System.OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue" />.</exception>
  838. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  839. public static IQbservable<double?> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long?>> selector)
  840. {
  841. if (source == null)
  842. throw new ArgumentNullException("source");
  843. if (selector == null)
  844. throw new ArgumentNullException("selector");
  845. return source.Provider.CreateQuery<double?>(
  846. Expression.Call(
  847. null,
  848. #if CRIPPLED_REFLECTION
  849. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long?>>))),
  850. #else
  851. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  852. #endif
  853. source.Expression,
  854. selector
  855. )
  856. );
  857. }
  858. /// <summary>
  859. /// Projects each element of an observable sequence into consecutive non-overlapping buffers which are produced based on element count information.
  860. /// </summary>
  861. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  862. /// <param name="source">Source sequence to produce buffers over.</param>
  863. /// <param name="count">Length of each buffer.</param>
  864. /// <returns>An observable sequence of buffers.</returns>
  865. /// <exception cref="T:System.ArgumentNullException">
  866. /// <paramref name="source" /> is null.</exception>
  867. /// <exception cref="T:System.ArgumentOutOfRangeException">
  868. /// <paramref name="count" /> is less than or equal to zero.</exception>
  869. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, int count)
  870. {
  871. if (source == null)
  872. throw new ArgumentNullException("source");
  873. return source.Provider.CreateQuery<IList<TSource>>(
  874. Expression.Call(
  875. null,
  876. #if CRIPPLED_REFLECTION
  877. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(int))),
  878. #else
  879. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  880. #endif
  881. source.Expression,
  882. Expression.Constant(count, typeof(int))
  883. )
  884. );
  885. }
  886. /// <summary>
  887. /// Projects each element of an observable sequence into zero or more buffers which are produced based on element count information.
  888. /// </summary>
  889. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  890. /// <param name="source">Source sequence to produce buffers over.</param>
  891. /// <param name="count">Length of each buffer.</param>
  892. /// <param name="skip">Number of elements to skip between creation of consecutive buffers.</param>
  893. /// <returns>An observable sequence of buffers.</returns>
  894. /// <exception cref="T:System.ArgumentNullException">
  895. /// <paramref name="source" /> is null.</exception>
  896. /// <exception cref="T:System.ArgumentOutOfRangeException">
  897. /// <paramref name="count" /> or <paramref name="skip" /> is less than or equal to zero.</exception>
  898. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, int count, int skip)
  899. {
  900. if (source == null)
  901. throw new ArgumentNullException("source");
  902. return source.Provider.CreateQuery<IList<TSource>>(
  903. Expression.Call(
  904. null,
  905. #if CRIPPLED_REFLECTION
  906. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(int), default(int))),
  907. #else
  908. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  909. #endif
  910. source.Expression,
  911. Expression.Constant(count, typeof(int)),
  912. Expression.Constant(skip, typeof(int))
  913. )
  914. );
  915. }
  916. /// <summary>
  917. /// Projects each element of an observable sequence into consecutive non-overlapping buffers which are produced based on timing information.
  918. /// </summary>
  919. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  920. /// <param name="source">Source sequence to produce buffers over.</param>
  921. /// <param name="timeSpan">Length of each buffer.</param>
  922. /// <returns>An observable sequence of buffers.</returns>
  923. /// <exception cref="T:System.ArgumentNullException">
  924. /// <paramref name="source" /> is null.</exception>
  925. /// <exception cref="T:System.ArgumentOutOfRangeException">
  926. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  927. /// <remarks>
  928. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create buffers as fast as it can.
  929. /// Because all source sequence elements end up in one of the buffers, some buffers won't have a zero time span. This is a side-effect of the asynchrony introduced
  930. /// by the scheduler, where the action to close the current buffer and to create a new buffer may not execute immediately, despite the TimeSpan.Zero due time.
  931. /// </remarks>
  932. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan)
  933. {
  934. if (source == null)
  935. throw new ArgumentNullException("source");
  936. return source.Provider.CreateQuery<IList<TSource>>(
  937. Expression.Call(
  938. null,
  939. #if CRIPPLED_REFLECTION
  940. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  941. #else
  942. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  943. #endif
  944. source.Expression,
  945. Expression.Constant(timeSpan, typeof(TimeSpan))
  946. )
  947. );
  948. }
  949. /// <summary>
  950. /// Projects each element of an observable sequence into a buffer that's sent out when either it's full or a given amount of time has elapsed.
  951. /// A useful real-world analogy of this overload is the behavior of a ferry leaving the dock when all seats are taken, or at the scheduled time of departure, whichever event occurs first.
  952. /// </summary>
  953. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  954. /// <param name="source">Source sequence to produce buffers over.</param>
  955. /// <param name="timeSpan">Maximum time length of a window.</param>
  956. /// <param name="count">Maximum element count of a window.</param>
  957. /// <returns>An observable sequence of buffers.</returns>
  958. /// <exception cref="T:System.ArgumentNullException">
  959. /// <paramref name="source" /> is null.</exception>
  960. /// <exception cref="T:System.ArgumentOutOfRangeException">
  961. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero. -or- <paramref name="count" /> is less than or equal to zero.</exception>
  962. /// <remarks>
  963. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create buffers as fast as it can.
  964. /// Because all source sequence elements end up in one of the buffers, some buffers won't have a zero time span. This is a side-effect of the asynchrony introduced
  965. /// by the scheduler, where the action to close the current buffer and to create a new buffer may not execute immediately, despite the TimeSpan.Zero due time.
  966. /// </remarks>
  967. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, int count)
  968. {
  969. if (source == null)
  970. throw new ArgumentNullException("source");
  971. return source.Provider.CreateQuery<IList<TSource>>(
  972. Expression.Call(
  973. null,
  974. #if CRIPPLED_REFLECTION
  975. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(int))),
  976. #else
  977. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  978. #endif
  979. source.Expression,
  980. Expression.Constant(timeSpan, typeof(TimeSpan)),
  981. Expression.Constant(count, typeof(int))
  982. )
  983. );
  984. }
  985. /// <summary>
  986. /// Projects each element of an observable sequence into a buffer that's sent out when either it's full or a given amount of time has elapsed, using the specified scheduler to run timers.
  987. /// A useful real-world analogy of this overload is the behavior of a ferry leaving the dock when all seats are taken, or at the scheduled time of departure, whichever event occurs first.
  988. /// </summary>
  989. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  990. /// <param name="source">Source sequence to produce buffers over.</param>
  991. /// <param name="timeSpan">Maximum time length of a buffer.</param>
  992. /// <param name="count">Maximum element count of a buffer.</param>
  993. /// <param name="scheduler">Scheduler to run buffering timers on.</param>
  994. /// <returns>An observable sequence of buffers.</returns>
  995. /// <exception cref="T:System.ArgumentNullException">
  996. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  997. /// <exception cref="T:System.ArgumentOutOfRangeException">
  998. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero. -or- <paramref name="count" /> is less than or equal to zero.</exception>
  999. /// <remarks>
  1000. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create buffers as fast as it can.
  1001. /// Because all source sequence elements end up in one of the buffers, some buffers won't have a zero time span. This is a side-effect of the asynchrony introduced
  1002. /// by the scheduler, where the action to close the current buffer and to create a new buffer may not execute immediately, despite the TimeSpan.Zero due time.
  1003. /// </remarks>
  1004. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, int count, IScheduler scheduler)
  1005. {
  1006. if (source == null)
  1007. throw new ArgumentNullException("source");
  1008. if (scheduler == null)
  1009. throw new ArgumentNullException("scheduler");
  1010. return source.Provider.CreateQuery<IList<TSource>>(
  1011. Expression.Call(
  1012. null,
  1013. #if CRIPPLED_REFLECTION
  1014. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(int), default(IScheduler))),
  1015. #else
  1016. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1017. #endif
  1018. source.Expression,
  1019. Expression.Constant(timeSpan, typeof(TimeSpan)),
  1020. Expression.Constant(count, typeof(int)),
  1021. Expression.Constant(scheduler, typeof(IScheduler))
  1022. )
  1023. );
  1024. }
  1025. /// <summary>
  1026. /// Projects each element of an observable sequence into consecutive non-overlapping buffers which are produced based on timing information, using the specified scheduler to run timers.
  1027. /// </summary>
  1028. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1029. /// <param name="source">Source sequence to produce buffers over.</param>
  1030. /// <param name="timeSpan">Length of each buffer.</param>
  1031. /// <param name="scheduler">Scheduler to run buffering timers on.</param>
  1032. /// <returns>An observable sequence of buffers.</returns>
  1033. /// <exception cref="T:System.ArgumentNullException">
  1034. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  1035. /// <exception cref="T:System.ArgumentOutOfRangeException">
  1036. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  1037. /// <remarks>
  1038. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create buffers as fast as it can.
  1039. /// Because all source sequence elements end up in one of the buffers, some buffers won't have a zero time span. This is a side-effect of the asynchrony introduced
  1040. /// by the scheduler, where the action to close the current buffer and to create a new buffer may not execute immediately, despite the TimeSpan.Zero due time.
  1041. /// </remarks>
  1042. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, IScheduler scheduler)
  1043. {
  1044. if (source == null)
  1045. throw new ArgumentNullException("source");
  1046. if (scheduler == null)
  1047. throw new ArgumentNullException("scheduler");
  1048. return source.Provider.CreateQuery<IList<TSource>>(
  1049. Expression.Call(
  1050. null,
  1051. #if CRIPPLED_REFLECTION
  1052. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  1053. #else
  1054. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1055. #endif
  1056. source.Expression,
  1057. Expression.Constant(timeSpan, typeof(TimeSpan)),
  1058. Expression.Constant(scheduler, typeof(IScheduler))
  1059. )
  1060. );
  1061. }
  1062. /// <summary>
  1063. /// Projects each element of an observable sequence into zero or more buffers which are produced based on timing information.
  1064. /// </summary>
  1065. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1066. /// <param name="source">Source sequence to produce buffers over.</param>
  1067. /// <param name="timeSpan">Length of each buffer.</param>
  1068. /// <param name="timeShift">Interval between creation of consecutive buffers.</param>
  1069. /// <returns>An observable sequence of buffers.</returns>
  1070. /// <exception cref="T:System.ArgumentNullException">
  1071. /// <paramref name="source" /> is null.</exception>
  1072. /// <exception cref="T:System.ArgumentOutOfRangeException">
  1073. /// <paramref name="timeSpan" /> or <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  1074. /// <remarks>
  1075. /// <para>
  1076. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create buffers with minimum duration
  1077. /// length. However, some buffers won't have a zero time span. This is a side-effect of the asynchrony introduced by the scheduler, where the action to close the
  1078. /// current buffer may not execute immediately, despite the TimeSpan.Zero due time.
  1079. /// </para>
  1080. /// <para>
  1081. /// Specifying a TimeSpan.Zero value for <paramref name="timeShift" /> is not recommended but supported, causing the scheduler to create buffers as fast as it can.
  1082. /// However, this doesn't mean all buffers will start at the beginning of the source sequence. This is a side-effect of the asynchrony introduced by the scheduler,
  1083. /// where the action to create a new buffer may not execute immediately, despite the TimeSpan.Zero due time.
  1084. /// </para>
  1085. /// </remarks>
  1086. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, TimeSpan timeShift)
  1087. {
  1088. if (source == null)
  1089. throw new ArgumentNullException("source");
  1090. return source.Provider.CreateQuery<IList<TSource>>(
  1091. Expression.Call(
  1092. null,
  1093. #if CRIPPLED_REFLECTION
  1094. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(TimeSpan))),
  1095. #else
  1096. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1097. #endif
  1098. source.Expression,
  1099. Expression.Constant(timeSpan, typeof(TimeSpan)),
  1100. Expression.Constant(timeShift, typeof(TimeSpan))
  1101. )
  1102. );
  1103. }
  1104. /// <summary>
  1105. /// Projects each element of an observable sequence into zero or more buffers which are produced based on timing information, using the specified scheduler to run timers.
  1106. /// </summary>
  1107. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1108. /// <param name="source">Source sequence to produce buffers over.</param>
  1109. /// <param name="timeSpan">Length of each buffer.</param>
  1110. /// <param name="timeShift">Interval between creation of consecutive buffers.</param>
  1111. /// <param name="scheduler">Scheduler to run buffering timers on.</param>
  1112. /// <returns>An observable sequence of buffers.</returns>
  1113. /// <exception cref="T:System.ArgumentNullException">
  1114. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  1115. /// <exception cref="T:System.ArgumentOutOfRangeException">
  1116. /// <paramref name="timeSpan" /> or <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  1117. /// <remarks>
  1118. /// <para>
  1119. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create buffers with minimum duration
  1120. /// length. However, some buffers won't have a zero time span. This is a side-effect of the asynchrony introduced by the scheduler, where the action to close the
  1121. /// current buffer may not execute immediately, despite the TimeSpan.Zero due time.
  1122. /// </para>
  1123. /// <para>
  1124. /// Specifying a TimeSpan.Zero value for <paramref name="timeShift" /> is not recommended but supported, causing the scheduler to create buffers as fast as it can.
  1125. /// However, this doesn't mean all buffers will start at the beginning of the source sequence. This is a side-effect of the asynchrony introduced by the scheduler,
  1126. /// where the action to create a new buffer may not execute immediately, despite the TimeSpan.Zero due time.
  1127. /// </para>
  1128. /// </remarks>
  1129. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, TimeSpan timeShift, IScheduler scheduler)
  1130. {
  1131. if (source == null)
  1132. throw new ArgumentNullException("source");
  1133. if (scheduler == null)
  1134. throw new ArgumentNullException("scheduler");
  1135. return source.Provider.CreateQuery<IList<TSource>>(
  1136. Expression.Call(
  1137. null,
  1138. #if CRIPPLED_REFLECTION
  1139. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(TimeSpan), default(IScheduler))),
  1140. #else
  1141. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1142. #endif
  1143. source.Expression,
  1144. Expression.Constant(timeSpan, typeof(TimeSpan)),
  1145. Expression.Constant(timeShift, typeof(TimeSpan)),
  1146. Expression.Constant(scheduler, typeof(IScheduler))
  1147. )
  1148. );
  1149. }
  1150. /// <summary>
  1151. /// Projects each element of an observable sequence into consecutive non-overlapping buffers.
  1152. /// </summary>
  1153. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1154. /// <typeparam name="TBufferBoundary">The type of the elements in the sequences indicating buffer boundary events.</typeparam>
  1155. /// <param name="source">Source sequence to produce buffers over.</param>
  1156. /// <param name="bufferBoundaries">Sequence of buffer boundary markers. The current buffer is closed and a new buffer is opened upon receiving a boundary marker.</param>
  1157. /// <returns>An observable sequence of buffers.</returns>
  1158. /// <exception cref="T:System.ArgumentNullException">
  1159. /// <paramref name="source" /> or <paramref name="bufferBoundaries" /> is null.</exception>
  1160. public static IQbservable<IList<TSource>> Buffer<TSource, TBufferBoundary>(this IQbservable<TSource> source, IObservable<TBufferBoundary> bufferBoundaries)
  1161. {
  1162. if (source == null)
  1163. throw new ArgumentNullException("source");
  1164. if (bufferBoundaries == null)
  1165. throw new ArgumentNullException("bufferBoundaries");
  1166. return source.Provider.CreateQuery<IList<TSource>>(
  1167. Expression.Call(
  1168. null,
  1169. #if CRIPPLED_REFLECTION
  1170. InfoOf(() => Qbservable.Buffer<TSource, TBufferBoundary>(default(IQbservable<TSource>), default(IObservable<TBufferBoundary>))),
  1171. #else
  1172. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TBufferBoundary)),
  1173. #endif
  1174. source.Expression,
  1175. GetSourceExpression(bufferBoundaries)
  1176. )
  1177. );
  1178. }
  1179. /// <summary>
  1180. /// Projects each element of an observable sequence into consecutive non-overlapping buffers.
  1181. /// </summary>
  1182. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1183. /// <typeparam name="TBufferClosing">The type of the elements in the sequences indicating buffer closing events.</typeparam>
  1184. /// <param name="source">Source sequence to produce buffers over.</param>
  1185. /// <param name="bufferClosingSelector">A function invoked to define the boundaries of the produced buffers. A new buffer is started when the previous one is closed.</param>
  1186. /// <returns>An observable sequence of buffers.</returns>
  1187. /// <exception cref="T:System.ArgumentNullException">
  1188. /// <paramref name="source" /> or <paramref name="bufferClosingSelector" /> is null.</exception>
  1189. public static IQbservable<IList<TSource>> Buffer<TSource, TBufferClosing>(this IQbservable<TSource> source, Expression<Func<IObservable<TBufferClosing>>> bufferClosingSelector)
  1190. {
  1191. if (source == null)
  1192. throw new ArgumentNullException("source");
  1193. if (bufferClosingSelector == null)
  1194. throw new ArgumentNullException("bufferClosingSelector");
  1195. return source.Provider.CreateQuery<IList<TSource>>(
  1196. Expression.Call(
  1197. null,
  1198. #if CRIPPLED_REFLECTION
  1199. InfoOf(() => Qbservable.Buffer<TSource, TBufferClosing>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TBufferClosing>>>))),
  1200. #else
  1201. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TBufferClosing)),
  1202. #endif
  1203. source.Expression,
  1204. bufferClosingSelector
  1205. )
  1206. );
  1207. }
  1208. /// <summary>
  1209. /// Projects each element of an observable sequence into zero or more buffers.
  1210. /// </summary>
  1211. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1212. /// <typeparam name="TBufferOpening">The type of the elements in the sequence indicating buffer opening events, also passed to the closing selector to obtain a sequence of buffer closing events.</typeparam>
  1213. /// <typeparam name="TBufferClosing">The type of the elements in the sequences indicating buffer closing events.</typeparam>
  1214. /// <param name="source">Source sequence to produce buffers over.</param>
  1215. /// <param name="bufferOpenings">Observable sequence whose elements denote the creation of new buffers.</param>
  1216. /// <param name="bufferClosingSelector">A function invoked to define the closing of each produced buffer.</param>
  1217. /// <returns>An observable sequence of buffers.</returns>
  1218. /// <exception cref="T:System.ArgumentNullException">
  1219. /// <paramref name="source" /> or <paramref name="bufferOpenings" /> or <paramref name="bufferClosingSelector" /> is null.</exception>
  1220. public static IQbservable<IList<TSource>> Buffer<TSource, TBufferOpening, TBufferClosing>(this IQbservable<TSource> source, IObservable<TBufferOpening> bufferOpenings, Expression<Func<TBufferOpening, IObservable<TBufferClosing>>> bufferClosingSelector)
  1221. {
  1222. if (source == null)
  1223. throw new ArgumentNullException("source");
  1224. if (bufferOpenings == null)
  1225. throw new ArgumentNullException("bufferOpenings");
  1226. if (bufferClosingSelector == null)
  1227. throw new ArgumentNullException("bufferClosingSelector");
  1228. return source.Provider.CreateQuery<IList<TSource>>(
  1229. Expression.Call(
  1230. null,
  1231. #if CRIPPLED_REFLECTION
  1232. InfoOf(() => Qbservable.Buffer<TSource, TBufferOpening, TBufferClosing>(default(IQbservable<TSource>), default(IObservable<TBufferOpening>), default(Expression<Func<TBufferOpening, IObservable<TBufferClosing>>>))),
  1233. #else
  1234. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TBufferOpening), typeof(TBufferClosing)),
  1235. #endif
  1236. source.Expression,
  1237. GetSourceExpression(bufferOpenings),
  1238. bufferClosingSelector
  1239. )
  1240. );
  1241. }
  1242. /// <summary>
  1243. /// Uses <paramref name="selector" /> to determine which source in <paramref name="sources" /> to return, choosing an empty sequence if no match is found.
  1244. /// </summary>
  1245. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  1246. /// <typeparam name="TValue">The type of the value returned by the selector function, used to look up the resulting source.</typeparam>
  1247. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  1248. /// <param name="selector">Selector function invoked to determine the source to lookup in the <paramref name="sources" /> dictionary.</param>
  1249. /// <param name="sources">Dictionary of sources to select from based on the <paramref name="selector" /> invocation result.</param>
  1250. /// <returns>The observable sequence retrieved from the <paramref name="sources" /> dictionary based on the <paramref name="selector" /> invocation result, or an empty sequence if no match is found.</returns>
  1251. /// <exception cref="T:System.ArgumentNullException">
  1252. /// <paramref name="selector" /> or <paramref name="sources" /> is null.</exception>
  1253. public static IQbservable<TResult> Case<TValue, TResult>(this IQbservableProvider provider, Expression<Func<TValue>> selector, IDictionary<TValue, IObservable<TResult>> sources)
  1254. {
  1255. if (provider == null)
  1256. throw new ArgumentNullException("provider");
  1257. if (selector == null)
  1258. throw new ArgumentNullException("selector");
  1259. if (sources == null)
  1260. throw new ArgumentNullException("sources");
  1261. return provider.CreateQuery<TResult>(
  1262. Expression.Call(
  1263. null,
  1264. #if CRIPPLED_REFLECTION
  1265. InfoOf(() => Qbservable.Case<TValue, TResult>(default(IQbservableProvider), default(Expression<Func<TValue>>), default(IDictionary<TValue, IObservable<TResult>>))),
  1266. #else
  1267. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TValue), typeof(TResult)),
  1268. #endif
  1269. Expression.Constant(provider, typeof(IQbservableProvider)),
  1270. selector,
  1271. Expression.Constant(sources, typeof(IDictionary<TValue, IObservable<TResult>>))
  1272. )
  1273. );
  1274. }
  1275. /// <summary>
  1276. /// Uses <paramref name="selector" /> to determine which source in <paramref name="sources" /> to return, choosing <paramref name="defaultSource" /> if no match is found.
  1277. /// </summary>
  1278. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  1279. /// <typeparam name="TValue">The type of the value returned by the selector function, used to look up the resulting source.</typeparam>
  1280. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  1281. /// <param name="selector">Selector function invoked to determine the source to lookup in the <paramref name="sources" /> dictionary.</param>
  1282. /// <param name="sources">Dictionary of sources to select from based on the <paramref name="selector" /> invocation result.</param>
  1283. /// <param name="defaultSource">Default source to select in case no matching source in <paramref name="sources" /> is found.</param>
  1284. /// <returns>The observable sequence retrieved from the <paramref name="sources" /> dictionary based on the <paramref name="selector" /> invocation result, or <paramref name="defaultSource" /> if no match is found.</returns>
  1285. /// <exception cref="T:System.ArgumentNullException">
  1286. /// <paramref name="selector" /> or <paramref name="sources" /> or <paramref name="defaultSource" /> is null.</exception>
  1287. public static IQbservable<TResult> Case<TValue, TResult>(this IQbservableProvider provider, Expression<Func<TValue>> selector, IDictionary<TValue, IObservable<TResult>> sources, IObservable<TResult> defaultSource)
  1288. {
  1289. if (provider == null)
  1290. throw new ArgumentNullException("provider");
  1291. if (selector == null)
  1292. throw new ArgumentNullException("selector");
  1293. if (sources == null)
  1294. throw new ArgumentNullException("sources");
  1295. if (defaultSource == null)
  1296. throw new ArgumentNullException("defaultSource");
  1297. return provider.CreateQuery<TResult>(
  1298. Expression.Call(
  1299. null,
  1300. #if CRIPPLED_REFLECTION
  1301. InfoOf(() => Qbservable.Case<TValue, TResult>(default(IQbservableProvider), default(Expression<Func<TValue>>), default(IDictionary<TValue, IObservable<TResult>>), default(IObservable<TResult>))),
  1302. #else
  1303. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TValue), typeof(TResult)),
  1304. #endif
  1305. Expression.Constant(provider, typeof(IQbservableProvider)),
  1306. selector,
  1307. Expression.Constant(sources, typeof(IDictionary<TValue, IObservable<TResult>>)),
  1308. GetSourceExpression(defaultSource)
  1309. )
  1310. );
  1311. }
  1312. /// <summary>
  1313. /// Uses <paramref name="selector" /> to determine which source in <paramref name="sources" /> to return, choosing an empty sequence on the specified scheduler if no match is found.
  1314. /// </summary>
  1315. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  1316. /// <typeparam name="TValue">The type of the value returned by the selector function, used to look up the resulting source.</typeparam>
  1317. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  1318. /// <param name="selector">Selector function invoked to determine the source to lookup in the <paramref name="sources" /> dictionary.</param>
  1319. /// <param name="sources">Dictionary of sources to select from based on the <paramref name="selector" /> invocation result.</param>
  1320. /// <param name="scheduler">Scheduler to generate an empty sequence on in case no matching source in <paramref name="sources" /> is found.</param>
  1321. /// <returns>The observable sequence retrieved from the <paramref name="sources" /> dictionary based on the <paramref name="selector" /> invocation result, or an empty sequence if no match is found.</returns>
  1322. /// <exception cref="T:System.ArgumentNullException">
  1323. /// <paramref name="selector" /> or <paramref name="sources" /> or <paramref name="scheduler" /> is null.</exception>
  1324. public static IQbservable<TResult> Case<TValue, TResult>(this IQbservableProvider provider, Expression<Func<TValue>> selector, IDictionary<TValue, IObservable<TResult>> sources, IScheduler scheduler)
  1325. {
  1326. if (provider == null)
  1327. throw new ArgumentNullException("provider");
  1328. if (selector == null)
  1329. throw new ArgumentNullException("selector");
  1330. if (sources == null)
  1331. throw new ArgumentNullException("sources");
  1332. if (scheduler == null)
  1333. throw new ArgumentNullException("scheduler");
  1334. return provider.CreateQuery<TResult>(
  1335. Expression.Call(
  1336. null,
  1337. #if CRIPPLED_REFLECTION
  1338. InfoOf(() => Qbservable.Case<TValue, TResult>(default(IQbservableProvider), default(Expression<Func<TValue>>), default(IDictionary<TValue, IObservable<TResult>>), default(IScheduler))),
  1339. #else
  1340. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TValue), typeof(TResult)),
  1341. #endif
  1342. Expression.Constant(provider, typeof(IQbservableProvider)),
  1343. selector,
  1344. Expression.Constant(sources, typeof(IDictionary<TValue, IObservable<TResult>>)),
  1345. Expression.Constant(scheduler, typeof(IScheduler))
  1346. )
  1347. );
  1348. }
  1349. /// <summary>
  1350. /// Converts the elements of an observable sequence to the specified type.
  1351. /// </summary>
  1352. /// <typeparam name="TResult">The type to convert the elements in the source sequence to.</typeparam>
  1353. /// <param name="source">The observable sequence that contains the elements to be converted.</param>
  1354. /// <returns>An observable sequence that contains each element of the source sequence converted to the specified type.</returns>
  1355. /// <exception cref="T:System.ArgumentNullException">
  1356. /// <paramref name="source" /> is null.</exception>
  1357. public static IQbservable<TResult> Cast<TResult>(this IQbservable<object> source)
  1358. {
  1359. if (source == null)
  1360. throw new ArgumentNullException("source");
  1361. return source.Provider.CreateQuery<TResult>(
  1362. Expression.Call(
  1363. null,
  1364. #if CRIPPLED_REFLECTION
  1365. InfoOf(() => Qbservable.Cast<TResult>(default(IQbservable<object>))),
  1366. #else
  1367. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  1368. #endif
  1369. source.Expression
  1370. )
  1371. );
  1372. }
  1373. /// <summary>
  1374. /// Continues an observable sequence that is terminated by an exception with the next observable sequence.
  1375. /// </summary>
  1376. /// <typeparam name="TSource">The type of the elements in the source sequence and handler sequence.</typeparam>
  1377. /// <param name="first">First observable sequence whose exception (if any) is caught.</param>
  1378. /// <param name="second">Second observable sequence used to produce results when an error occurred in the first sequence.</param>
  1379. /// <returns>An observable sequence containing the first sequence's elements, followed by the elements of the second sequence in case an exception occurred.</returns>
  1380. /// <exception cref="T:System.ArgumentNullException">
  1381. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  1382. public static IQbservable<TSource> Catch<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  1383. {
  1384. if (first == null)
  1385. throw new ArgumentNullException("first");
  1386. if (second == null)
  1387. throw new ArgumentNullException("second");
  1388. return first.Provider.CreateQuery<TSource>(
  1389. Expression.Call(
  1390. null,
  1391. #if CRIPPLED_REFLECTION
  1392. InfoOf(() => Qbservable.Catch<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  1393. #else
  1394. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1395. #endif
  1396. first.Expression,
  1397. GetSourceExpression(second)
  1398. )
  1399. );
  1400. }
  1401. /// <summary>
  1402. /// Continues an observable sequence that is terminated by an exception with the next observable sequence.
  1403. /// </summary>
  1404. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  1405. /// <typeparam name="TSource">The type of the elements in the source and handler sequences.</typeparam>
  1406. /// <param name="sources">Observable sequences to catch exceptions for.</param>
  1407. /// <returns>An observable sequence containing elements from consecutive source sequences until a source sequence terminates successfully.</returns>
  1408. /// <exception cref="T:System.ArgumentNullException">
  1409. /// <paramref name="sources" /> is null.</exception>
  1410. public static IQbservable<TSource> Catch<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  1411. {
  1412. if (provider == null)
  1413. throw new ArgumentNullException("provider");
  1414. if (sources == null)
  1415. throw new ArgumentNullException("sources");
  1416. return provider.CreateQuery<TSource>(
  1417. Expression.Call(
  1418. null,
  1419. #if CRIPPLED_REFLECTION
  1420. InfoOf(() => Qbservable.Catch<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  1421. #else
  1422. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1423. #endif
  1424. Expression.Constant(provider, typeof(IQbservableProvider)),
  1425. GetSourceExpression(sources)
  1426. )
  1427. );
  1428. }
  1429. /// <summary>
  1430. /// Continues an observable sequence that is terminated by an exception with the next observable sequence.
  1431. /// </summary>
  1432. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  1433. /// <typeparam name="TSource">The type of the elements in the source and handler sequences.</typeparam>
  1434. /// <param name="sources">Observable sequences to catch exceptions for.</param>
  1435. /// <returns>An observable sequence containing elements from consecutive source sequences until a source sequence terminates successfully.</returns>
  1436. /// <exception cref="T:System.ArgumentNullException">
  1437. /// <paramref name="sources" /> is null.</exception>
  1438. public static IQbservable<TSource> Catch<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  1439. {
  1440. if (provider == null)
  1441. throw new ArgumentNullException("provider");
  1442. if (sources == null)
  1443. throw new ArgumentNullException("sources");
  1444. return provider.CreateQuery<TSource>(
  1445. Expression.Call(
  1446. null,
  1447. #if CRIPPLED_REFLECTION
  1448. InfoOf(() => Qbservable.Catch<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  1449. #else
  1450. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1451. #endif
  1452. Expression.Constant(provider, typeof(IQbservableProvider)),
  1453. GetSourceExpression(sources)
  1454. )
  1455. );
  1456. }
  1457. /// <summary>
  1458. /// Continues an observable sequence that is terminated by an exception of the specified type with the observable sequence produced by the handler.
  1459. /// </summary>
  1460. /// <typeparam name="TSource">The type of the elements in the source sequence and sequences returned by the exception handler function.</typeparam>
  1461. /// <typeparam name="TException">The type of the exception to catch and handle. Needs to derive from <see cref="T:System.Exception" />.</typeparam>
  1462. /// <param name="source">Source sequence.</param>
  1463. /// <param name="handler">Exception handler function, producing another observable sequence.</param>
  1464. /// <returns>An observable sequence containing the source sequence's elements, followed by the elements produced by the handler's resulting observable sequence in case an exception occurred.</returns>
  1465. /// <exception cref="T:System.ArgumentNullException">
  1466. /// <paramref name="source" /> or <paramref name="handler" /> is null.</exception>
  1467. public static IQbservable<TSource> Catch<TSource, TException>(this IQbservable<TSource> source, Expression<Func<TException, IObservable<TSource>>> handler)
  1468. where TException : Exception
  1469. {
  1470. if (source == null)
  1471. throw new ArgumentNullException("source");
  1472. if (handler == null)
  1473. throw new ArgumentNullException("handler");
  1474. return source.Provider.CreateQuery<TSource>(
  1475. Expression.Call(
  1476. null,
  1477. #if CRIPPLED_REFLECTION
  1478. InfoOf(() => Qbservable.Catch<TSource, TException>(default(IQbservable<TSource>), default(Expression<Func<TException, IObservable<TSource>>>))),
  1479. #else
  1480. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TException)),
  1481. #endif
  1482. source.Expression,
  1483. handler
  1484. )
  1485. );
  1486. }
  1487. /// <summary>
  1488. /// Produces an enumerable sequence of consecutive (possibly empty) chunks of the source sequence.
  1489. /// </summary>
  1490. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  1491. /// <param name="source">Source observable sequence.</param>
  1492. /// <returns>The enumerable sequence that returns consecutive (possibly empty) chunks upon each iteration.</returns>
  1493. /// <exception cref="T:System.ArgumentNullException">
  1494. /// <paramref name="source" /> is null.</exception>
  1495. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  1496. public static IQueryable<IList<TSource>> Chunkify<TSource>(this IQbservable<TSource> source)
  1497. {
  1498. if (source == null)
  1499. throw new ArgumentNullException("source");
  1500. return ((IQueryProvider)source.Provider).CreateQuery<IList<TSource>>(
  1501. Expression.Call(
  1502. null,
  1503. #if CRIPPLED_REFLECTION
  1504. InfoOf(() => Qbservable.Chunkify<TSource>(default(IQbservable<TSource>))),
  1505. #else
  1506. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1507. #endif
  1508. source.Expression
  1509. )
  1510. );
  1511. }
  1512. /// <summary>
  1513. /// Produces an enumerable sequence that returns elements collected/aggregated from the source sequence between consecutive iterations.
  1514. /// </summary>
  1515. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  1516. /// <typeparam name="TResult">The type of the elements produced by the merge operation during collection.</typeparam>
  1517. /// <param name="source">Source observable sequence.</param>
  1518. /// <param name="getInitialCollector">Factory to create the initial collector object.</param>
  1519. /// <param name="merge">Merges a sequence element with the current collector.</param>
  1520. /// <param name="getNewCollector">Factory to replace the current collector by a new collector.</param>
  1521. /// <returns>The enumerable sequence that returns collected/aggregated elements from the source sequence upon each iteration.</returns>
  1522. /// <exception cref="T:System.ArgumentNullException">
  1523. /// <paramref name="source" /> or <paramref name="getInitialCollector" /> or <paramref name="merge" /> or <paramref name="getNewCollector" /> is null.</exception>
  1524. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  1525. public static IQueryable<TResult> Collect<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TResult>> getInitialCollector, Expression<Func<TResult, TSource, TResult>> merge, Expression<Func<TResult, TResult>> getNewCollector)
  1526. {
  1527. if (source == null)
  1528. throw new ArgumentNullException("source");
  1529. if (getInitialCollector == null)
  1530. throw new ArgumentNullException("getInitialCollector");
  1531. if (merge == null)
  1532. throw new ArgumentNullException("merge");
  1533. if (getNewCollector == null)
  1534. throw new ArgumentNullException("getNewCollector");
  1535. return ((IQueryProvider)source.Provider).CreateQuery<TResult>(
  1536. Expression.Call(
  1537. null,
  1538. #if CRIPPLED_REFLECTION
  1539. InfoOf(() => Qbservable.Collect<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TResult>>), default(Expression<Func<TResult, TSource, TResult>>), default(Expression<Func<TResult, TResult>>))),
  1540. #else
  1541. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  1542. #endif
  1543. source.Expression,
  1544. getInitialCollector,
  1545. merge,
  1546. getNewCollector
  1547. )
  1548. );
  1549. }
  1550. /// <summary>
  1551. /// Produces an enumerable sequence that returns elements collected/aggregated from the source sequence between consecutive iterations.
  1552. /// </summary>
  1553. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  1554. /// <typeparam name="TResult">The type of the elements produced by the merge operation during collection.</typeparam>
  1555. /// <param name="source">Source observable sequence.</param>
  1556. /// <param name="newCollector">Factory to create a new collector object.</param>
  1557. /// <param name="merge">Merges a sequence element with the current collector.</param>
  1558. /// <returns>The enumerable sequence that returns collected/aggregated elements from the source sequence upon each iteration.</returns>
  1559. /// <exception cref="T:System.ArgumentNullException">
  1560. /// <paramref name="source" /> or <paramref name="newCollector" /> or <paramref name="merge" /> is null.</exception>
  1561. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  1562. public static IQueryable<TResult> Collect<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TResult>> newCollector, Expression<Func<TResult, TSource, TResult>> merge)
  1563. {
  1564. if (source == null)
  1565. throw new ArgumentNullException("source");
  1566. if (newCollector == null)
  1567. throw new ArgumentNullException("newCollector");
  1568. if (merge == null)
  1569. throw new ArgumentNullException("merge");
  1570. return ((IQueryProvider)source.Provider).CreateQuery<TResult>(
  1571. Expression.Call(
  1572. null,
  1573. #if CRIPPLED_REFLECTION
  1574. InfoOf(() => Qbservable.Collect<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TResult>>), default(Expression<Func<TResult, TSource, TResult>>))),
  1575. #else
  1576. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  1577. #endif
  1578. source.Expression,
  1579. newCollector,
  1580. merge
  1581. )
  1582. );
  1583. }
  1584. /// <summary>
  1585. /// Merges the specified observable sequences into one observable sequence by emitting a list with the latest source elements whenever any of the observable sequences produces an element.
  1586. /// </summary>
  1587. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  1588. /// <typeparam name="TSource">The type of the elements in the source sequences, and in the lists in the result sequence.</typeparam>
  1589. /// <param name="sources">Observable sources.</param>
  1590. /// <returns>An observable sequence containing lists of the latest elements of the sources.</returns>
  1591. /// <exception cref="T:System.ArgumentNullException">
  1592. /// <paramref name="sources" /> is null.</exception>
  1593. public static IQbservable<IList<TSource>> CombineLatest<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  1594. {
  1595. if (provider == null)
  1596. throw new ArgumentNullException("provider");
  1597. if (sources == null)
  1598. throw new ArgumentNullException("sources");
  1599. return provider.CreateQuery<IList<TSource>>(
  1600. Expression.Call(
  1601. null,
  1602. #if CRIPPLED_REFLECTION
  1603. InfoOf(() => Qbservable.CombineLatest<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  1604. #else
  1605. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1606. #endif
  1607. Expression.Constant(provider, typeof(IQbservableProvider)),
  1608. GetSourceExpression(sources)
  1609. )
  1610. );
  1611. }
  1612. /// <summary>
  1613. /// Merges the specified observable sequences into one observable sequence by emitting a list with the latest source elements whenever any of the observable sequences produces an element.
  1614. /// </summary>
  1615. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  1616. /// <typeparam name="TSource">The type of the elements in the source sequences, and in the lists in the result sequence.</typeparam>
  1617. /// <param name="sources">Observable sources.</param>
  1618. /// <returns>An observable sequence containing lists of the latest elements of the sources.</returns>
  1619. /// <exception cref="T:System.ArgumentNullException">
  1620. /// <paramref name="sources" /> is null.</exception>
  1621. public static IQbservable<IList<TSource>> CombineLatest<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  1622. {
  1623. if (provider == null)
  1624. throw new ArgumentNullException("provider");
  1625. if (sources == null)
  1626. throw new ArgumentNullException("sources");
  1627. return provider.CreateQuery<IList<TSource>>(
  1628. Expression.Call(
  1629. null,
  1630. #if CRIPPLED_REFLECTION
  1631. InfoOf(() => Qbservable.CombineLatest<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  1632. #else
  1633. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1634. #endif
  1635. Expression.Constant(provider, typeof(IQbservableProvider)),
  1636. GetSourceExpression(sources)
  1637. )
  1638. );
  1639. }
  1640. /// <summary>
  1641. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1642. /// </summary>
  1643. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  1644. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  1645. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1646. /// <param name="sources">Observable sources.</param>
  1647. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element. For efficiency, the input list is reused after the selector returns. Either aggregate or copy the values during the function call.</param>
  1648. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1649. /// <exception cref="T:System.ArgumentNullException">
  1650. /// <paramref name="sources" /> or <paramref name="resultSelector" /> is null.</exception>
  1651. public static IQbservable<TResult> CombineLatest<TSource, TResult>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, Expression<Func<IList<TSource>, TResult>> resultSelector)
  1652. {
  1653. if (provider == null)
  1654. throw new ArgumentNullException("provider");
  1655. if (sources == null)
  1656. throw new ArgumentNullException("sources");
  1657. if (resultSelector == null)
  1658. throw new ArgumentNullException("resultSelector");
  1659. return provider.CreateQuery<TResult>(
  1660. Expression.Call(
  1661. null,
  1662. #if CRIPPLED_REFLECTION
  1663. InfoOf(() => Qbservable.CombineLatest<TSource, TResult>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(Expression<Func<IList<TSource>, TResult>>))),
  1664. #else
  1665. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  1666. #endif
  1667. Expression.Constant(provider, typeof(IQbservableProvider)),
  1668. GetSourceExpression(sources),
  1669. resultSelector
  1670. )
  1671. );
  1672. }
  1673. /// <summary>
  1674. /// Merges two observable sequences into one observable sequence by using the selector function whenever one of the observable sequences produces an element.
  1675. /// </summary>
  1676. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1677. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1678. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1679. /// <param name="first">First observable source.</param>
  1680. /// <param name="second">Second observable source.</param>
  1681. /// <param name="resultSelector">Function to invoke whenever either of the sources produces an element.</param>
  1682. /// <returns>An observable sequence containing the result of combining elements of both sources using the specified result selector function.</returns>
  1683. /// <exception cref="T:System.ArgumentNullException">
  1684. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="resultSelector" /> is null.</exception>
  1685. public static IQbservable<TResult> CombineLatest<TSource1, TSource2, TResult>(this IQbservable<TSource1> first, IObservable<TSource2> second, Expression<Func<TSource1, TSource2, TResult>> resultSelector)
  1686. {
  1687. if (first == null)
  1688. throw new ArgumentNullException("first");
  1689. if (second == null)
  1690. throw new ArgumentNullException("second");
  1691. if (resultSelector == null)
  1692. throw new ArgumentNullException("resultSelector");
  1693. return first.Provider.CreateQuery<TResult>(
  1694. Expression.Call(
  1695. null,
  1696. #if CRIPPLED_REFLECTION
  1697. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(Expression<Func<TSource1, TSource2, TResult>>))),
  1698. #else
  1699. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TResult)),
  1700. #endif
  1701. first.Expression,
  1702. GetSourceExpression(second),
  1703. resultSelector
  1704. )
  1705. );
  1706. }
  1707. /// <summary>
  1708. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1709. /// </summary>
  1710. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1711. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1712. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  1713. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1714. /// <param name="source1">First observable source.</param>
  1715. /// <param name="source2">Second observable source.</param>
  1716. /// <param name="source3">Third observable source.</param>
  1717. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  1718. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1719. /// <exception cref="T:System.ArgumentNullException">
  1720. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="resultSelector" /> is null.</exception>
  1721. public static IQbservable<TResult> CombineLatest<TSource1, TSource2, TSource3, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, Expression<Func<TSource1, TSource2, TSource3, TResult>> resultSelector)
  1722. {
  1723. if (source1 == null)
  1724. throw new ArgumentNullException("source1");
  1725. if (source2 == null)
  1726. throw new ArgumentNullException("source2");
  1727. if (source3 == null)
  1728. throw new ArgumentNullException("source3");
  1729. if (resultSelector == null)
  1730. throw new ArgumentNullException("resultSelector");
  1731. return source1.Provider.CreateQuery<TResult>(
  1732. Expression.Call(
  1733. null,
  1734. #if CRIPPLED_REFLECTION
  1735. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TSource3, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(Expression<Func<TSource1, TSource2, TSource3, TResult>>))),
  1736. #else
  1737. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TResult)),
  1738. #endif
  1739. source1.Expression,
  1740. GetSourceExpression(source2),
  1741. GetSourceExpression(source3),
  1742. resultSelector
  1743. )
  1744. );
  1745. }
  1746. /// <summary>
  1747. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1748. /// </summary>
  1749. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1750. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1751. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  1752. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  1753. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1754. /// <param name="source1">First observable source.</param>
  1755. /// <param name="source2">Second observable source.</param>
  1756. /// <param name="source3">Third observable source.</param>
  1757. /// <param name="source4">Fourth observable source.</param>
  1758. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  1759. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1760. /// <exception cref="T:System.ArgumentNullException">
  1761. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="resultSelector" /> is null.</exception>
  1762. public static IQbservable<TResult> CombineLatest<TSource1, TSource2, TSource3, TSource4, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, Expression<Func<TSource1, TSource2, TSource3, TSource4, TResult>> resultSelector)
  1763. {
  1764. if (source1 == null)
  1765. throw new ArgumentNullException("source1");
  1766. if (source2 == null)
  1767. throw new ArgumentNullException("source2");
  1768. if (source3 == null)
  1769. throw new ArgumentNullException("source3");
  1770. if (source4 == null)
  1771. throw new ArgumentNullException("source4");
  1772. if (resultSelector == null)
  1773. throw new ArgumentNullException("resultSelector");
  1774. return source1.Provider.CreateQuery<TResult>(
  1775. Expression.Call(
  1776. null,
  1777. #if CRIPPLED_REFLECTION
  1778. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TSource3, TSource4, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TResult>>))),
  1779. #else
  1780. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TResult)),
  1781. #endif
  1782. source1.Expression,
  1783. GetSourceExpression(source2),
  1784. GetSourceExpression(source3),
  1785. GetSourceExpression(source4),
  1786. resultSelector
  1787. )
  1788. );
  1789. }
  1790. #if !NO_LARGEARITY
  1791. /// <summary>
  1792. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1793. /// </summary>
  1794. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1795. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1796. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  1797. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  1798. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  1799. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1800. /// <param name="source1">First observable source.</param>
  1801. /// <param name="source2">Second observable source.</param>
  1802. /// <param name="source3">Third observable source.</param>
  1803. /// <param name="source4">Fourth observable source.</param>
  1804. /// <param name="source5">Fifth observable source.</param>
  1805. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  1806. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1807. /// <exception cref="T:System.ArgumentNullException">
  1808. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="resultSelector" /> is null.</exception>
  1809. public static IQbservable<TResult> CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TResult>> resultSelector)
  1810. {
  1811. if (source1 == null)
  1812. throw new ArgumentNullException("source1");
  1813. if (source2 == null)
  1814. throw new ArgumentNullException("source2");
  1815. if (source3 == null)
  1816. throw new ArgumentNullException("source3");
  1817. if (source4 == null)
  1818. throw new ArgumentNullException("source4");
  1819. if (source5 == null)
  1820. throw new ArgumentNullException("source5");
  1821. if (resultSelector == null)
  1822. throw new ArgumentNullException("resultSelector");
  1823. return source1.Provider.CreateQuery<TResult>(
  1824. Expression.Call(
  1825. null,
  1826. #if CRIPPLED_REFLECTION
  1827. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(IObservable<TSource5>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TResult>>))),
  1828. #else
  1829. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TResult)),
  1830. #endif
  1831. source1.Expression,
  1832. GetSourceExpression(source2),
  1833. GetSourceExpression(source3),
  1834. GetSourceExpression(source4),
  1835. GetSourceExpression(source5),
  1836. resultSelector
  1837. )
  1838. );
  1839. }
  1840. #endif
  1841. #if !NO_LARGEARITY
  1842. /// <summary>
  1843. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1844. /// </summary>
  1845. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1846. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1847. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  1848. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  1849. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  1850. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  1851. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1852. /// <param name="source1">First observable source.</param>
  1853. /// <param name="source2">Second observable source.</param>
  1854. /// <param name="source3">Third observable source.</param>
  1855. /// <param name="source4">Fourth observable source.</param>
  1856. /// <param name="source5">Fifth observable source.</param>
  1857. /// <param name="source6">Sixth observable source.</param>
  1858. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  1859. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1860. /// <exception cref="T:System.ArgumentNullException">
  1861. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="source6" /> or <paramref name="resultSelector" /> is null.</exception>
  1862. public static IQbservable<TResult> CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, IObservable<TSource6> source6, Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TResult>> resultSelector)
  1863. {
  1864. if (source1 == null)
  1865. throw new ArgumentNullException("source1");
  1866. if (source2 == null)
  1867. throw new ArgumentNullException("source2");
  1868. if (source3 == null)
  1869. throw new ArgumentNullException("source3");
  1870. if (source4 == null)
  1871. throw new ArgumentNullException("source4");
  1872. if (source5 == null)
  1873. throw new ArgumentNullException("source5");
  1874. if (source6 == null)
  1875. throw new ArgumentNullException("source6");
  1876. if (resultSelector == null)
  1877. throw new ArgumentNullException("resultSelector");
  1878. return source1.Provider.CreateQuery<TResult>(
  1879. Expression.Call(
  1880. null,
  1881. #if CRIPPLED_REFLECTION
  1882. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(IObservable<TSource5>), default(IObservable<TSource6>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TResult>>))),
  1883. #else
  1884. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TResult)),
  1885. #endif
  1886. source1.Expression,
  1887. GetSourceExpression(source2),
  1888. GetSourceExpression(source3),
  1889. GetSourceExpression(source4),
  1890. GetSourceExpression(source5),
  1891. GetSourceExpression(source6),
  1892. resultSelector
  1893. )
  1894. );
  1895. }
  1896. #endif
  1897. #if !NO_LARGEARITY
  1898. /// <summary>
  1899. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1900. /// </summary>
  1901. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1902. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1903. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  1904. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  1905. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  1906. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  1907. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  1908. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1909. /// <param name="source1">First observable source.</param>
  1910. /// <param name="source2">Second observable source.</param>
  1911. /// <param name="source3">Third observable source.</param>
  1912. /// <param name="source4">Fourth observable source.</param>
  1913. /// <param name="source5">Fifth observable source.</param>
  1914. /// <param name="source6">Sixth observable source.</param>
  1915. /// <param name="source7">Seventh observable source.</param>
  1916. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  1917. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1918. /// <exception cref="T:System.ArgumentNullException">
  1919. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="source6" /> or <paramref name="source7" /> or <paramref name="resultSelector" /> is null.</exception>
  1920. public static IQbservable<TResult> CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, IObservable<TSource6> source6, IObservable<TSource7> source7, Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TResult>> resultSelector)
  1921. {
  1922. if (source1 == null)
  1923. throw new ArgumentNullException("source1");
  1924. if (source2 == null)
  1925. throw new ArgumentNullException("source2");
  1926. if (source3 == null)
  1927. throw new ArgumentNullException("source3");
  1928. if (source4 == null)
  1929. throw new ArgumentNullException("source4");
  1930. if (source5 == null)
  1931. throw new ArgumentNullException("source5");
  1932. if (source6 == null)
  1933. throw new ArgumentNullException("source6");
  1934. if (source7 == null)
  1935. throw new ArgumentNullException("source7");
  1936. if (resultSelector == null)
  1937. throw new ArgumentNullException("resultSelector");
  1938. return source1.Provider.CreateQuery<TResult>(
  1939. Expression.Call(
  1940. null,
  1941. #if CRIPPLED_REFLECTION
  1942. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(IObservable<TSource5>), default(IObservable<TSource6>), default(IObservable<TSource7>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TResult>>))),
  1943. #else
  1944. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TResult)),
  1945. #endif
  1946. source1.Expression,
  1947. GetSourceExpression(source2),
  1948. GetSourceExpression(source3),
  1949. GetSourceExpression(source4),
  1950. GetSourceExpression(source5),
  1951. GetSourceExpression(source6),
  1952. GetSourceExpression(source7),
  1953. resultSelector
  1954. )
  1955. );
  1956. }
  1957. #endif
  1958. #if !NO_LARGEARITY
  1959. /// <summary>
  1960. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1961. /// </summary>
  1962. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1963. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1964. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  1965. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  1966. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  1967. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  1968. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  1969. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  1970. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1971. /// <param name="source1">First observable source.</param>
  1972. /// <param name="source2">Second observable source.</param>
  1973. /// <param name="source3">Third observable source.</param>
  1974. /// <param name="source4">Fourth observable source.</param>
  1975. /// <param name="source5">Fifth observable source.</param>
  1976. /// <param name="source6">Sixth observable source.</param>
  1977. /// <param name="source7">Seventh observable source.</param>
  1978. /// <param name="source8">Eighth observable source.</param>
  1979. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  1980. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1981. /// <exception cref="T:System.ArgumentNullException">
  1982. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="source6" /> or <paramref name="source7" /> or <paramref name="source8" /> or <paramref name="resultSelector" /> is null.</exception>
  1983. public static IQbservable<TResult> CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, IObservable<TSource6> source6, IObservable<TSource7> source7, IObservable<TSource8> source8, Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TResult>> resultSelector)
  1984. {
  1985. if (source1 == null)
  1986. throw new ArgumentNullException("source1");
  1987. if (source2 == null)
  1988. throw new ArgumentNullException("source2");
  1989. if (source3 == null)
  1990. throw new ArgumentNullException("source3");
  1991. if (source4 == null)
  1992. throw new ArgumentNullException("source4");
  1993. if (source5 == null)
  1994. throw new ArgumentNullException("source5");
  1995. if (source6 == null)
  1996. throw new ArgumentNullException("source6");
  1997. if (source7 == null)
  1998. throw new ArgumentNullException("source7");
  1999. if (source8 == null)
  2000. throw new ArgumentNullException("source8");
  2001. if (resultSelector == null)
  2002. throw new ArgumentNullException("resultSelector");
  2003. return source1.Provider.CreateQuery<TResult>(
  2004. Expression.Call(
  2005. null,
  2006. #if CRIPPLED_REFLECTION
  2007. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(IObservable<TSource5>), default(IObservable<TSource6>), default(IObservable<TSource7>), default(IObservable<TSource8>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TResult>>))),
  2008. #else
  2009. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TResult)),
  2010. #endif
  2011. source1.Expression,
  2012. GetSourceExpression(source2),
  2013. GetSourceExpression(source3),
  2014. GetSourceExpression(source4),
  2015. GetSourceExpression(source5),
  2016. GetSourceExpression(source6),
  2017. GetSourceExpression(source7),
  2018. GetSourceExpression(source8),
  2019. resultSelector
  2020. )
  2021. );
  2022. }
  2023. #endif
  2024. #if !NO_LARGEARITY
  2025. /// <summary>
  2026. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2027. /// </summary>
  2028. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2029. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2030. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2031. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2032. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2033. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2034. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2035. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2036. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2037. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2038. /// <param name="source1">First observable source.</param>
  2039. /// <param name="source2">Second observable source.</param>
  2040. /// <param name="source3">Third observable source.</param>
  2041. /// <param name="source4">Fourth observable source.</param>
  2042. /// <param name="source5">Fifth observable source.</param>
  2043. /// <param name="source6">Sixth observable source.</param>
  2044. /// <param name="source7">Seventh observable source.</param>
  2045. /// <param name="source8">Eighth observable source.</param>
  2046. /// <param name="source9">Ninth observable source.</param>
  2047. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2048. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2049. /// <exception cref="T:System.ArgumentNullException">
  2050. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="source6" /> or <paramref name="source7" /> or <paramref name="source8" /> or <paramref name="source9" /> or <paramref name="resultSelector" /> is null.</exception>
  2051. public static IQbservable<TResult> CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, IObservable<TSource6> source6, IObservable<TSource7> source7, IObservable<TSource8> source8, IObservable<TSource9> source9, Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TResult>> resultSelector)
  2052. {
  2053. if (source1 == null)
  2054. throw new ArgumentNullException("source1");
  2055. if (source2 == null)
  2056. throw new ArgumentNullException("source2");
  2057. if (source3 == null)
  2058. throw new ArgumentNullException("source3");
  2059. if (source4 == null)
  2060. throw new ArgumentNullException("source4");
  2061. if (source5 == null)
  2062. throw new ArgumentNullException("source5");
  2063. if (source6 == null)
  2064. throw new ArgumentNullException("source6");
  2065. if (source7 == null)
  2066. throw new ArgumentNullException("source7");
  2067. if (source8 == null)
  2068. throw new ArgumentNullException("source8");
  2069. if (source9 == null)
  2070. throw new ArgumentNullException("source9");
  2071. if (resultSelector == null)
  2072. throw new ArgumentNullException("resultSelector");
  2073. return source1.Provider.CreateQuery<TResult>(
  2074. Expression.Call(
  2075. null,
  2076. #if CRIPPLED_REFLECTION
  2077. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(IObservable<TSource5>), default(IObservable<TSource6>), default(IObservable<TSource7>), default(IObservable<TSource8>), default(IObservable<TSource9>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TResult>>))),
  2078. #else
  2079. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TSource9), typeof(TResult)),
  2080. #endif
  2081. source1.Expression,
  2082. GetSourceExpression(source2),
  2083. GetSourceExpression(source3),
  2084. GetSourceExpression(source4),
  2085. GetSourceExpression(source5),
  2086. GetSourceExpression(source6),
  2087. GetSourceExpression(source7),
  2088. GetSourceExpression(source8),
  2089. GetSourceExpression(source9),
  2090. resultSelector
  2091. )
  2092. );
  2093. }
  2094. #endif
  2095. #if !NO_LARGEARITY
  2096. /// <summary>
  2097. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2098. /// </summary>
  2099. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2100. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2101. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2102. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2103. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2104. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2105. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2106. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2107. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2108. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2109. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2110. /// <param name="source1">First observable source.</param>
  2111. /// <param name="source2">Second observable source.</param>
  2112. /// <param name="source3">Third observable source.</param>
  2113. /// <param name="source4">Fourth observable source.</param>
  2114. /// <param name="source5">Fifth observable source.</param>
  2115. /// <param name="source6">Sixth observable source.</param>
  2116. /// <param name="source7">Seventh observable source.</param>
  2117. /// <param name="source8">Eighth observable source.</param>
  2118. /// <param name="source9">Ninth observable source.</param>
  2119. /// <param name="source10">Tenth observable source.</param>
  2120. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2121. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2122. /// <exception cref="T:System.ArgumentNullException">
  2123. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="source6" /> or <paramref name="source7" /> or <paramref name="source8" /> or <paramref name="source9" /> or <paramref name="source10" /> or <paramref name="resultSelector" /> is null.</exception>
  2124. public static IQbservable<TResult> CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, IObservable<TSource6> source6, IObservable<TSource7> source7, IObservable<TSource8> source8, IObservable<TSource9> source9, IObservable<TSource10> source10, Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TResult>> resultSelector)
  2125. {
  2126. if (source1 == null)
  2127. throw new ArgumentNullException("source1");
  2128. if (source2 == null)
  2129. throw new ArgumentNullException("source2");
  2130. if (source3 == null)
  2131. throw new ArgumentNullException("source3");
  2132. if (source4 == null)
  2133. throw new ArgumentNullException("source4");
  2134. if (source5 == null)
  2135. throw new ArgumentNullException("source5");
  2136. if (source6 == null)
  2137. throw new ArgumentNullException("source6");
  2138. if (source7 == null)
  2139. throw new ArgumentNullException("source7");
  2140. if (source8 == null)
  2141. throw new ArgumentNullException("source8");
  2142. if (source9 == null)
  2143. throw new ArgumentNullException("source9");
  2144. if (source10 == null)
  2145. throw new ArgumentNullException("source10");
  2146. if (resultSelector == null)
  2147. throw new ArgumentNullException("resultSelector");
  2148. return source1.Provider.CreateQuery<TResult>(
  2149. Expression.Call(
  2150. null,
  2151. #if CRIPPLED_REFLECTION
  2152. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(IObservable<TSource5>), default(IObservable<TSource6>), default(IObservable<TSource7>), default(IObservable<TSource8>), default(IObservable<TSource9>), default(IObservable<TSource10>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TResult>>))),
  2153. #else
  2154. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TSource9), typeof(TSource10), typeof(TResult)),
  2155. #endif
  2156. source1.Expression,
  2157. GetSourceExpression(source2),
  2158. GetSourceExpression(source3),
  2159. GetSourceExpression(source4),
  2160. GetSourceExpression(source5),
  2161. GetSourceExpression(source6),
  2162. GetSourceExpression(source7),
  2163. GetSourceExpression(source8),
  2164. GetSourceExpression(source9),
  2165. GetSourceExpression(source10),
  2166. resultSelector
  2167. )
  2168. );
  2169. }
  2170. #endif
  2171. #if !NO_LARGEARITY
  2172. /// <summary>
  2173. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2174. /// </summary>
  2175. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2176. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2177. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2178. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2179. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2180. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2181. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2182. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2183. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2184. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2185. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  2186. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2187. /// <param name="source1">First observable source.</param>
  2188. /// <param name="source2">Second observable source.</param>
  2189. /// <param name="source3">Third observable source.</param>
  2190. /// <param name="source4">Fourth observable source.</param>
  2191. /// <param name="source5">Fifth observable source.</param>
  2192. /// <param name="source6">Sixth observable source.</param>
  2193. /// <param name="source7">Seventh observable source.</param>
  2194. /// <param name="source8">Eighth observable source.</param>
  2195. /// <param name="source9">Ninth observable source.</param>
  2196. /// <param name="source10">Tenth observable source.</param>
  2197. /// <param name="source11">Eleventh observable source.</param>
  2198. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2199. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2200. /// <exception cref="T:System.ArgumentNullException">
  2201. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="source6" /> or <paramref name="source7" /> or <paramref name="source8" /> or <paramref name="source9" /> or <paramref name="source10" /> or <paramref name="source11" /> or <paramref name="resultSelector" /> is null.</exception>
  2202. public static IQbservable<TResult> CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, IObservable<TSource6> source6, IObservable<TSource7> source7, IObservable<TSource8> source8, IObservable<TSource9> source9, IObservable<TSource10> source10, IObservable<TSource11> source11, Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TResult>> resultSelector)
  2203. {
  2204. if (source1 == null)
  2205. throw new ArgumentNullException("source1");
  2206. if (source2 == null)
  2207. throw new ArgumentNullException("source2");
  2208. if (source3 == null)
  2209. throw new ArgumentNullException("source3");
  2210. if (source4 == null)
  2211. throw new ArgumentNullException("source4");
  2212. if (source5 == null)
  2213. throw new ArgumentNullException("source5");
  2214. if (source6 == null)
  2215. throw new ArgumentNullException("source6");
  2216. if (source7 == null)
  2217. throw new ArgumentNullException("source7");
  2218. if (source8 == null)
  2219. throw new ArgumentNullException("source8");
  2220. if (source9 == null)
  2221. throw new ArgumentNullException("source9");
  2222. if (source10 == null)
  2223. throw new ArgumentNullException("source10");
  2224. if (source11 == null)
  2225. throw new ArgumentNullException("source11");
  2226. if (resultSelector == null)
  2227. throw new ArgumentNullException("resultSelector");
  2228. return source1.Provider.CreateQuery<TResult>(
  2229. Expression.Call(
  2230. null,
  2231. #if CRIPPLED_REFLECTION
  2232. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(IObservable<TSource5>), default(IObservable<TSource6>), default(IObservable<TSource7>), default(IObservable<TSource8>), default(IObservable<TSource9>), default(IObservable<TSource10>), default(IObservable<TSource11>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TResult>>))),
  2233. #else
  2234. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TSource9), typeof(TSource10), typeof(TSource11), typeof(TResult)),
  2235. #endif
  2236. source1.Expression,
  2237. GetSourceExpression(source2),
  2238. GetSourceExpression(source3),
  2239. GetSourceExpression(source4),
  2240. GetSourceExpression(source5),
  2241. GetSourceExpression(source6),
  2242. GetSourceExpression(source7),
  2243. GetSourceExpression(source8),
  2244. GetSourceExpression(source9),
  2245. GetSourceExpression(source10),
  2246. GetSourceExpression(source11),
  2247. resultSelector
  2248. )
  2249. );
  2250. }
  2251. #endif
  2252. #if !NO_LARGEARITY
  2253. /// <summary>
  2254. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2255. /// </summary>
  2256. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2257. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2258. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2259. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2260. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2261. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2262. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2263. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2264. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2265. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2266. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  2267. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  2268. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2269. /// <param name="source1">First observable source.</param>
  2270. /// <param name="source2">Second observable source.</param>
  2271. /// <param name="source3">Third observable source.</param>
  2272. /// <param name="source4">Fourth observable source.</param>
  2273. /// <param name="source5">Fifth observable source.</param>
  2274. /// <param name="source6">Sixth observable source.</param>
  2275. /// <param name="source7">Seventh observable source.</param>
  2276. /// <param name="source8">Eighth observable source.</param>
  2277. /// <param name="source9">Ninth observable source.</param>
  2278. /// <param name="source10">Tenth observable source.</param>
  2279. /// <param name="source11">Eleventh observable source.</param>
  2280. /// <param name="source12">Twelfth observable source.</param>
  2281. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2282. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2283. /// <exception cref="T:System.ArgumentNullException">
  2284. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="source6" /> or <paramref name="source7" /> or <paramref name="source8" /> or <paramref name="source9" /> or <paramref name="source10" /> or <paramref name="source11" /> or <paramref name="source12" /> or <paramref name="resultSelector" /> is null.</exception>
  2285. public static IQbservable<TResult> CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, IObservable<TSource6> source6, IObservable<TSource7> source7, IObservable<TSource8> source8, IObservable<TSource9> source9, IObservable<TSource10> source10, IObservable<TSource11> source11, IObservable<TSource12> source12, Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TResult>> resultSelector)
  2286. {
  2287. if (source1 == null)
  2288. throw new ArgumentNullException("source1");
  2289. if (source2 == null)
  2290. throw new ArgumentNullException("source2");
  2291. if (source3 == null)
  2292. throw new ArgumentNullException("source3");
  2293. if (source4 == null)
  2294. throw new ArgumentNullException("source4");
  2295. if (source5 == null)
  2296. throw new ArgumentNullException("source5");
  2297. if (source6 == null)
  2298. throw new ArgumentNullException("source6");
  2299. if (source7 == null)
  2300. throw new ArgumentNullException("source7");
  2301. if (source8 == null)
  2302. throw new ArgumentNullException("source8");
  2303. if (source9 == null)
  2304. throw new ArgumentNullException("source9");
  2305. if (source10 == null)
  2306. throw new ArgumentNullException("source10");
  2307. if (source11 == null)
  2308. throw new ArgumentNullException("source11");
  2309. if (source12 == null)
  2310. throw new ArgumentNullException("source12");
  2311. if (resultSelector == null)
  2312. throw new ArgumentNullException("resultSelector");
  2313. return source1.Provider.CreateQuery<TResult>(
  2314. Expression.Call(
  2315. null,
  2316. #if CRIPPLED_REFLECTION
  2317. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(IObservable<TSource5>), default(IObservable<TSource6>), default(IObservable<TSource7>), default(IObservable<TSource8>), default(IObservable<TSource9>), default(IObservable<TSource10>), default(IObservable<TSource11>), default(IObservable<TSource12>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TResult>>))),
  2318. #else
  2319. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TSource9), typeof(TSource10), typeof(TSource11), typeof(TSource12), typeof(TResult)),
  2320. #endif
  2321. source1.Expression,
  2322. GetSourceExpression(source2),
  2323. GetSourceExpression(source3),
  2324. GetSourceExpression(source4),
  2325. GetSourceExpression(source5),
  2326. GetSourceExpression(source6),
  2327. GetSourceExpression(source7),
  2328. GetSourceExpression(source8),
  2329. GetSourceExpression(source9),
  2330. GetSourceExpression(source10),
  2331. GetSourceExpression(source11),
  2332. GetSourceExpression(source12),
  2333. resultSelector
  2334. )
  2335. );
  2336. }
  2337. #endif
  2338. #if !NO_LARGEARITY
  2339. /// <summary>
  2340. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2341. /// </summary>
  2342. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2343. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2344. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2345. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2346. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2347. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2348. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2349. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2350. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2351. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2352. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  2353. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  2354. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  2355. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2356. /// <param name="source1">First observable source.</param>
  2357. /// <param name="source2">Second observable source.</param>
  2358. /// <param name="source3">Third observable source.</param>
  2359. /// <param name="source4">Fourth observable source.</param>
  2360. /// <param name="source5">Fifth observable source.</param>
  2361. /// <param name="source6">Sixth observable source.</param>
  2362. /// <param name="source7">Seventh observable source.</param>
  2363. /// <param name="source8">Eighth observable source.</param>
  2364. /// <param name="source9">Ninth observable source.</param>
  2365. /// <param name="source10">Tenth observable source.</param>
  2366. /// <param name="source11">Eleventh observable source.</param>
  2367. /// <param name="source12">Twelfth observable source.</param>
  2368. /// <param name="source13">Thirteenth observable source.</param>
  2369. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2370. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2371. /// <exception cref="T:System.ArgumentNullException">
  2372. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="source6" /> or <paramref name="source7" /> or <paramref name="source8" /> or <paramref name="source9" /> or <paramref name="source10" /> or <paramref name="source11" /> or <paramref name="source12" /> or <paramref name="source13" /> or <paramref name="resultSelector" /> is null.</exception>
  2373. public static IQbservable<TResult> CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, IObservable<TSource6> source6, IObservable<TSource7> source7, IObservable<TSource8> source8, IObservable<TSource9> source9, IObservable<TSource10> source10, IObservable<TSource11> source11, IObservable<TSource12> source12, IObservable<TSource13> source13, Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TResult>> resultSelector)
  2374. {
  2375. if (source1 == null)
  2376. throw new ArgumentNullException("source1");
  2377. if (source2 == null)
  2378. throw new ArgumentNullException("source2");
  2379. if (source3 == null)
  2380. throw new ArgumentNullException("source3");
  2381. if (source4 == null)
  2382. throw new ArgumentNullException("source4");
  2383. if (source5 == null)
  2384. throw new ArgumentNullException("source5");
  2385. if (source6 == null)
  2386. throw new ArgumentNullException("source6");
  2387. if (source7 == null)
  2388. throw new ArgumentNullException("source7");
  2389. if (source8 == null)
  2390. throw new ArgumentNullException("source8");
  2391. if (source9 == null)
  2392. throw new ArgumentNullException("source9");
  2393. if (source10 == null)
  2394. throw new ArgumentNullException("source10");
  2395. if (source11 == null)
  2396. throw new ArgumentNullException("source11");
  2397. if (source12 == null)
  2398. throw new ArgumentNullException("source12");
  2399. if (source13 == null)
  2400. throw new ArgumentNullException("source13");
  2401. if (resultSelector == null)
  2402. throw new ArgumentNullException("resultSelector");
  2403. return source1.Provider.CreateQuery<TResult>(
  2404. Expression.Call(
  2405. null,
  2406. #if CRIPPLED_REFLECTION
  2407. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(IObservable<TSource5>), default(IObservable<TSource6>), default(IObservable<TSource7>), default(IObservable<TSource8>), default(IObservable<TSource9>), default(IObservable<TSource10>), default(IObservable<TSource11>), default(IObservable<TSource12>), default(IObservable<TSource13>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TResult>>))),
  2408. #else
  2409. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TSource9), typeof(TSource10), typeof(TSource11), typeof(TSource12), typeof(TSource13), typeof(TResult)),
  2410. #endif
  2411. source1.Expression,
  2412. GetSourceExpression(source2),
  2413. GetSourceExpression(source3),
  2414. GetSourceExpression(source4),
  2415. GetSourceExpression(source5),
  2416. GetSourceExpression(source6),
  2417. GetSourceExpression(source7),
  2418. GetSourceExpression(source8),
  2419. GetSourceExpression(source9),
  2420. GetSourceExpression(source10),
  2421. GetSourceExpression(source11),
  2422. GetSourceExpression(source12),
  2423. GetSourceExpression(source13),
  2424. resultSelector
  2425. )
  2426. );
  2427. }
  2428. #endif
  2429. #if !NO_LARGEARITY
  2430. /// <summary>
  2431. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2432. /// </summary>
  2433. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2434. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2435. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2436. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2437. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2438. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2439. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2440. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2441. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2442. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2443. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  2444. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  2445. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  2446. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  2447. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2448. /// <param name="source1">First observable source.</param>
  2449. /// <param name="source2">Second observable source.</param>
  2450. /// <param name="source3">Third observable source.</param>
  2451. /// <param name="source4">Fourth observable source.</param>
  2452. /// <param name="source5">Fifth observable source.</param>
  2453. /// <param name="source6">Sixth observable source.</param>
  2454. /// <param name="source7">Seventh observable source.</param>
  2455. /// <param name="source8">Eighth observable source.</param>
  2456. /// <param name="source9">Ninth observable source.</param>
  2457. /// <param name="source10">Tenth observable source.</param>
  2458. /// <param name="source11">Eleventh observable source.</param>
  2459. /// <param name="source12">Twelfth observable source.</param>
  2460. /// <param name="source13">Thirteenth observable source.</param>
  2461. /// <param name="source14">Fourteenth observable source.</param>
  2462. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2463. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2464. /// <exception cref="T:System.ArgumentNullException">
  2465. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="source6" /> or <paramref name="source7" /> or <paramref name="source8" /> or <paramref name="source9" /> or <paramref name="source10" /> or <paramref name="source11" /> or <paramref name="source12" /> or <paramref name="source13" /> or <paramref name="source14" /> or <paramref name="resultSelector" /> is null.</exception>
  2466. public static IQbservable<TResult> CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, IObservable<TSource6> source6, IObservable<TSource7> source7, IObservable<TSource8> source8, IObservable<TSource9> source9, IObservable<TSource10> source10, IObservable<TSource11> source11, IObservable<TSource12> source12, IObservable<TSource13> source13, IObservable<TSource14> source14, Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TResult>> resultSelector)
  2467. {
  2468. if (source1 == null)
  2469. throw new ArgumentNullException("source1");
  2470. if (source2 == null)
  2471. throw new ArgumentNullException("source2");
  2472. if (source3 == null)
  2473. throw new ArgumentNullException("source3");
  2474. if (source4 == null)
  2475. throw new ArgumentNullException("source4");
  2476. if (source5 == null)
  2477. throw new ArgumentNullException("source5");
  2478. if (source6 == null)
  2479. throw new ArgumentNullException("source6");
  2480. if (source7 == null)
  2481. throw new ArgumentNullException("source7");
  2482. if (source8 == null)
  2483. throw new ArgumentNullException("source8");
  2484. if (source9 == null)
  2485. throw new ArgumentNullException("source9");
  2486. if (source10 == null)
  2487. throw new ArgumentNullException("source10");
  2488. if (source11 == null)
  2489. throw new ArgumentNullException("source11");
  2490. if (source12 == null)
  2491. throw new ArgumentNullException("source12");
  2492. if (source13 == null)
  2493. throw new ArgumentNullException("source13");
  2494. if (source14 == null)
  2495. throw new ArgumentNullException("source14");
  2496. if (resultSelector == null)
  2497. throw new ArgumentNullException("resultSelector");
  2498. return source1.Provider.CreateQuery<TResult>(
  2499. Expression.Call(
  2500. null,
  2501. #if CRIPPLED_REFLECTION
  2502. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(IObservable<TSource5>), default(IObservable<TSource6>), default(IObservable<TSource7>), default(IObservable<TSource8>), default(IObservable<TSource9>), default(IObservable<TSource10>), default(IObservable<TSource11>), default(IObservable<TSource12>), default(IObservable<TSource13>), default(IObservable<TSource14>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TResult>>))),
  2503. #else
  2504. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TSource9), typeof(TSource10), typeof(TSource11), typeof(TSource12), typeof(TSource13), typeof(TSource14), typeof(TResult)),
  2505. #endif
  2506. source1.Expression,
  2507. GetSourceExpression(source2),
  2508. GetSourceExpression(source3),
  2509. GetSourceExpression(source4),
  2510. GetSourceExpression(source5),
  2511. GetSourceExpression(source6),
  2512. GetSourceExpression(source7),
  2513. GetSourceExpression(source8),
  2514. GetSourceExpression(source9),
  2515. GetSourceExpression(source10),
  2516. GetSourceExpression(source11),
  2517. GetSourceExpression(source12),
  2518. GetSourceExpression(source13),
  2519. GetSourceExpression(source14),
  2520. resultSelector
  2521. )
  2522. );
  2523. }
  2524. #endif
  2525. #if !NO_LARGEARITY
  2526. /// <summary>
  2527. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2528. /// </summary>
  2529. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2530. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2531. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2532. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2533. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2534. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2535. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2536. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2537. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2538. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2539. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  2540. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  2541. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  2542. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  2543. /// <typeparam name="TSource15">The type of the elements in the fifteenth source sequence.</typeparam>
  2544. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2545. /// <param name="source1">First observable source.</param>
  2546. /// <param name="source2">Second observable source.</param>
  2547. /// <param name="source3">Third observable source.</param>
  2548. /// <param name="source4">Fourth observable source.</param>
  2549. /// <param name="source5">Fifth observable source.</param>
  2550. /// <param name="source6">Sixth observable source.</param>
  2551. /// <param name="source7">Seventh observable source.</param>
  2552. /// <param name="source8">Eighth observable source.</param>
  2553. /// <param name="source9">Ninth observable source.</param>
  2554. /// <param name="source10">Tenth observable source.</param>
  2555. /// <param name="source11">Eleventh observable source.</param>
  2556. /// <param name="source12">Twelfth observable source.</param>
  2557. /// <param name="source13">Thirteenth observable source.</param>
  2558. /// <param name="source14">Fourteenth observable source.</param>
  2559. /// <param name="source15">Fifteenth observable source.</param>
  2560. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2561. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2562. /// <exception cref="T:System.ArgumentNullException">
  2563. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="source6" /> or <paramref name="source7" /> or <paramref name="source8" /> or <paramref name="source9" /> or <paramref name="source10" /> or <paramref name="source11" /> or <paramref name="source12" /> or <paramref name="source13" /> or <paramref name="source14" /> or <paramref name="source15" /> or <paramref name="resultSelector" /> is null.</exception>
  2564. public static IQbservable<TResult> CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, IObservable<TSource6> source6, IObservable<TSource7> source7, IObservable<TSource8> source8, IObservable<TSource9> source9, IObservable<TSource10> source10, IObservable<TSource11> source11, IObservable<TSource12> source12, IObservable<TSource13> source13, IObservable<TSource14> source14, IObservable<TSource15> source15, Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15, TResult>> resultSelector)
  2565. {
  2566. if (source1 == null)
  2567. throw new ArgumentNullException("source1");
  2568. if (source2 == null)
  2569. throw new ArgumentNullException("source2");
  2570. if (source3 == null)
  2571. throw new ArgumentNullException("source3");
  2572. if (source4 == null)
  2573. throw new ArgumentNullException("source4");
  2574. if (source5 == null)
  2575. throw new ArgumentNullException("source5");
  2576. if (source6 == null)
  2577. throw new ArgumentNullException("source6");
  2578. if (source7 == null)
  2579. throw new ArgumentNullException("source7");
  2580. if (source8 == null)
  2581. throw new ArgumentNullException("source8");
  2582. if (source9 == null)
  2583. throw new ArgumentNullException("source9");
  2584. if (source10 == null)
  2585. throw new ArgumentNullException("source10");
  2586. if (source11 == null)
  2587. throw new ArgumentNullException("source11");
  2588. if (source12 == null)
  2589. throw new ArgumentNullException("source12");
  2590. if (source13 == null)
  2591. throw new ArgumentNullException("source13");
  2592. if (source14 == null)
  2593. throw new ArgumentNullException("source14");
  2594. if (source15 == null)
  2595. throw new ArgumentNullException("source15");
  2596. if (resultSelector == null)
  2597. throw new ArgumentNullException("resultSelector");
  2598. return source1.Provider.CreateQuery<TResult>(
  2599. Expression.Call(
  2600. null,
  2601. #if CRIPPLED_REFLECTION
  2602. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(IObservable<TSource5>), default(IObservable<TSource6>), default(IObservable<TSource7>), default(IObservable<TSource8>), default(IObservable<TSource9>), default(IObservable<TSource10>), default(IObservable<TSource11>), default(IObservable<TSource12>), default(IObservable<TSource13>), default(IObservable<TSource14>), default(IObservable<TSource15>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15, TResult>>))),
  2603. #else
  2604. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TSource9), typeof(TSource10), typeof(TSource11), typeof(TSource12), typeof(TSource13), typeof(TSource14), typeof(TSource15), typeof(TResult)),
  2605. #endif
  2606. source1.Expression,
  2607. GetSourceExpression(source2),
  2608. GetSourceExpression(source3),
  2609. GetSourceExpression(source4),
  2610. GetSourceExpression(source5),
  2611. GetSourceExpression(source6),
  2612. GetSourceExpression(source7),
  2613. GetSourceExpression(source8),
  2614. GetSourceExpression(source9),
  2615. GetSourceExpression(source10),
  2616. GetSourceExpression(source11),
  2617. GetSourceExpression(source12),
  2618. GetSourceExpression(source13),
  2619. GetSourceExpression(source14),
  2620. GetSourceExpression(source15),
  2621. resultSelector
  2622. )
  2623. );
  2624. }
  2625. #endif
  2626. #if !NO_LARGEARITY
  2627. /// <summary>
  2628. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2629. /// </summary>
  2630. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2631. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2632. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2633. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2634. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2635. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2636. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2637. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2638. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2639. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2640. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  2641. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  2642. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  2643. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  2644. /// <typeparam name="TSource15">The type of the elements in the fifteenth source sequence.</typeparam>
  2645. /// <typeparam name="TSource16">The type of the elements in the sixteenth source sequence.</typeparam>
  2646. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2647. /// <param name="source1">First observable source.</param>
  2648. /// <param name="source2">Second observable source.</param>
  2649. /// <param name="source3">Third observable source.</param>
  2650. /// <param name="source4">Fourth observable source.</param>
  2651. /// <param name="source5">Fifth observable source.</param>
  2652. /// <param name="source6">Sixth observable source.</param>
  2653. /// <param name="source7">Seventh observable source.</param>
  2654. /// <param name="source8">Eighth observable source.</param>
  2655. /// <param name="source9">Ninth observable source.</param>
  2656. /// <param name="source10">Tenth observable source.</param>
  2657. /// <param name="source11">Eleventh observable source.</param>
  2658. /// <param name="source12">Twelfth observable source.</param>
  2659. /// <param name="source13">Thirteenth observable source.</param>
  2660. /// <param name="source14">Fourteenth observable source.</param>
  2661. /// <param name="source15">Fifteenth observable source.</param>
  2662. /// <param name="source16">Sixteenth observable source.</param>
  2663. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2664. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2665. /// <exception cref="T:System.ArgumentNullException">
  2666. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="source6" /> or <paramref name="source7" /> or <paramref name="source8" /> or <paramref name="source9" /> or <paramref name="source10" /> or <paramref name="source11" /> or <paramref name="source12" /> or <paramref name="source13" /> or <paramref name="source14" /> or <paramref name="source15" /> or <paramref name="source16" /> or <paramref name="resultSelector" /> is null.</exception>
  2667. public static IQbservable<TResult> CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15, TSource16, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, IObservable<TSource6> source6, IObservable<TSource7> source7, IObservable<TSource8> source8, IObservable<TSource9> source9, IObservable<TSource10> source10, IObservable<TSource11> source11, IObservable<TSource12> source12, IObservable<TSource13> source13, IObservable<TSource14> source14, IObservable<TSource15> source15, IObservable<TSource16> source16, Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15, TSource16, TResult>> resultSelector)
  2668. {
  2669. if (source1 == null)
  2670. throw new ArgumentNullException("source1");
  2671. if (source2 == null)
  2672. throw new ArgumentNullException("source2");
  2673. if (source3 == null)
  2674. throw new ArgumentNullException("source3");
  2675. if (source4 == null)
  2676. throw new ArgumentNullException("source4");
  2677. if (source5 == null)
  2678. throw new ArgumentNullException("source5");
  2679. if (source6 == null)
  2680. throw new ArgumentNullException("source6");
  2681. if (source7 == null)
  2682. throw new ArgumentNullException("source7");
  2683. if (source8 == null)
  2684. throw new ArgumentNullException("source8");
  2685. if (source9 == null)
  2686. throw new ArgumentNullException("source9");
  2687. if (source10 == null)
  2688. throw new ArgumentNullException("source10");
  2689. if (source11 == null)
  2690. throw new ArgumentNullException("source11");
  2691. if (source12 == null)
  2692. throw new ArgumentNullException("source12");
  2693. if (source13 == null)
  2694. throw new ArgumentNullException("source13");
  2695. if (source14 == null)
  2696. throw new ArgumentNullException("source14");
  2697. if (source15 == null)
  2698. throw new ArgumentNullException("source15");
  2699. if (source16 == null)
  2700. throw new ArgumentNullException("source16");
  2701. if (resultSelector == null)
  2702. throw new ArgumentNullException("resultSelector");
  2703. return source1.Provider.CreateQuery<TResult>(
  2704. Expression.Call(
  2705. null,
  2706. #if CRIPPLED_REFLECTION
  2707. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15, TSource16, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(IObservable<TSource5>), default(IObservable<TSource6>), default(IObservable<TSource7>), default(IObservable<TSource8>), default(IObservable<TSource9>), default(IObservable<TSource10>), default(IObservable<TSource11>), default(IObservable<TSource12>), default(IObservable<TSource13>), default(IObservable<TSource14>), default(IObservable<TSource15>), default(IObservable<TSource16>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15, TSource16, TResult>>))),
  2708. #else
  2709. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TSource9), typeof(TSource10), typeof(TSource11), typeof(TSource12), typeof(TSource13), typeof(TSource14), typeof(TSource15), typeof(TSource16), typeof(TResult)),
  2710. #endif
  2711. source1.Expression,
  2712. GetSourceExpression(source2),
  2713. GetSourceExpression(source3),
  2714. GetSourceExpression(source4),
  2715. GetSourceExpression(source5),
  2716. GetSourceExpression(source6),
  2717. GetSourceExpression(source7),
  2718. GetSourceExpression(source8),
  2719. GetSourceExpression(source9),
  2720. GetSourceExpression(source10),
  2721. GetSourceExpression(source11),
  2722. GetSourceExpression(source12),
  2723. GetSourceExpression(source13),
  2724. GetSourceExpression(source14),
  2725. GetSourceExpression(source15),
  2726. GetSourceExpression(source16),
  2727. resultSelector
  2728. )
  2729. );
  2730. }
  2731. #endif
  2732. /// <summary>
  2733. /// Concatenates the second observable sequence to the first observable sequence upon successful termination of the first.
  2734. /// </summary>
  2735. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  2736. /// <param name="first">First observable sequence.</param>
  2737. /// <param name="second">Second observable sequence.</param>
  2738. /// <returns>An observable sequence that contains the elements of the first sequence, followed by those of the second the sequence.</returns>
  2739. /// <exception cref="T:System.ArgumentNullException">
  2740. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  2741. public static IQbservable<TSource> Concat<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  2742. {
  2743. if (first == null)
  2744. throw new ArgumentNullException("first");
  2745. if (second == null)
  2746. throw new ArgumentNullException("second");
  2747. return first.Provider.CreateQuery<TSource>(
  2748. Expression.Call(
  2749. null,
  2750. #if CRIPPLED_REFLECTION
  2751. InfoOf(() => Qbservable.Concat<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  2752. #else
  2753. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2754. #endif
  2755. first.Expression,
  2756. GetSourceExpression(second)
  2757. )
  2758. );
  2759. }
  2760. /// <summary>
  2761. /// Concatenates all of the specified observable sequences, as long as the previous observable sequence terminated successfully.
  2762. /// </summary>
  2763. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  2764. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  2765. /// <param name="sources">Observable sequences to concatenate.</param>
  2766. /// <returns>An observable sequence that contains the elements of each given sequence, in sequential order.</returns>
  2767. /// <exception cref="T:System.ArgumentNullException">
  2768. /// <paramref name="sources" /> is null.</exception>
  2769. public static IQbservable<TSource> Concat<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  2770. {
  2771. if (provider == null)
  2772. throw new ArgumentNullException("provider");
  2773. if (sources == null)
  2774. throw new ArgumentNullException("sources");
  2775. return provider.CreateQuery<TSource>(
  2776. Expression.Call(
  2777. null,
  2778. #if CRIPPLED_REFLECTION
  2779. InfoOf(() => Qbservable.Concat<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  2780. #else
  2781. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2782. #endif
  2783. Expression.Constant(provider, typeof(IQbservableProvider)),
  2784. GetSourceExpression(sources)
  2785. )
  2786. );
  2787. }
  2788. /// <summary>
  2789. /// Concatenates all observable sequences in the given enumerable sequence, as long as the previous observable sequence terminated successfully.
  2790. /// </summary>
  2791. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  2792. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  2793. /// <param name="sources">Observable sequences to concatenate.</param>
  2794. /// <returns>An observable sequence that contains the elements of each given sequence, in sequential order.</returns>
  2795. /// <exception cref="T:System.ArgumentNullException">
  2796. /// <paramref name="sources" /> is null.</exception>
  2797. public static IQbservable<TSource> Concat<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  2798. {
  2799. if (provider == null)
  2800. throw new ArgumentNullException("provider");
  2801. if (sources == null)
  2802. throw new ArgumentNullException("sources");
  2803. return provider.CreateQuery<TSource>(
  2804. Expression.Call(
  2805. null,
  2806. #if CRIPPLED_REFLECTION
  2807. InfoOf(() => Qbservable.Concat<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  2808. #else
  2809. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2810. #endif
  2811. Expression.Constant(provider, typeof(IQbservableProvider)),
  2812. GetSourceExpression(sources)
  2813. )
  2814. );
  2815. }
  2816. /// <summary>
  2817. /// Concatenates all inner observable sequences, as long as the previous observable sequence terminated successfully.
  2818. /// </summary>
  2819. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  2820. /// <param name="sources">Observable sequence of inner observable sequences.</param>
  2821. /// <returns>An observable sequence that contains the elements of each observed inner sequence, in sequential order.</returns>
  2822. /// <exception cref="T:System.ArgumentNullException">
  2823. /// <paramref name="sources" /> is null.</exception>
  2824. public static IQbservable<TSource> Concat<TSource>(this IQbservable<IObservable<TSource>> sources)
  2825. {
  2826. if (sources == null)
  2827. throw new ArgumentNullException("sources");
  2828. return sources.Provider.CreateQuery<TSource>(
  2829. Expression.Call(
  2830. null,
  2831. #if CRIPPLED_REFLECTION
  2832. InfoOf(() => Qbservable.Concat<TSource>(default(IQbservable<IObservable<TSource>>))),
  2833. #else
  2834. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2835. #endif
  2836. sources.Expression
  2837. )
  2838. );
  2839. }
  2840. #if !NO_TPL
  2841. /// <summary>
  2842. /// Concatenates all task results, as long as the previous task terminated successfully.
  2843. /// </summary>
  2844. /// <typeparam name="TSource">The type of the results produced by the tasks.</typeparam>
  2845. /// <param name="sources">Observable sequence of tasks.</param>
  2846. /// <returns>An observable sequence that contains the results of each task, in sequential order.</returns>
  2847. /// <exception cref="T:System.ArgumentNullException">
  2848. /// <paramref name="sources" /> is null.</exception>
  2849. /// <remarks>If the tasks support cancellation, consider manual conversion of the tasks using <see cref="M:System.Reactive.Linq.Observable.FromAsync``1(System.Func{System.Threading.CancellationToken,System.Threading.Tasks.Task{``0}})" />, followed by a concatenation operation using <see cref="M:System.Reactive.Linq.Observable.Concat``1(System.IObservable{System.IObservable{``0}})" />.</remarks>
  2850. public static IQbservable<TSource> Concat<TSource>(this IQbservable<Task<TSource>> sources)
  2851. {
  2852. if (sources == null)
  2853. throw new ArgumentNullException("sources");
  2854. return sources.Provider.CreateQuery<TSource>(
  2855. Expression.Call(
  2856. null,
  2857. #if CRIPPLED_REFLECTION
  2858. InfoOf(() => Qbservable.Concat<TSource>(default(IQbservable<Task<TSource>>))),
  2859. #else
  2860. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2861. #endif
  2862. sources.Expression
  2863. )
  2864. );
  2865. }
  2866. #endif
  2867. /// <summary>
  2868. /// Determines whether an observable sequence contains a specified element by using the default equality comparer.
  2869. /// </summary>
  2870. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  2871. /// <param name="source">An observable sequence in which to locate a value.</param>
  2872. /// <param name="value">The value to locate in the source sequence.</param>
  2873. /// <returns>An observable sequence containing a single element determining whether the source sequence contains an element that has the specified value.</returns>
  2874. /// <exception cref="T:System.ArgumentNullException">
  2875. /// <paramref name="source" /> is null.</exception>
  2876. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  2877. public static IQbservable<bool> Contains<TSource>(this IQbservable<TSource> source, TSource value)
  2878. {
  2879. if (source == null)
  2880. throw new ArgumentNullException("source");
  2881. return source.Provider.CreateQuery<bool>(
  2882. Expression.Call(
  2883. null,
  2884. #if CRIPPLED_REFLECTION
  2885. InfoOf(() => Qbservable.Contains<TSource>(default(IQbservable<TSource>), default(TSource))),
  2886. #else
  2887. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2888. #endif
  2889. source.Expression,
  2890. Expression.Constant(value, typeof(TSource))
  2891. )
  2892. );
  2893. }
  2894. /// <summary>
  2895. /// Determines whether an observable sequence contains a specified element by using a specified System.Collections.Generic.IEqualityComparer&lt;T&gt;.
  2896. /// </summary>
  2897. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  2898. /// <param name="source">An observable sequence in which to locate a value.</param>
  2899. /// <param name="value">The value to locate in the source sequence.</param>
  2900. /// <param name="comparer">An equality comparer to compare elements.</param>
  2901. /// <returns>An observable sequence containing a single element determining whether the source sequence contains an element that has the specified value.</returns>
  2902. /// <exception cref="T:System.ArgumentNullException">
  2903. /// <paramref name="source" /> or <paramref name="comparer" /> is null.</exception>
  2904. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  2905. public static IQbservable<bool> Contains<TSource>(this IQbservable<TSource> source, TSource value, IEqualityComparer<TSource> comparer)
  2906. {
  2907. if (source == null)
  2908. throw new ArgumentNullException("source");
  2909. if (comparer == null)
  2910. throw new ArgumentNullException("comparer");
  2911. return source.Provider.CreateQuery<bool>(
  2912. Expression.Call(
  2913. null,
  2914. #if CRIPPLED_REFLECTION
  2915. InfoOf(() => Qbservable.Contains<TSource>(default(IQbservable<TSource>), default(TSource), default(IEqualityComparer<TSource>))),
  2916. #else
  2917. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2918. #endif
  2919. source.Expression,
  2920. Expression.Constant(value, typeof(TSource)),
  2921. Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))
  2922. )
  2923. );
  2924. }
  2925. /// <summary>
  2926. /// Returns an observable sequence containing an <see cref="T:System.Int32" /> that represents the total number of elements in an observable sequence.
  2927. /// </summary>
  2928. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  2929. /// <param name="source">An observable sequence that contains elements to be counted.</param>
  2930. /// <returns>An observable sequence containing a single element with the number of elements in the input sequence.</returns>
  2931. /// <exception cref="T:System.ArgumentNullException">
  2932. /// <paramref name="source" /> is null.</exception>
  2933. /// <exception cref="T:System.OverflowException">(Asynchronous) The number of elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue" />.</exception>
  2934. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  2935. public static IQbservable<int> Count<TSource>(this IQbservable<TSource> source)
  2936. {
  2937. if (source == null)
  2938. throw new ArgumentNullException("source");
  2939. return source.Provider.CreateQuery<int>(
  2940. Expression.Call(
  2941. null,
  2942. #if CRIPPLED_REFLECTION
  2943. InfoOf(() => Qbservable.Count<TSource>(default(IQbservable<TSource>))),
  2944. #else
  2945. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2946. #endif
  2947. source.Expression
  2948. )
  2949. );
  2950. }
  2951. /// <summary>
  2952. /// Returns an observable sequence containing an <see cref="T:System.Int32" /> that represents how many elements in the specified observable sequence satisfy a condition.
  2953. /// </summary>
  2954. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  2955. /// <param name="source">An observable sequence that contains elements to be counted.</param>
  2956. /// <param name="predicate">A function to test each element for a condition.</param>
  2957. /// <returns>An observable sequence containing a single element with a number that represents how many elements in the input sequence satisfy the condition in the predicate function.</returns>
  2958. /// <exception cref="T:System.ArgumentNullException">
  2959. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  2960. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  2961. public static IQbservable<int> Count<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  2962. {
  2963. if (source == null)
  2964. throw new ArgumentNullException("source");
  2965. if (predicate == null)
  2966. throw new ArgumentNullException("predicate");
  2967. return source.Provider.CreateQuery<int>(
  2968. Expression.Call(
  2969. null,
  2970. #if CRIPPLED_REFLECTION
  2971. InfoOf(() => Qbservable.Count<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  2972. #else
  2973. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2974. #endif
  2975. source.Expression,
  2976. predicate
  2977. )
  2978. );
  2979. }
  2980. /// <summary>
  2981. /// Creates an observable sequence from a specified Subscribe method implementation.
  2982. /// </summary>
  2983. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  2984. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  2985. /// <param name="subscribe">Implementation of the resulting observable sequence's Subscribe method.</param>
  2986. /// <returns>The observable sequence with the specified implementation for the Subscribe method.</returns>
  2987. /// <exception cref="T:System.ArgumentNullException">
  2988. /// <paramref name="subscribe" /> is null.</exception>
  2989. /// <remarks>
  2990. /// Use of this operator is preferred over manual implementation of the IObservable&lt;T&gt; interface. In case
  2991. /// you need a type implementing IObservable&lt;T&gt; rather than an anonymous implementation, consider using
  2992. /// the <see cref="T:System.Reactive.ObservableBase`1" /> abstract base class.
  2993. /// </remarks>
  2994. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, IDisposable>> subscribe)
  2995. {
  2996. if (provider == null)
  2997. throw new ArgumentNullException("provider");
  2998. if (subscribe == null)
  2999. throw new ArgumentNullException("subscribe");
  3000. return provider.CreateQuery<TResult>(
  3001. Expression.Call(
  3002. null,
  3003. #if CRIPPLED_REFLECTION
  3004. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, IDisposable>>))),
  3005. #else
  3006. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3007. #endif
  3008. Expression.Constant(provider, typeof(IQbservableProvider)),
  3009. subscribe
  3010. )
  3011. );
  3012. }
  3013. /// <summary>
  3014. /// Creates an observable sequence from a specified Subscribe method implementation.
  3015. /// </summary>
  3016. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  3017. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3018. /// <param name="subscribe">Implementation of the resulting observable sequence's Subscribe method, returning an Action delegate that will be wrapped in an IDisposable.</param>
  3019. /// <returns>The observable sequence with the specified implementation for the Subscribe method.</returns>
  3020. /// <exception cref="T:System.ArgumentNullException">
  3021. /// <paramref name="subscribe" /> is null.</exception>
  3022. /// <remarks>
  3023. /// Use of this operator is preferred over manual implementation of the IObservable&lt;T&gt; interface. In case
  3024. /// you need a type implementing IObservable&lt;T&gt; rather than an anonymous implementation, consider using
  3025. /// the <see cref="T:System.Reactive.ObservableBase`1" /> abstract base class.
  3026. /// </remarks>
  3027. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, Action>> subscribe)
  3028. {
  3029. if (provider == null)
  3030. throw new ArgumentNullException("provider");
  3031. if (subscribe == null)
  3032. throw new ArgumentNullException("subscribe");
  3033. return provider.CreateQuery<TResult>(
  3034. Expression.Call(
  3035. null,
  3036. #if CRIPPLED_REFLECTION
  3037. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, Action>>))),
  3038. #else
  3039. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3040. #endif
  3041. Expression.Constant(provider, typeof(IQbservableProvider)),
  3042. subscribe
  3043. )
  3044. );
  3045. }
  3046. #if !NO_TPL
  3047. /// <summary>
  3048. /// Creates an observable sequence from a specified cancellable asynchronous Subscribe method.
  3049. /// The CancellationToken passed to the asynchronous Subscribe method is tied to the returned disposable subscription, allowing best-effort cancellation.
  3050. /// </summary>
  3051. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  3052. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3053. /// <param name="subscribeAsync">Asynchronous method used to produce elements.</param>
  3054. /// <returns>The observable sequence surfacing the elements produced by the asynchronous method.</returns>
  3055. /// <exception cref="T:System.ArgumentNullException">
  3056. /// <paramref name="subscribeAsync" /> is null.</exception>
  3057. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3058. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous subscribe function will be signaled.</remarks>
  3059. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, CancellationToken, Task>> subscribeAsync)
  3060. {
  3061. if (provider == null)
  3062. throw new ArgumentNullException("provider");
  3063. if (subscribeAsync == null)
  3064. throw new ArgumentNullException("subscribeAsync");
  3065. return provider.CreateQuery<TResult>(
  3066. Expression.Call(
  3067. null,
  3068. #if CRIPPLED_REFLECTION
  3069. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, CancellationToken, Task>>))),
  3070. #else
  3071. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3072. #endif
  3073. Expression.Constant(provider, typeof(IQbservableProvider)),
  3074. subscribeAsync
  3075. )
  3076. );
  3077. }
  3078. #endif
  3079. #if !NO_TPL
  3080. /// <summary>
  3081. /// Creates an observable sequence from a specified asynchronous Subscribe method.
  3082. /// </summary>
  3083. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  3084. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3085. /// <param name="subscribeAsync">Asynchronous method used to produce elements.</param>
  3086. /// <returns>The observable sequence surfacing the elements produced by the asynchronous method.</returns>
  3087. /// <exception cref="T:System.ArgumentNullException">
  3088. /// <paramref name="subscribeAsync" /> is null.</exception>
  3089. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3090. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, Task>> subscribeAsync)
  3091. {
  3092. if (provider == null)
  3093. throw new ArgumentNullException("provider");
  3094. if (subscribeAsync == null)
  3095. throw new ArgumentNullException("subscribeAsync");
  3096. return provider.CreateQuery<TResult>(
  3097. Expression.Call(
  3098. null,
  3099. #if CRIPPLED_REFLECTION
  3100. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, Task>>))),
  3101. #else
  3102. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3103. #endif
  3104. Expression.Constant(provider, typeof(IQbservableProvider)),
  3105. subscribeAsync
  3106. )
  3107. );
  3108. }
  3109. #endif
  3110. #if !NO_TPL
  3111. /// <summary>
  3112. /// Creates an observable sequence from a specified cancellable asynchronous Subscribe method.
  3113. /// The CancellationToken passed to the asynchronous Subscribe method is tied to the returned disposable subscription, allowing best-effort cancellation.
  3114. /// </summary>
  3115. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  3116. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3117. /// <param name="subscribeAsync">Asynchronous method used to 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. /// The CancellationToken passed to the asynchronous action is tied to the observable sequence's subscription that triggered the action's invocation and can be used for best-effort cancellation.
  4567. /// </summary>
  4568. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  4569. /// <param name="actionAsync">Asynchronous action to convert.</param>
  4570. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  4571. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous function will be signaled.</remarks>
  4572. /// <exception cref="T:System.ArgumentNullException">
  4573. /// <paramref name="actionAsync" /> is null.</exception>
  4574. public static IQbservable<Unit> FromAsync(this IQbservableProvider provider, Expression<Func<CancellationToken, Task>> actionAsync)
  4575. {
  4576. if (provider == null)
  4577. throw new ArgumentNullException("provider");
  4578. if (actionAsync == null)
  4579. throw new ArgumentNullException("actionAsync");
  4580. return provider.CreateQuery<Unit>(
  4581. Expression.Call(
  4582. null,
  4583. #if CRIPPLED_REFLECTION
  4584. InfoOf(() => Qbservable.FromAsync(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task>>))),
  4585. #else
  4586. (MethodInfo)MethodInfo.GetCurrentMethod(),
  4587. #endif
  4588. Expression.Constant(provider, typeof(IQbservableProvider)),
  4589. actionAsync
  4590. )
  4591. );
  4592. }
  4593. #endif
  4594. #if !NO_TPL
  4595. /// <summary>
  4596. /// Converts to asynchronous function into an observable sequence. Each subscription to the resulting sequence causes the function to be started.
  4597. /// </summary>
  4598. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  4599. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  4600. /// <param name="functionAsync">Asynchronous function to convert.</param>
  4601. /// <returns>An observable sequence exposing the result of invoking the function, or an exception.</returns>
  4602. /// <exception cref="T:System.ArgumentNullException">
  4603. /// <paramref name="functionAsync" /> is null.</exception>
  4604. public static IQbservable<TResult> FromAsync<TResult>(this IQbservableProvider provider, Expression<Func<Task<TResult>>> functionAsync)
  4605. {
  4606. if (provider == null)
  4607. throw new ArgumentNullException("provider");
  4608. if (functionAsync == null)
  4609. throw new ArgumentNullException("functionAsync");
  4610. return provider.CreateQuery<TResult>(
  4611. Expression.Call(
  4612. null,
  4613. #if CRIPPLED_REFLECTION
  4614. InfoOf(() => Qbservable.FromAsync<TResult>(default(IQbservableProvider), default(Expression<Func<Task<TResult>>>))),
  4615. #else
  4616. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4617. #endif
  4618. Expression.Constant(provider, typeof(IQbservableProvider)),
  4619. functionAsync
  4620. )
  4621. );
  4622. }
  4623. #endif
  4624. #if !NO_TPL
  4625. /// <summary>
  4626. /// Converts to asynchronous function into an observable sequence. Each subscription to the resulting sequence causes the function to be started.
  4627. /// The CancellationToken passed to the asynchronous function is tied to the observable sequence's subscription that triggered the function's invocation and can be used for best-effort cancellation.
  4628. /// </summary>
  4629. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  4630. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  4631. /// <param name="functionAsync">Asynchronous function to convert.</param>
  4632. /// <returns>An observable sequence exposing the result of invoking the function, or an exception.</returns>
  4633. /// <exception cref="T:System.ArgumentNullException">
  4634. /// <paramref name="functionAsync" /> is null.</exception>
  4635. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous function will be signaled.</remarks>
  4636. public static IQbservable<TResult> FromAsync<TResult>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<TResult>>> functionAsync)
  4637. {
  4638. if (provider == null)
  4639. throw new ArgumentNullException("provider");
  4640. if (functionAsync == null)
  4641. throw new ArgumentNullException("functionAsync");
  4642. return provider.CreateQuery<TResult>(
  4643. Expression.Call(
  4644. null,
  4645. #if CRIPPLED_REFLECTION
  4646. InfoOf(() => Qbservable.FromAsync<TResult>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<TResult>>>))),
  4647. #else
  4648. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4649. #endif
  4650. Expression.Constant(provider, typeof(IQbservableProvider)),
  4651. functionAsync
  4652. )
  4653. );
  4654. }
  4655. #endif
  4656. /// <summary>
  4657. /// Converts an Action-based .NET event to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence.
  4658. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  4659. /// </summary>
  4660. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  4661. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  4662. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  4663. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  4664. /// <exception cref="T:System.ArgumentNullException">
  4665. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  4666. /// <remarks>
  4667. /// <para>
  4668. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  4669. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  4670. /// </para>
  4671. /// <para>
  4672. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEvent, and is used to post add and remove handler invocations.
  4673. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  4674. /// </para>
  4675. /// <para>
  4676. /// If no SynchronizationContext is present at the point of calling FromEvent, add and remove handler invocations are made synchronously on the thread
  4677. /// making the Subscribe or Dispose call, respectively.
  4678. /// </para>
  4679. /// <para>
  4680. /// It's recommended to lift FromEvent calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  4681. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  4682. /// more concise and easier to understand.
  4683. /// </para>
  4684. /// </remarks>
  4685. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  4686. public static IQbservable<Unit> FromEvent(this IQbservableProvider provider, Expression<Action<Action>> addHandler, Expression<Action<Action>> removeHandler)
  4687. {
  4688. if (provider == null)
  4689. throw new ArgumentNullException("provider");
  4690. if (addHandler == null)
  4691. throw new ArgumentNullException("addHandler");
  4692. if (removeHandler == null)
  4693. throw new ArgumentNullException("removeHandler");
  4694. return provider.CreateQuery<Unit>(
  4695. Expression.Call(
  4696. null,
  4697. #if CRIPPLED_REFLECTION
  4698. InfoOf(() => Qbservable.FromEvent(default(IQbservableProvider), default(Expression<Action<Action>>), default(Expression<Action<Action>>))),
  4699. #else
  4700. (MethodInfo)MethodInfo.GetCurrentMethod(),
  4701. #endif
  4702. Expression.Constant(provider, typeof(IQbservableProvider)),
  4703. addHandler,
  4704. removeHandler
  4705. )
  4706. );
  4707. }
  4708. /// <summary>
  4709. /// Converts an Action-based .NET event to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence.
  4710. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  4711. /// </summary>
  4712. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  4713. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  4714. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  4715. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  4716. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  4717. /// <exception cref="T:System.ArgumentNullException">
  4718. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  4719. /// <remarks>
  4720. /// <para>
  4721. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  4722. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  4723. /// </para>
  4724. /// <para>
  4725. /// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be
  4726. /// accessed from the same context, as required by some UI frameworks.
  4727. /// </para>
  4728. /// <para>
  4729. /// It's recommended to lift FromEvent calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  4730. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEvent that omit the IScheduler
  4731. /// parameter. For more information, see the remarks section on those overloads.
  4732. /// </para>
  4733. /// </remarks>
  4734. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  4735. public static IQbservable<Unit> FromEvent(this IQbservableProvider provider, Expression<Action<Action>> addHandler, Expression<Action<Action>> removeHandler, IScheduler scheduler)
  4736. {
  4737. if (provider == null)
  4738. throw new ArgumentNullException("provider");
  4739. if (addHandler == null)
  4740. throw new ArgumentNullException("addHandler");
  4741. if (removeHandler == null)
  4742. throw new ArgumentNullException("removeHandler");
  4743. if (scheduler == null)
  4744. throw new ArgumentNullException("scheduler");
  4745. return provider.CreateQuery<Unit>(
  4746. Expression.Call(
  4747. null,
  4748. #if CRIPPLED_REFLECTION
  4749. InfoOf(() => Qbservable.FromEvent(default(IQbservableProvider), default(Expression<Action<Action>>), default(Expression<Action<Action>>), default(IScheduler))),
  4750. #else
  4751. (MethodInfo)MethodInfo.GetCurrentMethod(),
  4752. #endif
  4753. Expression.Constant(provider, typeof(IQbservableProvider)),
  4754. addHandler,
  4755. removeHandler,
  4756. Expression.Constant(scheduler, typeof(IScheduler))
  4757. )
  4758. );
  4759. }
  4760. /// <summary>
  4761. /// Converts a .NET event to an observable sequence, using a supplied event delegate type. Each event invocation is surfaced through an OnNext message in the resulting sequence.
  4762. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  4763. /// </summary>
  4764. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  4765. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  4766. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  4767. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  4768. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  4769. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  4770. /// <exception cref="T:System.ArgumentNullException">
  4771. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  4772. /// <remarks>
  4773. /// <para>
  4774. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  4775. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  4776. /// </para>
  4777. /// <para>
  4778. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEvent, and is used to post add and remove handler invocations.
  4779. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  4780. /// </para>
  4781. /// <para>
  4782. /// If no SynchronizationContext is present at the point of calling FromEvent, add and remove handler invocations are made synchronously on the thread
  4783. /// making the Subscribe or Dispose call, respectively.
  4784. /// </para>
  4785. /// <para>
  4786. /// It's recommended to lift FromEvent calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  4787. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  4788. /// more concise and easier to understand.
  4789. /// </para>
  4790. /// </remarks>
  4791. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  4792. public static IQbservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)
  4793. {
  4794. if (provider == null)
  4795. throw new ArgumentNullException("provider");
  4796. if (addHandler == null)
  4797. throw new ArgumentNullException("addHandler");
  4798. if (removeHandler == null)
  4799. throw new ArgumentNullException("removeHandler");
  4800. return provider.CreateQuery<TEventArgs>(
  4801. Expression.Call(
  4802. null,
  4803. #if CRIPPLED_REFLECTION
  4804. InfoOf(() => Qbservable.FromEvent<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>))),
  4805. #else
  4806. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  4807. #endif
  4808. Expression.Constant(provider, typeof(IQbservableProvider)),
  4809. addHandler,
  4810. removeHandler
  4811. )
  4812. );
  4813. }
  4814. /// <summary>
  4815. /// Converts a .NET event to an observable sequence, using a supplied event delegate type. Each event invocation is surfaced through an OnNext message in the resulting sequence.
  4816. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  4817. /// </summary>
  4818. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  4819. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  4820. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  4821. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  4822. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  4823. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  4824. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  4825. /// <exception cref="T:System.ArgumentNullException">
  4826. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  4827. /// <remarks>
  4828. /// <para>
  4829. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  4830. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  4831. /// </para>
  4832. /// <para>
  4833. /// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be
  4834. /// accessed from the same context, as required by some UI frameworks.
  4835. /// </para>
  4836. /// <para>
  4837. /// It's recommended to lift FromEvent calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  4838. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEvent that omit the IScheduler
  4839. /// parameter. For more information, see the remarks section on those overloads.
  4840. /// </para>
  4841. /// </remarks>
  4842. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  4843. public static IQbservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler, IScheduler scheduler)
  4844. {
  4845. if (provider == null)
  4846. throw new ArgumentNullException("provider");
  4847. if (addHandler == null)
  4848. throw new ArgumentNullException("addHandler");
  4849. if (removeHandler == null)
  4850. throw new ArgumentNullException("removeHandler");
  4851. if (scheduler == null)
  4852. throw new ArgumentNullException("scheduler");
  4853. return provider.CreateQuery<TEventArgs>(
  4854. Expression.Call(
  4855. null,
  4856. #if CRIPPLED_REFLECTION
  4857. InfoOf(() => Qbservable.FromEvent<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>), default(IScheduler))),
  4858. #else
  4859. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  4860. #endif
  4861. Expression.Constant(provider, typeof(IQbservableProvider)),
  4862. addHandler,
  4863. removeHandler,
  4864. Expression.Constant(scheduler, typeof(IScheduler))
  4865. )
  4866. );
  4867. }
  4868. /// <summary>
  4869. /// Converts a .NET event to an observable sequence, using a conversion function to obtain the event delegate. Each event invocation is surfaced through an OnNext message in the resulting sequence.
  4870. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  4871. /// </summary>
  4872. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  4873. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  4874. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  4875. /// <param name="conversion">A function used to convert the given event handler to a delegate compatible with the underlying .NET event. The resulting delegate is used in calls to the addHandler and removeHandler action parameters.</param>
  4876. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  4877. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  4878. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  4879. /// <exception cref="T:System.ArgumentNullException">
  4880. /// <paramref name="conversion" /> or <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  4881. /// <remarks>
  4882. /// <para>
  4883. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  4884. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  4885. /// </para>
  4886. /// <para>
  4887. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEvent, and is used to post add and remove handler invocations.
  4888. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  4889. /// </para>
  4890. /// <para>
  4891. /// If no SynchronizationContext is present at the point of calling FromEvent, add and remove handler invocations are made synchronously on the thread
  4892. /// making the Subscribe or Dispose call, respectively.
  4893. /// </para>
  4894. /// <para>
  4895. /// It's recommended to lift FromEvent calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  4896. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  4897. /// more concise and easier to understand.
  4898. /// </para>
  4899. /// </remarks>
  4900. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  4901. public static IQbservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Func<Action<TEventArgs>, TDelegate>> conversion, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)
  4902. {
  4903. if (provider == null)
  4904. throw new ArgumentNullException("provider");
  4905. if (conversion == null)
  4906. throw new ArgumentNullException("conversion");
  4907. if (addHandler == null)
  4908. throw new ArgumentNullException("addHandler");
  4909. if (removeHandler == null)
  4910. throw new ArgumentNullException("removeHandler");
  4911. return provider.CreateQuery<TEventArgs>(
  4912. Expression.Call(
  4913. null,
  4914. #if CRIPPLED_REFLECTION
  4915. InfoOf(() => Qbservable.FromEvent<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Func<Action<TEventArgs>, TDelegate>>), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>))),
  4916. #else
  4917. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  4918. #endif
  4919. Expression.Constant(provider, typeof(IQbservableProvider)),
  4920. conversion,
  4921. addHandler,
  4922. removeHandler
  4923. )
  4924. );
  4925. }
  4926. /// <summary>
  4927. /// Converts a .NET event to an observable sequence, using a conversion function to obtain the event delegate. Each event invocation is surfaced through an OnNext message in the resulting sequence.
  4928. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  4929. /// </summary>
  4930. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  4931. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  4932. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  4933. /// <param name="conversion">A function used to convert the given event handler to a delegate compatible with the underlying .NET event. The resulting delegate is used in calls to the addHandler and removeHandler action parameters.</param>
  4934. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  4935. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  4936. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  4937. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  4938. /// <exception cref="T:System.ArgumentNullException">
  4939. /// <paramref name="conversion" /> or <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  4940. /// <remarks>
  4941. /// <para>
  4942. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  4943. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  4944. /// </para>
  4945. /// <para>
  4946. /// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be
  4947. /// accessed from the same context, as required by some UI frameworks.
  4948. /// </para>
  4949. /// <para>
  4950. /// It's recommended to lift FromEvent calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  4951. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEvent that omit the IScheduler
  4952. /// parameter. For more information, see the remarks section on those overloads.
  4953. /// </para>
  4954. /// </remarks>
  4955. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  4956. public static IQbservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Func<Action<TEventArgs>, TDelegate>> conversion, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler, IScheduler scheduler)
  4957. {
  4958. if (provider == null)
  4959. throw new ArgumentNullException("provider");
  4960. if (conversion == null)
  4961. throw new ArgumentNullException("conversion");
  4962. if (addHandler == null)
  4963. throw new ArgumentNullException("addHandler");
  4964. if (removeHandler == null)
  4965. throw new ArgumentNullException("removeHandler");
  4966. if (scheduler == null)
  4967. throw new ArgumentNullException("scheduler");
  4968. return provider.CreateQuery<TEventArgs>(
  4969. Expression.Call(
  4970. null,
  4971. #if CRIPPLED_REFLECTION
  4972. InfoOf(() => Qbservable.FromEvent<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Func<Action<TEventArgs>, TDelegate>>), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>), default(IScheduler))),
  4973. #else
  4974. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  4975. #endif
  4976. Expression.Constant(provider, typeof(IQbservableProvider)),
  4977. conversion,
  4978. addHandler,
  4979. removeHandler,
  4980. Expression.Constant(scheduler, typeof(IScheduler))
  4981. )
  4982. );
  4983. }
  4984. /// <summary>
  4985. /// Converts a generic Action-based .NET event to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence.
  4986. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  4987. /// </summary>
  4988. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  4989. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  4990. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  4991. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  4992. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  4993. /// <exception cref="T:System.ArgumentNullException">
  4994. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  4995. /// <remarks>
  4996. /// <para>
  4997. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  4998. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  4999. /// </para>
  5000. /// <para>
  5001. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEvent, and is used to post add and remove handler invocations.
  5002. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5003. /// </para>
  5004. /// <para>
  5005. /// If no SynchronizationContext is present at the point of calling FromEvent, add and remove handler invocations are made synchronously on the thread
  5006. /// making the Subscribe or Dispose call, respectively.
  5007. /// </para>
  5008. /// <para>
  5009. /// It's recommended to lift FromEvent calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5010. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5011. /// more concise and easier to understand.
  5012. /// </para>
  5013. /// </remarks>
  5014. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  5015. public static IQbservable<TEventArgs> FromEvent<TEventArgs>(this IQbservableProvider provider, Expression<Action<Action<TEventArgs>>> addHandler, Expression<Action<Action<TEventArgs>>> removeHandler)
  5016. {
  5017. if (provider == null)
  5018. throw new ArgumentNullException("provider");
  5019. if (addHandler == null)
  5020. throw new ArgumentNullException("addHandler");
  5021. if (removeHandler == null)
  5022. throw new ArgumentNullException("removeHandler");
  5023. return provider.CreateQuery<TEventArgs>(
  5024. Expression.Call(
  5025. null,
  5026. #if CRIPPLED_REFLECTION
  5027. InfoOf(() => Qbservable.FromEvent<TEventArgs>(default(IQbservableProvider), default(Expression<Action<Action<TEventArgs>>>), default(Expression<Action<Action<TEventArgs>>>))),
  5028. #else
  5029. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  5030. #endif
  5031. Expression.Constant(provider, typeof(IQbservableProvider)),
  5032. addHandler,
  5033. removeHandler
  5034. )
  5035. );
  5036. }
  5037. /// <summary>
  5038. /// Converts a generic Action-based .NET event to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5039. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  5040. /// </summary>
  5041. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5042. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5043. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5044. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5045. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5046. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  5047. /// <exception cref="T:System.ArgumentNullException">
  5048. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5049. /// <remarks>
  5050. /// <para>
  5051. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5052. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5053. /// </para>
  5054. /// <para>
  5055. /// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be
  5056. /// accessed from the same context, as required by some UI frameworks.
  5057. /// </para>
  5058. /// <para>
  5059. /// It's recommended to lift FromEvent calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5060. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEvent that omit the IScheduler
  5061. /// parameter. For more information, see the remarks section on those overloads.
  5062. /// </para>
  5063. /// </remarks>
  5064. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  5065. public static IQbservable<TEventArgs> FromEvent<TEventArgs>(this IQbservableProvider provider, Expression<Action<Action<TEventArgs>>> addHandler, Expression<Action<Action<TEventArgs>>> removeHandler, IScheduler scheduler)
  5066. {
  5067. if (provider == null)
  5068. throw new ArgumentNullException("provider");
  5069. if (addHandler == null)
  5070. throw new ArgumentNullException("addHandler");
  5071. if (removeHandler == null)
  5072. throw new ArgumentNullException("removeHandler");
  5073. if (scheduler == null)
  5074. throw new ArgumentNullException("scheduler");
  5075. return provider.CreateQuery<TEventArgs>(
  5076. Expression.Call(
  5077. null,
  5078. #if CRIPPLED_REFLECTION
  5079. InfoOf(() => Qbservable.FromEvent<TEventArgs>(default(IQbservableProvider), default(Expression<Action<Action<TEventArgs>>>), default(Expression<Action<Action<TEventArgs>>>), default(IScheduler))),
  5080. #else
  5081. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  5082. #endif
  5083. Expression.Constant(provider, typeof(IQbservableProvider)),
  5084. addHandler,
  5085. removeHandler,
  5086. Expression.Constant(scheduler, typeof(IScheduler))
  5087. )
  5088. );
  5089. }
  5090. #if !NO_EVENTARGS_CONSTRAINT
  5091. /// <summary>
  5092. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="T:System.EventHandler" />, to an observable sequence.
  5093. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5094. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5095. /// </summary>
  5096. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5097. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5098. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5099. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5100. /// <exception cref="T:System.ArgumentNullException">
  5101. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  5102. /// <remarks>
  5103. /// <para>
  5104. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5105. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5106. /// </para>
  5107. /// <para>
  5108. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  5109. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5110. /// </para>
  5111. /// <para>
  5112. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5113. /// making the Subscribe or Dispose call, respectively.
  5114. /// </para>
  5115. /// <para>
  5116. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5117. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5118. /// more concise and easier to understand.
  5119. /// </para>
  5120. /// </remarks>
  5121. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5122. public static IQbservable<EventPattern<EventArgs>> FromEventPattern(this IQbservableProvider provider, Expression<Action<EventHandler>> addHandler, Expression<Action<EventHandler>> removeHandler)
  5123. {
  5124. if (provider == null)
  5125. throw new ArgumentNullException("provider");
  5126. if (addHandler == null)
  5127. throw new ArgumentNullException("addHandler");
  5128. if (removeHandler == null)
  5129. throw new ArgumentNullException("removeHandler");
  5130. return provider.CreateQuery<EventPattern<EventArgs>>(
  5131. Expression.Call(
  5132. null,
  5133. #if CRIPPLED_REFLECTION
  5134. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Expression<Action<EventHandler>>), default(Expression<Action<EventHandler>>))),
  5135. #else
  5136. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5137. #endif
  5138. Expression.Constant(provider, typeof(IQbservableProvider)),
  5139. addHandler,
  5140. removeHandler
  5141. )
  5142. );
  5143. }
  5144. #else
  5145. /// <summary>
  5146. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="T:System.EventHandler" />, to an observable sequence.
  5147. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5148. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5149. /// </summary>
  5150. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5151. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5152. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5153. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5154. /// <exception cref="T:System.ArgumentNullException">
  5155. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  5156. /// <remarks>
  5157. /// <para>
  5158. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5159. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5160. /// </para>
  5161. /// <para>
  5162. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  5163. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5164. /// </para>
  5165. /// <para>
  5166. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5167. /// making the Subscribe or Dispose call, respectively.
  5168. /// </para>
  5169. /// <para>
  5170. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5171. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5172. /// more concise and easier to understand.
  5173. /// </para>
  5174. /// </remarks>
  5175. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5176. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, Expression<Action<EventHandler>> addHandler, Expression<Action<EventHandler>> removeHandler)
  5177. {
  5178. if (provider == null)
  5179. throw new ArgumentNullException("provider");
  5180. if (addHandler == null)
  5181. throw new ArgumentNullException("addHandler");
  5182. if (removeHandler == null)
  5183. throw new ArgumentNullException("removeHandler");
  5184. return provider.CreateQuery<EventPattern<object>>(
  5185. Expression.Call(
  5186. null,
  5187. #if CRIPPLED_REFLECTION
  5188. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Expression<Action<EventHandler>>), default(Expression<Action<EventHandler>>))),
  5189. #else
  5190. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5191. #endif
  5192. Expression.Constant(provider, typeof(IQbservableProvider)),
  5193. addHandler,
  5194. removeHandler
  5195. )
  5196. );
  5197. }
  5198. #endif
  5199. #if !NO_EVENTARGS_CONSTRAINT
  5200. /// <summary>
  5201. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="T:System.EventHandler" />, to an observable sequence.
  5202. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5203. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5204. /// </summary>
  5205. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5206. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5207. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5208. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5209. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5210. /// <exception cref="T:System.ArgumentNullException">
  5211. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5212. /// <remarks>
  5213. /// <para>
  5214. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5215. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5216. /// </para>
  5217. /// <para>
  5218. /// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be
  5219. /// accessed from the same context, as required by some UI frameworks.
  5220. /// </para>
  5221. /// <para>
  5222. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5223. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5224. /// parameter. For more information, see the remarks section on those overloads.
  5225. /// </para>
  5226. /// </remarks>
  5227. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5228. public static IQbservable<EventPattern<EventArgs>> FromEventPattern(this IQbservableProvider provider, Expression<Action<EventHandler>> addHandler, Expression<Action<EventHandler>> removeHandler, IScheduler scheduler)
  5229. {
  5230. if (provider == null)
  5231. throw new ArgumentNullException("provider");
  5232. if (addHandler == null)
  5233. throw new ArgumentNullException("addHandler");
  5234. if (removeHandler == null)
  5235. throw new ArgumentNullException("removeHandler");
  5236. if (scheduler == null)
  5237. throw new ArgumentNullException("scheduler");
  5238. return provider.CreateQuery<EventPattern<EventArgs>>(
  5239. Expression.Call(
  5240. null,
  5241. #if CRIPPLED_REFLECTION
  5242. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Expression<Action<EventHandler>>), default(Expression<Action<EventHandler>>), default(IScheduler))),
  5243. #else
  5244. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5245. #endif
  5246. Expression.Constant(provider, typeof(IQbservableProvider)),
  5247. addHandler,
  5248. removeHandler,
  5249. Expression.Constant(scheduler, typeof(IScheduler))
  5250. )
  5251. );
  5252. }
  5253. #else
  5254. /// <summary>
  5255. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="T:System.EventHandler" />, to an observable sequence.
  5256. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5257. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5258. /// </summary>
  5259. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5260. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5261. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5262. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5263. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5264. /// <exception cref="T:System.ArgumentNullException">
  5265. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5266. /// <remarks>
  5267. /// <para>
  5268. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5269. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5270. /// </para>
  5271. /// <para>
  5272. /// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be
  5273. /// accessed from the same context, as required by some UI frameworks.
  5274. /// </para>
  5275. /// <para>
  5276. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5277. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5278. /// parameter. For more information, see the remarks section on those overloads.
  5279. /// </para>
  5280. /// </remarks>
  5281. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5282. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, Expression<Action<EventHandler>> addHandler, Expression<Action<EventHandler>> removeHandler, IScheduler scheduler)
  5283. {
  5284. if (provider == null)
  5285. throw new ArgumentNullException("provider");
  5286. if (addHandler == null)
  5287. throw new ArgumentNullException("addHandler");
  5288. if (removeHandler == null)
  5289. throw new ArgumentNullException("removeHandler");
  5290. if (scheduler == null)
  5291. throw new ArgumentNullException("scheduler");
  5292. return provider.CreateQuery<EventPattern<object>>(
  5293. Expression.Call(
  5294. null,
  5295. #if CRIPPLED_REFLECTION
  5296. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Expression<Action<EventHandler>>), default(Expression<Action<EventHandler>>), default(IScheduler))),
  5297. #else
  5298. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5299. #endif
  5300. Expression.Constant(provider, typeof(IQbservableProvider)),
  5301. addHandler,
  5302. removeHandler,
  5303. Expression.Constant(scheduler, typeof(IScheduler))
  5304. )
  5305. );
  5306. }
  5307. #endif
  5308. #if !NO_EVENTARGS_CONSTRAINT
  5309. /// <summary>
  5310. /// Converts an instance .NET event, conforming to the standard .NET event pattern with an <see cref="T:System.EventArgs" /> parameter, to an observable sequence.
  5311. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5312. /// Reflection is used to discover the event based on the target object type and the specified event name.
  5313. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5314. /// </summary>
  5315. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5316. /// <param name="target">Object instance that exposes the event to convert.</param>
  5317. /// <param name="eventName">Name of the event to convert.</param>
  5318. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5319. /// <exception cref="T:System.ArgumentNullException">
  5320. /// <paramref name="target" /> or <paramref name="eventName" /> is null.</exception>
  5321. /// <exception cref="T:System.InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5322. /// <remarks>
  5323. /// <para>
  5324. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5325. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5326. /// </para>
  5327. /// <para>
  5328. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  5329. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5330. /// </para>
  5331. /// <para>
  5332. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5333. /// making the Subscribe or Dispose call, respectively.
  5334. /// </para>
  5335. /// <para>
  5336. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5337. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5338. /// more concise and easier to understand.
  5339. /// </para>
  5340. /// </remarks>
  5341. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5342. public static IQbservable<EventPattern<EventArgs>> FromEventPattern(this IQbservableProvider provider, object target, string eventName)
  5343. {
  5344. if (provider == null)
  5345. throw new ArgumentNullException("provider");
  5346. if (target == null)
  5347. throw new ArgumentNullException("target");
  5348. if (eventName == null)
  5349. throw new ArgumentNullException("eventName");
  5350. return provider.CreateQuery<EventPattern<EventArgs>>(
  5351. Expression.Call(
  5352. null,
  5353. #if CRIPPLED_REFLECTION
  5354. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(object), default(string))),
  5355. #else
  5356. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5357. #endif
  5358. Expression.Constant(provider, typeof(IQbservableProvider)),
  5359. Expression.Constant(target, typeof(object)),
  5360. Expression.Constant(eventName, typeof(string))
  5361. )
  5362. );
  5363. }
  5364. #else
  5365. /// <summary>
  5366. /// Converts an instance .NET event, conforming to the standard .NET event pattern with an <see cref="T:System.EventArgs" /> parameter, to an observable sequence.
  5367. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5368. /// Reflection is used to discover the event based on the target object type and the specified event name.
  5369. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5370. /// </summary>
  5371. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5372. /// <param name="target">Object instance that exposes the event to convert.</param>
  5373. /// <param name="eventName">Name of the event to convert.</param>
  5374. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5375. /// <exception cref="T:System.ArgumentNullException">
  5376. /// <paramref name="target" /> or <paramref name="eventName" /> is null.</exception>
  5377. /// <exception cref="T:System.InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5378. /// <remarks>
  5379. /// <para>
  5380. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5381. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5382. /// </para>
  5383. /// <para>
  5384. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  5385. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5386. /// </para>
  5387. /// <para>
  5388. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5389. /// making the Subscribe or Dispose call, respectively.
  5390. /// </para>
  5391. /// <para>
  5392. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5393. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5394. /// more concise and easier to understand.
  5395. /// </para>
  5396. /// </remarks>
  5397. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5398. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, object target, string eventName)
  5399. {
  5400. if (provider == null)
  5401. throw new ArgumentNullException("provider");
  5402. if (target == null)
  5403. throw new ArgumentNullException("target");
  5404. if (eventName == null)
  5405. throw new ArgumentNullException("eventName");
  5406. return provider.CreateQuery<EventPattern<object>>(
  5407. Expression.Call(
  5408. null,
  5409. #if CRIPPLED_REFLECTION
  5410. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(object), default(string))),
  5411. #else
  5412. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5413. #endif
  5414. Expression.Constant(provider, typeof(IQbservableProvider)),
  5415. Expression.Constant(target, typeof(object)),
  5416. Expression.Constant(eventName, typeof(string))
  5417. )
  5418. );
  5419. }
  5420. #endif
  5421. #if !NO_EVENTARGS_CONSTRAINT
  5422. /// <summary>
  5423. /// Converts an instance .NET event, conforming to the standard .NET event pattern with an <see cref="T:System.EventArgs" /> parameter, to an observable sequence.
  5424. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5425. /// Reflection is used to discover the event based on the target object type and the specified event name.
  5426. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5427. /// </summary>
  5428. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5429. /// <param name="target">Object instance that exposes the event to convert.</param>
  5430. /// <param name="eventName">Name of the event to convert.</param>
  5431. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5432. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5433. /// <exception cref="T:System.ArgumentNullException">
  5434. /// <paramref name="target" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  5435. /// <exception cref="T:System.InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5436. /// <remarks>
  5437. /// <para>
  5438. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5439. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5440. /// </para>
  5441. /// <para>
  5442. /// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be
  5443. /// accessed from the same context, as required by some UI frameworks.
  5444. /// </para>
  5445. /// <para>
  5446. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5447. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5448. /// parameter. For more information, see the remarks section on those overloads.
  5449. /// </para>
  5450. /// </remarks>
  5451. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5452. public static IQbservable<EventPattern<EventArgs>> FromEventPattern(this IQbservableProvider provider, object target, string eventName, IScheduler scheduler)
  5453. {
  5454. if (provider == null)
  5455. throw new ArgumentNullException("provider");
  5456. if (target == null)
  5457. throw new ArgumentNullException("target");
  5458. if (eventName == null)
  5459. throw new ArgumentNullException("eventName");
  5460. if (scheduler == null)
  5461. throw new ArgumentNullException("scheduler");
  5462. return provider.CreateQuery<EventPattern<EventArgs>>(
  5463. Expression.Call(
  5464. null,
  5465. #if CRIPPLED_REFLECTION
  5466. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(object), default(string), default(IScheduler))),
  5467. #else
  5468. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5469. #endif
  5470. Expression.Constant(provider, typeof(IQbservableProvider)),
  5471. Expression.Constant(target, typeof(object)),
  5472. Expression.Constant(eventName, typeof(string)),
  5473. Expression.Constant(scheduler, typeof(IScheduler))
  5474. )
  5475. );
  5476. }
  5477. #else
  5478. /// <summary>
  5479. /// Converts an instance .NET event, conforming to the standard .NET event pattern with an <see cref="T:System.EventArgs" /> parameter, to an observable sequence.
  5480. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5481. /// Reflection is used to discover the event based on the target object type and the specified event name.
  5482. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5483. /// </summary>
  5484. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5485. /// <param name="target">Object instance that exposes the event to convert.</param>
  5486. /// <param name="eventName">Name of the event to convert.</param>
  5487. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5488. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5489. /// <exception cref="T:System.ArgumentNullException">
  5490. /// <paramref name="target" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  5491. /// <exception cref="T:System.InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5492. /// <remarks>
  5493. /// <para>
  5494. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5495. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5496. /// </para>
  5497. /// <para>
  5498. /// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be
  5499. /// accessed from the same context, as required by some UI frameworks.
  5500. /// </para>
  5501. /// <para>
  5502. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5503. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5504. /// parameter. For more information, see the remarks section on those overloads.
  5505. /// </para>
  5506. /// </remarks>
  5507. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5508. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, object target, string eventName, IScheduler scheduler)
  5509. {
  5510. if (provider == null)
  5511. throw new ArgumentNullException("provider");
  5512. if (target == null)
  5513. throw new ArgumentNullException("target");
  5514. if (eventName == null)
  5515. throw new ArgumentNullException("eventName");
  5516. if (scheduler == null)
  5517. throw new ArgumentNullException("scheduler");
  5518. return provider.CreateQuery<EventPattern<object>>(
  5519. Expression.Call(
  5520. null,
  5521. #if CRIPPLED_REFLECTION
  5522. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(object), default(string), default(IScheduler))),
  5523. #else
  5524. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5525. #endif
  5526. Expression.Constant(provider, typeof(IQbservableProvider)),
  5527. Expression.Constant(target, typeof(object)),
  5528. Expression.Constant(eventName, typeof(string)),
  5529. Expression.Constant(scheduler, typeof(IScheduler))
  5530. )
  5531. );
  5532. }
  5533. #endif
  5534. #if !NO_EVENTARGS_CONSTRAINT
  5535. /// <summary>
  5536. /// Converts a static .NET event, conforming to the standard .NET event pattern with an <see cref="T:System.EventArgs" /> parameter, to an observable sequence.
  5537. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5538. /// Reflection is used to discover the event based on the specified type and the specified event name.
  5539. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5540. /// </summary>
  5541. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5542. /// <param name="type">Type that exposes the static event to convert.</param>
  5543. /// <param name="eventName">Name of the event to convert.</param>
  5544. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5545. /// <exception cref="T:System.ArgumentNullException">
  5546. /// <paramref name="type" /> or <paramref name="eventName" /> is null.</exception>
  5547. /// <exception cref="T:System.InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5548. /// <remarks>
  5549. /// <para>
  5550. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5551. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5552. /// </para>
  5553. /// <para>
  5554. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  5555. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5556. /// </para>
  5557. /// <para>
  5558. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5559. /// making the Subscribe or Dispose call, respectively.
  5560. /// </para>
  5561. /// <para>
  5562. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5563. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5564. /// more concise and easier to understand.
  5565. /// </para>
  5566. /// </remarks>
  5567. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5568. public static IQbservable<EventPattern<EventArgs>> FromEventPattern(this IQbservableProvider provider, Type type, string eventName)
  5569. {
  5570. if (provider == null)
  5571. throw new ArgumentNullException("provider");
  5572. if (type == null)
  5573. throw new ArgumentNullException("type");
  5574. if (eventName == null)
  5575. throw new ArgumentNullException("eventName");
  5576. return provider.CreateQuery<EventPattern<EventArgs>>(
  5577. Expression.Call(
  5578. null,
  5579. #if CRIPPLED_REFLECTION
  5580. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Type), default(string))),
  5581. #else
  5582. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5583. #endif
  5584. Expression.Constant(provider, typeof(IQbservableProvider)),
  5585. Expression.Constant(type, typeof(Type)),
  5586. Expression.Constant(eventName, typeof(string))
  5587. )
  5588. );
  5589. }
  5590. #else
  5591. /// <summary>
  5592. /// Converts a static .NET event, conforming to the standard .NET event pattern with an <see cref="T:System.EventArgs" /> parameter, to an observable sequence.
  5593. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5594. /// Reflection is used to discover the event based on the specified type and the specified event name.
  5595. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5596. /// </summary>
  5597. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5598. /// <param name="type">Type that exposes the static event to convert.</param>
  5599. /// <param name="eventName">Name of the event to convert.</param>
  5600. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5601. /// <exception cref="T:System.ArgumentNullException">
  5602. /// <paramref name="type" /> or <paramref name="eventName" /> is null.</exception>
  5603. /// <exception cref="T:System.InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5604. /// <remarks>
  5605. /// <para>
  5606. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5607. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5608. /// </para>
  5609. /// <para>
  5610. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  5611. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5612. /// </para>
  5613. /// <para>
  5614. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5615. /// making the Subscribe or Dispose call, respectively.
  5616. /// </para>
  5617. /// <para>
  5618. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5619. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5620. /// more concise and easier to understand.
  5621. /// </para>
  5622. /// </remarks>
  5623. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5624. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, Type type, string eventName)
  5625. {
  5626. if (provider == null)
  5627. throw new ArgumentNullException("provider");
  5628. if (type == null)
  5629. throw new ArgumentNullException("type");
  5630. if (eventName == null)
  5631. throw new ArgumentNullException("eventName");
  5632. return provider.CreateQuery<EventPattern<object>>(
  5633. Expression.Call(
  5634. null,
  5635. #if CRIPPLED_REFLECTION
  5636. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Type), default(string))),
  5637. #else
  5638. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5639. #endif
  5640. Expression.Constant(provider, typeof(IQbservableProvider)),
  5641. Expression.Constant(type, typeof(Type)),
  5642. Expression.Constant(eventName, typeof(string))
  5643. )
  5644. );
  5645. }
  5646. #endif
  5647. #if !NO_EVENTARGS_CONSTRAINT
  5648. /// <summary>
  5649. /// Converts a static .NET event, conforming to the standard .NET event pattern with an <see cref="T:System.EventArgs" /> parameter, to an observable sequence.
  5650. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5651. /// Reflection is used to discover the event based on the specified type and the specified event name.
  5652. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5653. /// </summary>
  5654. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5655. /// <param name="type">Type that exposes the static event to convert.</param>
  5656. /// <param name="eventName">Name of the event to convert.</param>
  5657. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5658. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5659. /// <exception cref="T:System.ArgumentNullException">
  5660. /// <paramref name="type" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  5661. /// <exception cref="T:System.InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5662. /// <remarks>
  5663. /// <para>
  5664. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5665. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5666. /// </para>
  5667. /// <para>
  5668. /// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be
  5669. /// accessed from the same context, as required by some UI frameworks.
  5670. /// </para>
  5671. /// <para>
  5672. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5673. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5674. /// parameter. For more information, see the remarks section on those overloads.
  5675. /// </para>
  5676. /// </remarks>
  5677. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5678. public static IQbservable<EventPattern<EventArgs>> FromEventPattern(this IQbservableProvider provider, Type type, string eventName, IScheduler scheduler)
  5679. {
  5680. if (provider == null)
  5681. throw new ArgumentNullException("provider");
  5682. if (type == null)
  5683. throw new ArgumentNullException("type");
  5684. if (eventName == null)
  5685. throw new ArgumentNullException("eventName");
  5686. if (scheduler == null)
  5687. throw new ArgumentNullException("scheduler");
  5688. return provider.CreateQuery<EventPattern<EventArgs>>(
  5689. Expression.Call(
  5690. null,
  5691. #if CRIPPLED_REFLECTION
  5692. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Type), default(string), default(IScheduler))),
  5693. #else
  5694. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5695. #endif
  5696. Expression.Constant(provider, typeof(IQbservableProvider)),
  5697. Expression.Constant(type, typeof(Type)),
  5698. Expression.Constant(eventName, typeof(string)),
  5699. Expression.Constant(scheduler, typeof(IScheduler))
  5700. )
  5701. );
  5702. }
  5703. #else
  5704. /// <summary>
  5705. /// Converts a static .NET event, conforming to the standard .NET event pattern with an <see cref="T:System.EventArgs" /> parameter, to an observable sequence.
  5706. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5707. /// Reflection is used to discover the event based on the specified type and the specified event name.
  5708. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5709. /// </summary>
  5710. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5711. /// <param name="type">Type that exposes the static event to convert.</param>
  5712. /// <param name="eventName">Name of the event to convert.</param>
  5713. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5714. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5715. /// <exception cref="T:System.ArgumentNullException">
  5716. /// <paramref name="type" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  5717. /// <exception cref="T:System.InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5718. /// <remarks>
  5719. /// <para>
  5720. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5721. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5722. /// </para>
  5723. /// <para>
  5724. /// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be
  5725. /// accessed from the same context, as required by some UI frameworks.
  5726. /// </para>
  5727. /// <para>
  5728. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5729. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5730. /// parameter. For more information, see the remarks section on those overloads.
  5731. /// </para>
  5732. /// </remarks>
  5733. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5734. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, Type type, string eventName, IScheduler scheduler)
  5735. {
  5736. if (provider == null)
  5737. throw new ArgumentNullException("provider");
  5738. if (type == null)
  5739. throw new ArgumentNullException("type");
  5740. if (eventName == null)
  5741. throw new ArgumentNullException("eventName");
  5742. if (scheduler == null)
  5743. throw new ArgumentNullException("scheduler");
  5744. return provider.CreateQuery<EventPattern<object>>(
  5745. Expression.Call(
  5746. null,
  5747. #if CRIPPLED_REFLECTION
  5748. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Type), default(string), default(IScheduler))),
  5749. #else
  5750. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5751. #endif
  5752. Expression.Constant(provider, typeof(IQbservableProvider)),
  5753. Expression.Constant(type, typeof(Type)),
  5754. Expression.Constant(eventName, typeof(string)),
  5755. Expression.Constant(scheduler, typeof(IScheduler))
  5756. )
  5757. );
  5758. }
  5759. #endif
  5760. /// <summary>
  5761. /// Converts a .NET event, conforming to the standard .NET event pattern based on a supplied event delegate type, to an observable sequence.
  5762. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5763. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5764. /// </summary>
  5765. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5766. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5767. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5768. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5769. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5770. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5771. /// <exception cref="T:System.ArgumentNullException">
  5772. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  5773. /// <remarks>
  5774. /// <para>
  5775. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5776. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5777. /// </para>
  5778. /// <para>
  5779. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  5780. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5781. /// </para>
  5782. /// <para>
  5783. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5784. /// making the Subscribe or Dispose call, respectively.
  5785. /// </para>
  5786. /// <para>
  5787. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5788. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5789. /// more concise and easier to understand.
  5790. /// </para>
  5791. /// </remarks>
  5792. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5793. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)
  5794. #if !NO_EVENTARGS_CONSTRAINT
  5795. where TEventArgs : EventArgs
  5796. #endif
  5797. {
  5798. if (provider == null)
  5799. throw new ArgumentNullException("provider");
  5800. if (addHandler == null)
  5801. throw new ArgumentNullException("addHandler");
  5802. if (removeHandler == null)
  5803. throw new ArgumentNullException("removeHandler");
  5804. return provider.CreateQuery<EventPattern<TEventArgs>>(
  5805. Expression.Call(
  5806. null,
  5807. #if CRIPPLED_REFLECTION
  5808. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>))),
  5809. #else
  5810. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  5811. #endif
  5812. Expression.Constant(provider, typeof(IQbservableProvider)),
  5813. addHandler,
  5814. removeHandler
  5815. )
  5816. );
  5817. }
  5818. /// <summary>
  5819. /// Converts a .NET event, conforming to the standard .NET event pattern based on a supplied event delegate type, to an observable sequence.
  5820. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5821. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5822. /// </summary>
  5823. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5824. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5825. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5826. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5827. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5828. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5829. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5830. /// <exception cref="T:System.ArgumentNullException">
  5831. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5832. /// <remarks>
  5833. /// <para>
  5834. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5835. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5836. /// </para>
  5837. /// <para>
  5838. /// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be
  5839. /// accessed from the same context, as required by some UI frameworks.
  5840. /// </para>
  5841. /// <para>
  5842. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5843. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5844. /// parameter. For more information, see the remarks section on those overloads.
  5845. /// </para>
  5846. /// </remarks>
  5847. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5848. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler, IScheduler scheduler)
  5849. #if !NO_EVENTARGS_CONSTRAINT
  5850. where TEventArgs : EventArgs
  5851. #endif
  5852. {
  5853. if (provider == null)
  5854. throw new ArgumentNullException("provider");
  5855. if (addHandler == null)
  5856. throw new ArgumentNullException("addHandler");
  5857. if (removeHandler == null)
  5858. throw new ArgumentNullException("removeHandler");
  5859. if (scheduler == null)
  5860. throw new ArgumentNullException("scheduler");
  5861. return provider.CreateQuery<EventPattern<TEventArgs>>(
  5862. Expression.Call(
  5863. null,
  5864. #if CRIPPLED_REFLECTION
  5865. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>), default(IScheduler))),
  5866. #else
  5867. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  5868. #endif
  5869. Expression.Constant(provider, typeof(IQbservableProvider)),
  5870. addHandler,
  5871. removeHandler,
  5872. Expression.Constant(scheduler, typeof(IScheduler))
  5873. )
  5874. );
  5875. }
  5876. /// <summary>
  5877. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="T:System.EventHandler`1" />, to an observable sequence.
  5878. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5879. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5880. /// </summary>
  5881. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5882. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5883. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5884. /// <param name="conversion">A function used to convert the given event handler to a delegate compatible with the underlying .NET event. The resulting delegate is used in calls to the addHandler and removeHandler action parameters.</param>
  5885. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5886. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5887. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5888. /// <exception cref="T:System.ArgumentNullException">
  5889. /// <paramref name="conversion" /> or <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  5890. /// <remarks>
  5891. /// <para>
  5892. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5893. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5894. /// </para>
  5895. /// <para>
  5896. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  5897. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5898. /// </para>
  5899. /// <para>
  5900. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5901. /// making the Subscribe or Dispose call, respectively.
  5902. /// </para>
  5903. /// <para>
  5904. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5905. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5906. /// more concise and easier to understand.
  5907. /// </para>
  5908. /// </remarks>
  5909. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5910. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Func<EventHandler<TEventArgs>, TDelegate>> conversion, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)
  5911. #if !NO_EVENTARGS_CONSTRAINT
  5912. where TEventArgs : EventArgs
  5913. #endif
  5914. {
  5915. if (provider == null)
  5916. throw new ArgumentNullException("provider");
  5917. if (conversion == null)
  5918. throw new ArgumentNullException("conversion");
  5919. if (addHandler == null)
  5920. throw new ArgumentNullException("addHandler");
  5921. if (removeHandler == null)
  5922. throw new ArgumentNullException("removeHandler");
  5923. return provider.CreateQuery<EventPattern<TEventArgs>>(
  5924. Expression.Call(
  5925. null,
  5926. #if CRIPPLED_REFLECTION
  5927. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Func<EventHandler<TEventArgs>, TDelegate>>), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>))),
  5928. #else
  5929. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  5930. #endif
  5931. Expression.Constant(provider, typeof(IQbservableProvider)),
  5932. conversion,
  5933. addHandler,
  5934. removeHandler
  5935. )
  5936. );
  5937. }
  5938. /// <summary>
  5939. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="T:System.EventHandler`1" />, to an observable sequence.
  5940. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5941. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5942. /// </summary>
  5943. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  5944. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5945. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5946. /// <param name="conversion">A function used to convert the given event handler to a delegate compatible with the underlying .NET event. The resulting delegate is used in calls to the addHandler and removeHandler action parameters.</param>
  5947. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5948. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5949. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5950. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5951. /// <exception cref="T:System.ArgumentNullException">
  5952. /// <paramref name="conversion" /> or <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5953. /// <remarks>
  5954. /// <para>
  5955. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5956. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5957. /// </para>
  5958. /// <para>
  5959. /// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be
  5960. /// accessed from the same context, as required by some UI frameworks.
  5961. /// </para>
  5962. /// <para>
  5963. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5964. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5965. /// parameter. For more information, see the remarks section on those overloads.
  5966. /// </para>
  5967. /// </remarks>
  5968. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5969. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Func<EventHandler<TEventArgs>, TDelegate>> conversion, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler, IScheduler scheduler)
  5970. #if !NO_EVENTARGS_CONSTRAINT
  5971. where TEventArgs : EventArgs
  5972. #endif
  5973. {
  5974. if (provider == null)
  5975. throw new ArgumentNullException("provider");
  5976. if (conversion == null)
  5977. throw new ArgumentNullException("conversion");
  5978. if (addHandler == null)
  5979. throw new ArgumentNullException("addHandler");
  5980. if (removeHandler == null)
  5981. throw new ArgumentNullException("removeHandler");
  5982. if (scheduler == null)
  5983. throw new ArgumentNullException("scheduler");
  5984. return provider.CreateQuery<EventPattern<TEventArgs>>(
  5985. Expression.Call(
  5986. null,
  5987. #if CRIPPLED_REFLECTION
  5988. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Func<EventHandler<TEventArgs>, TDelegate>>), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>), default(IScheduler))),
  5989. #else
  5990. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  5991. #endif
  5992. Expression.Constant(provider, typeof(IQbservableProvider)),
  5993. conversion,
  5994. addHandler,
  5995. removeHandler,
  5996. Expression.Constant(scheduler, typeof(IScheduler))
  5997. )
  5998. );
  5999. }
  6000. /// <summary>
  6001. /// Converts a .NET event, conforming to the standard .NET event pattern based on a supplied event delegate type with a strongly typed sender parameter, to an observable sequence.
  6002. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6003. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6004. /// </summary>
  6005. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6006. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  6007. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  6008. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6009. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  6010. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  6011. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6012. /// <exception cref="T:System.ArgumentNullException">
  6013. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  6014. /// <remarks>
  6015. /// <para>
  6016. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6017. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6018. /// </para>
  6019. /// <para>
  6020. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  6021. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  6022. /// </para>
  6023. /// <para>
  6024. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  6025. /// making the Subscribe or Dispose call, respectively.
  6026. /// </para>
  6027. /// <para>
  6028. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  6029. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  6030. /// more concise and easier to understand.
  6031. /// </para>
  6032. /// </remarks>
  6033. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6034. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TDelegate, TSender, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)
  6035. #if !NO_EVENTARGS_CONSTRAINT
  6036. where TEventArgs : EventArgs
  6037. #endif
  6038. {
  6039. if (provider == null)
  6040. throw new ArgumentNullException("provider");
  6041. if (addHandler == null)
  6042. throw new ArgumentNullException("addHandler");
  6043. if (removeHandler == null)
  6044. throw new ArgumentNullException("removeHandler");
  6045. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  6046. Expression.Call(
  6047. null,
  6048. #if CRIPPLED_REFLECTION
  6049. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TSender, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>))),
  6050. #else
  6051. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TSender), typeof(TEventArgs)),
  6052. #endif
  6053. Expression.Constant(provider, typeof(IQbservableProvider)),
  6054. addHandler,
  6055. removeHandler
  6056. )
  6057. );
  6058. }
  6059. /// <summary>
  6060. /// Converts a .NET event, conforming to the standard .NET event pattern based on a supplied event delegate type with a strongly typed sender parameter, to an observable sequence.
  6061. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6062. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6063. /// </summary>
  6064. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6065. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  6066. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  6067. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6068. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  6069. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  6070. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  6071. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6072. /// <exception cref="T:System.ArgumentNullException">
  6073. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  6074. /// <remarks>
  6075. /// <para>
  6076. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6077. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6078. /// </para>
  6079. /// <para>
  6080. /// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be
  6081. /// accessed from the same context, as required by some UI frameworks.
  6082. /// </para>
  6083. /// <para>
  6084. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  6085. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  6086. /// parameter. For more information, see the remarks section on those overloads.
  6087. /// </para>
  6088. /// </remarks>
  6089. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6090. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TDelegate, TSender, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler, IScheduler scheduler)
  6091. #if !NO_EVENTARGS_CONSTRAINT
  6092. where TEventArgs : EventArgs
  6093. #endif
  6094. {
  6095. if (provider == null)
  6096. throw new ArgumentNullException("provider");
  6097. if (addHandler == null)
  6098. throw new ArgumentNullException("addHandler");
  6099. if (removeHandler == null)
  6100. throw new ArgumentNullException("removeHandler");
  6101. if (scheduler == null)
  6102. throw new ArgumentNullException("scheduler");
  6103. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  6104. Expression.Call(
  6105. null,
  6106. #if CRIPPLED_REFLECTION
  6107. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TSender, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>), default(IScheduler))),
  6108. #else
  6109. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TSender), typeof(TEventArgs)),
  6110. #endif
  6111. Expression.Constant(provider, typeof(IQbservableProvider)),
  6112. addHandler,
  6113. removeHandler,
  6114. Expression.Constant(scheduler, typeof(IScheduler))
  6115. )
  6116. );
  6117. }
  6118. /// <summary>
  6119. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="T:System.EventHandler`1" />, to an observable sequence.
  6120. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6121. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6122. /// </summary>
  6123. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6124. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6125. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  6126. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  6127. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6128. /// <remarks>
  6129. /// <para>
  6130. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6131. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6132. /// </para>
  6133. /// <para>
  6134. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  6135. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  6136. /// </para>
  6137. /// <para>
  6138. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  6139. /// making the Subscribe or Dispose call, respectively.
  6140. /// </para>
  6141. /// <para>
  6142. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  6143. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  6144. /// more concise and easier to understand.
  6145. /// </para>
  6146. /// </remarks>
  6147. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6148. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, Expression<Action<EventHandler<TEventArgs>>> addHandler, Expression<Action<EventHandler<TEventArgs>>> removeHandler)
  6149. #if !NO_EVENTARGS_CONSTRAINT
  6150. where TEventArgs : EventArgs
  6151. #endif
  6152. {
  6153. if (provider == null)
  6154. throw new ArgumentNullException("provider");
  6155. if (addHandler == null)
  6156. throw new ArgumentNullException("addHandler");
  6157. if (removeHandler == null)
  6158. throw new ArgumentNullException("removeHandler");
  6159. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6160. Expression.Call(
  6161. null,
  6162. #if CRIPPLED_REFLECTION
  6163. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(Expression<Action<EventHandler<TEventArgs>>>), default(Expression<Action<EventHandler<TEventArgs>>>))),
  6164. #else
  6165. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  6166. #endif
  6167. Expression.Constant(provider, typeof(IQbservableProvider)),
  6168. addHandler,
  6169. removeHandler
  6170. )
  6171. );
  6172. }
  6173. /// <summary>
  6174. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="T:System.EventHandler`1" />, to an observable sequence.
  6175. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6176. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6177. /// </summary>
  6178. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6179. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6180. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  6181. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  6182. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  6183. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6184. /// <remarks>
  6185. /// <para>
  6186. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6187. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6188. /// </para>
  6189. /// <para>
  6190. /// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be
  6191. /// accessed from the same context, as required by some UI frameworks.
  6192. /// </para>
  6193. /// <para>
  6194. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  6195. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  6196. /// parameter. For more information, see the remarks section on those overloads.
  6197. /// </para>
  6198. /// </remarks>
  6199. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6200. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, Expression<Action<EventHandler<TEventArgs>>> addHandler, Expression<Action<EventHandler<TEventArgs>>> removeHandler, IScheduler scheduler)
  6201. #if !NO_EVENTARGS_CONSTRAINT
  6202. where TEventArgs : EventArgs
  6203. #endif
  6204. {
  6205. if (provider == null)
  6206. throw new ArgumentNullException("provider");
  6207. if (addHandler == null)
  6208. throw new ArgumentNullException("addHandler");
  6209. if (removeHandler == null)
  6210. throw new ArgumentNullException("removeHandler");
  6211. if (scheduler == null)
  6212. throw new ArgumentNullException("scheduler");
  6213. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6214. Expression.Call(
  6215. null,
  6216. #if CRIPPLED_REFLECTION
  6217. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(Expression<Action<EventHandler<TEventArgs>>>), default(Expression<Action<EventHandler<TEventArgs>>>), default(IScheduler))),
  6218. #else
  6219. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  6220. #endif
  6221. Expression.Constant(provider, typeof(IQbservableProvider)),
  6222. addHandler,
  6223. removeHandler,
  6224. Expression.Constant(scheduler, typeof(IScheduler))
  6225. )
  6226. );
  6227. }
  6228. /// <summary>
  6229. /// Converts an instance .NET event, conforming to the standard .NET event pattern with strongly typed event arguments, to an observable sequence.
  6230. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6231. /// Reflection is used to discover the event based on the target object type and the specified event name.
  6232. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6233. /// </summary>
  6234. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6235. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6236. /// <param name="target">Object instance that exposes the event to convert.</param>
  6237. /// <param name="eventName">Name of the event to convert.</param>
  6238. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6239. /// <exception cref="T:System.ArgumentNullException">
  6240. /// <paramref name="target" /> or <paramref name="eventName" /> is null.</exception>
  6241. /// <exception cref="T:System.InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern. -or- The event's second argument type is not assignable to TEventArgs.</exception>
  6242. /// <remarks>
  6243. /// <para>
  6244. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6245. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6246. /// </para>
  6247. /// <para>
  6248. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  6249. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  6250. /// </para>
  6251. /// <para>
  6252. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  6253. /// making the Subscribe or Dispose call, respectively.
  6254. /// </para>
  6255. /// <para>
  6256. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  6257. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  6258. /// more concise and easier to understand.
  6259. /// </para>
  6260. /// </remarks>
  6261. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6262. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, object target, string eventName)
  6263. #if !NO_EVENTARGS_CONSTRAINT
  6264. where TEventArgs : EventArgs
  6265. #endif
  6266. {
  6267. if (provider == null)
  6268. throw new ArgumentNullException("provider");
  6269. if (target == null)
  6270. throw new ArgumentNullException("target");
  6271. if (eventName == null)
  6272. throw new ArgumentNullException("eventName");
  6273. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6274. Expression.Call(
  6275. null,
  6276. #if CRIPPLED_REFLECTION
  6277. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(object), default(string))),
  6278. #else
  6279. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  6280. #endif
  6281. Expression.Constant(provider, typeof(IQbservableProvider)),
  6282. Expression.Constant(target, typeof(object)),
  6283. Expression.Constant(eventName, typeof(string))
  6284. )
  6285. );
  6286. }
  6287. /// <summary>
  6288. /// Converts an instance .NET event, conforming to the standard .NET event pattern with strongly typed event arguments, to an observable sequence.
  6289. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6290. /// Reflection is used to discover the event based on the target object type and the specified event name.
  6291. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6292. /// </summary>
  6293. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6294. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6295. /// <param name="target">Object instance that exposes the event to convert.</param>
  6296. /// <param name="eventName">Name of the event to convert.</param>
  6297. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  6298. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6299. /// <exception cref="T:System.ArgumentNullException">
  6300. /// <paramref name="target" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  6301. /// <exception cref="T:System.InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern. -or- The event's second argument type is not assignable to TEventArgs.</exception>
  6302. /// <remarks>
  6303. /// <para>
  6304. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6305. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6306. /// </para>
  6307. /// <para>
  6308. /// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be
  6309. /// accessed from the same context, as required by some UI frameworks.
  6310. /// </para>
  6311. /// <para>
  6312. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  6313. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  6314. /// parameter. For more information, see the remarks section on those overloads.
  6315. /// </para>
  6316. /// </remarks>
  6317. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6318. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, object target, string eventName, IScheduler scheduler)
  6319. #if !NO_EVENTARGS_CONSTRAINT
  6320. where TEventArgs : EventArgs
  6321. #endif
  6322. {
  6323. if (provider == null)
  6324. throw new ArgumentNullException("provider");
  6325. if (target == null)
  6326. throw new ArgumentNullException("target");
  6327. if (eventName == null)
  6328. throw new ArgumentNullException("eventName");
  6329. if (scheduler == null)
  6330. throw new ArgumentNullException("scheduler");
  6331. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6332. Expression.Call(
  6333. null,
  6334. #if CRIPPLED_REFLECTION
  6335. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(object), default(string), default(IScheduler))),
  6336. #else
  6337. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  6338. #endif
  6339. Expression.Constant(provider, typeof(IQbservableProvider)),
  6340. Expression.Constant(target, typeof(object)),
  6341. Expression.Constant(eventName, typeof(string)),
  6342. Expression.Constant(scheduler, typeof(IScheduler))
  6343. )
  6344. );
  6345. }
  6346. /// <summary>
  6347. /// Converts a static .NET event, conforming to the standard .NET event pattern with strongly typed event arguments, to an observable sequence.
  6348. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6349. /// Reflection is used to discover the event based on the specified type and the specified event name.
  6350. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6351. /// </summary>
  6352. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6353. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6354. /// <param name="type">Type that exposes the static event to convert.</param>
  6355. /// <param name="eventName">Name of the event to convert.</param>
  6356. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6357. /// <exception cref="T:System.ArgumentNullException">
  6358. /// <paramref name="type" /> or <paramref name="eventName" /> is null.</exception>
  6359. /// <exception cref="T:System.InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern. -or- The event's second argument type is not assignable to TEventArgs.</exception>
  6360. /// <remarks>
  6361. /// <para>
  6362. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6363. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6364. /// </para>
  6365. /// <para>
  6366. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  6367. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  6368. /// </para>
  6369. /// <para>
  6370. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  6371. /// making the Subscribe or Dispose call, respectively.
  6372. /// </para>
  6373. /// <para>
  6374. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  6375. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  6376. /// more concise and easier to understand.
  6377. /// </para>
  6378. /// </remarks>
  6379. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6380. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, Type type, string eventName)
  6381. #if !NO_EVENTARGS_CONSTRAINT
  6382. where TEventArgs : EventArgs
  6383. #endif
  6384. {
  6385. if (provider == null)
  6386. throw new ArgumentNullException("provider");
  6387. if (type == null)
  6388. throw new ArgumentNullException("type");
  6389. if (eventName == null)
  6390. throw new ArgumentNullException("eventName");
  6391. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6392. Expression.Call(
  6393. null,
  6394. #if CRIPPLED_REFLECTION
  6395. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(Type), default(string))),
  6396. #else
  6397. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  6398. #endif
  6399. Expression.Constant(provider, typeof(IQbservableProvider)),
  6400. Expression.Constant(type, typeof(Type)),
  6401. Expression.Constant(eventName, typeof(string))
  6402. )
  6403. );
  6404. }
  6405. /// <summary>
  6406. /// Converts a static .NET event, conforming to the standard .NET event pattern with strongly typed event arguments, to an observable sequence.
  6407. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6408. /// Reflection is used to discover the event based on the specified type and the specified event name.
  6409. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6410. /// </summary>
  6411. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6412. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6413. /// <param name="type">Type that exposes the static event to convert.</param>
  6414. /// <param name="eventName">Name of the event to convert.</param>
  6415. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  6416. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6417. /// <exception cref="T:System.ArgumentNullException">
  6418. /// <paramref name="type" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  6419. /// <exception cref="T:System.InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern. -or- The event's second argument type is not assignable to TEventArgs.</exception>
  6420. /// <remarks>
  6421. /// <para>
  6422. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6423. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6424. /// </para>
  6425. /// <para>
  6426. /// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be
  6427. /// accessed from the same context, as required by some UI frameworks.
  6428. /// </para>
  6429. /// <para>
  6430. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  6431. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  6432. /// parameter. For more information, see the remarks section on those overloads.
  6433. /// </para>
  6434. /// </remarks>
  6435. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6436. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, Type type, string eventName, IScheduler scheduler)
  6437. #if !NO_EVENTARGS_CONSTRAINT
  6438. where TEventArgs : EventArgs
  6439. #endif
  6440. {
  6441. if (provider == null)
  6442. throw new ArgumentNullException("provider");
  6443. if (type == null)
  6444. throw new ArgumentNullException("type");
  6445. if (eventName == null)
  6446. throw new ArgumentNullException("eventName");
  6447. if (scheduler == null)
  6448. throw new ArgumentNullException("scheduler");
  6449. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6450. Expression.Call(
  6451. null,
  6452. #if CRIPPLED_REFLECTION
  6453. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(Type), default(string), default(IScheduler))),
  6454. #else
  6455. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  6456. #endif
  6457. Expression.Constant(provider, typeof(IQbservableProvider)),
  6458. Expression.Constant(type, typeof(Type)),
  6459. Expression.Constant(eventName, typeof(string)),
  6460. Expression.Constant(scheduler, typeof(IScheduler))
  6461. )
  6462. );
  6463. }
  6464. /// <summary>
  6465. /// Converts an instance .NET event, conforming to the standard .NET event pattern with a strongly typed sender and strongly typed event arguments, to an observable sequence.
  6466. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6467. /// Reflection is used to discover the event based on the target object type and the specified event name.
  6468. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6469. /// </summary>
  6470. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6471. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  6472. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6473. /// <param name="target">Object instance that exposes the event to convert.</param>
  6474. /// <param name="eventName">Name of the event to convert.</param>
  6475. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6476. /// <exception cref="T:System.ArgumentNullException">
  6477. /// <paramref name="target" /> or <paramref name="eventName" /> is null.</exception>
  6478. /// <exception cref="T:System.InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern. -or- The event's first argument type is not assignable to TSender. -or- The event's second argument type is not assignable to TEventArgs.</exception>
  6479. /// <remarks>
  6480. /// <para>
  6481. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6482. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6483. /// </para>
  6484. /// <para>
  6485. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  6486. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  6487. /// </para>
  6488. /// <para>
  6489. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  6490. /// making the Subscribe or Dispose call, respectively.
  6491. /// </para>
  6492. /// <para>
  6493. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  6494. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  6495. /// more concise and easier to understand.
  6496. /// </para>
  6497. /// </remarks>
  6498. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6499. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(this IQbservableProvider provider, object target, string eventName)
  6500. #if !NO_EVENTARGS_CONSTRAINT
  6501. where TEventArgs : EventArgs
  6502. #endif
  6503. {
  6504. if (provider == null)
  6505. throw new ArgumentNullException("provider");
  6506. if (target == null)
  6507. throw new ArgumentNullException("target");
  6508. if (eventName == null)
  6509. throw new ArgumentNullException("eventName");
  6510. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  6511. Expression.Call(
  6512. null,
  6513. #if CRIPPLED_REFLECTION
  6514. InfoOf(() => Qbservable.FromEventPattern<TSender, TEventArgs>(default(IQbservableProvider), default(object), default(string))),
  6515. #else
  6516. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSender), typeof(TEventArgs)),
  6517. #endif
  6518. Expression.Constant(provider, typeof(IQbservableProvider)),
  6519. Expression.Constant(target, typeof(object)),
  6520. Expression.Constant(eventName, typeof(string))
  6521. )
  6522. );
  6523. }
  6524. /// <summary>
  6525. /// Converts an instance .NET event, conforming to the standard .NET event pattern with a strongly typed sender and strongly typed event arguments, to an observable sequence.
  6526. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6527. /// Reflection is used to discover the event based on the target object type and the specified event name.
  6528. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6529. /// </summary>
  6530. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6531. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  6532. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6533. /// <param name="target">Object instance that exposes the event to convert.</param>
  6534. /// <param name="eventName">Name of the event to convert.</param>
  6535. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  6536. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6537. /// <exception cref="T:System.ArgumentNullException">
  6538. /// <paramref name="target" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  6539. /// <exception cref="T:System.InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern. -or- The event's first argument type is not assignable to TSender. -or- The event's second argument type is not assignable to TEventArgs.</exception>
  6540. /// <remarks>
  6541. /// <para>
  6542. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6543. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6544. /// </para>
  6545. /// <para>
  6546. /// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be
  6547. /// accessed from the same context, as required by some UI frameworks.
  6548. /// </para>
  6549. /// <para>
  6550. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  6551. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  6552. /// parameter. For more information, see the remarks section on those overloads.
  6553. /// </para>
  6554. /// </remarks>
  6555. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6556. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(this IQbservableProvider provider, object target, string eventName, IScheduler scheduler)
  6557. #if !NO_EVENTARGS_CONSTRAINT
  6558. where TEventArgs : EventArgs
  6559. #endif
  6560. {
  6561. if (provider == null)
  6562. throw new ArgumentNullException("provider");
  6563. if (target == null)
  6564. throw new ArgumentNullException("target");
  6565. if (eventName == null)
  6566. throw new ArgumentNullException("eventName");
  6567. if (scheduler == null)
  6568. throw new ArgumentNullException("scheduler");
  6569. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  6570. Expression.Call(
  6571. null,
  6572. #if CRIPPLED_REFLECTION
  6573. InfoOf(() => Qbservable.FromEventPattern<TSender, TEventArgs>(default(IQbservableProvider), default(object), default(string), default(IScheduler))),
  6574. #else
  6575. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSender), typeof(TEventArgs)),
  6576. #endif
  6577. Expression.Constant(provider, typeof(IQbservableProvider)),
  6578. Expression.Constant(target, typeof(object)),
  6579. Expression.Constant(eventName, typeof(string)),
  6580. Expression.Constant(scheduler, typeof(IScheduler))
  6581. )
  6582. );
  6583. }
  6584. /// <summary>
  6585. /// Converts a static .NET event, conforming to the standard .NET event pattern with a strongly typed sender and strongly typed event arguments, to an observable sequence.
  6586. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6587. /// Reflection is used to discover the event based on the specified type and the specified event name.
  6588. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6589. /// </summary>
  6590. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6591. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  6592. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6593. /// <param name="type">Type that exposes the static event to convert.</param>
  6594. /// <param name="eventName">Name of the event to convert.</param>
  6595. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6596. /// <exception cref="T:System.ArgumentNullException">
  6597. /// <paramref name="type" /> or <paramref name="eventName" /> is null.</exception>
  6598. /// <exception cref="T:System.InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern. -or- The event's first argument type is not assignable to TSender. -or- The event's second argument type is not assignable to TEventArgs.</exception>
  6599. /// <remarks>
  6600. /// <para>
  6601. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6602. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6603. /// </para>
  6604. /// <para>
  6605. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  6606. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  6607. /// </para>
  6608. /// <para>
  6609. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  6610. /// making the Subscribe or Dispose call, respectively.
  6611. /// </para>
  6612. /// <para>
  6613. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  6614. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  6615. /// more concise and easier to understand.
  6616. /// </para>
  6617. /// </remarks>
  6618. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6619. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(this IQbservableProvider provider, Type type, string eventName)
  6620. #if !NO_EVENTARGS_CONSTRAINT
  6621. where TEventArgs : EventArgs
  6622. #endif
  6623. {
  6624. if (provider == null)
  6625. throw new ArgumentNullException("provider");
  6626. if (type == null)
  6627. throw new ArgumentNullException("type");
  6628. if (eventName == null)
  6629. throw new ArgumentNullException("eventName");
  6630. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  6631. Expression.Call(
  6632. null,
  6633. #if CRIPPLED_REFLECTION
  6634. InfoOf(() => Qbservable.FromEventPattern<TSender, TEventArgs>(default(IQbservableProvider), default(Type), default(string))),
  6635. #else
  6636. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSender), typeof(TEventArgs)),
  6637. #endif
  6638. Expression.Constant(provider, typeof(IQbservableProvider)),
  6639. Expression.Constant(type, typeof(Type)),
  6640. Expression.Constant(eventName, typeof(string))
  6641. )
  6642. );
  6643. }
  6644. /// <summary>
  6645. /// Converts a static .NET event, conforming to the standard .NET event pattern with a strongly typed sender and strongly typed event arguments, to an observable sequence.
  6646. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6647. /// Reflection is used to discover the event based on the specified type and the specified event name.
  6648. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6649. /// </summary>
  6650. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6651. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  6652. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6653. /// <param name="type">Type that exposes the static event to convert.</param>
  6654. /// <param name="eventName">Name of the event to convert.</param>
  6655. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  6656. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6657. /// <exception cref="T:System.ArgumentNullException">
  6658. /// <paramref name="type" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  6659. /// <exception cref="T:System.InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern. -or- The event's first argument type is not assignable to TSender. -or- The event's second argument type is not assignable to TEventArgs.</exception>
  6660. /// <remarks>
  6661. /// <para>
  6662. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6663. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6664. /// </para>
  6665. /// <para>
  6666. /// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be
  6667. /// accessed from the same context, as required by some UI frameworks.
  6668. /// </para>
  6669. /// <para>
  6670. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  6671. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  6672. /// parameter. For more information, see the remarks section on those overloads.
  6673. /// </para>
  6674. /// </remarks>
  6675. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6676. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(this IQbservableProvider provider, Type type, string eventName, IScheduler scheduler)
  6677. #if !NO_EVENTARGS_CONSTRAINT
  6678. where TEventArgs : EventArgs
  6679. #endif
  6680. {
  6681. if (provider == null)
  6682. throw new ArgumentNullException("provider");
  6683. if (type == null)
  6684. throw new ArgumentNullException("type");
  6685. if (eventName == null)
  6686. throw new ArgumentNullException("eventName");
  6687. if (scheduler == null)
  6688. throw new ArgumentNullException("scheduler");
  6689. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  6690. Expression.Call(
  6691. null,
  6692. #if CRIPPLED_REFLECTION
  6693. InfoOf(() => Qbservable.FromEventPattern<TSender, TEventArgs>(default(IQbservableProvider), default(Type), default(string), default(IScheduler))),
  6694. #else
  6695. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSender), typeof(TEventArgs)),
  6696. #endif
  6697. Expression.Constant(provider, typeof(IQbservableProvider)),
  6698. Expression.Constant(type, typeof(Type)),
  6699. Expression.Constant(eventName, typeof(string)),
  6700. Expression.Constant(scheduler, typeof(IScheduler))
  6701. )
  6702. );
  6703. }
  6704. /// <summary>
  6705. /// Generates an observable sequence by running a state-driven loop producing the sequence's elements.
  6706. /// </summary>
  6707. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6708. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6709. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6710. /// <param name="initialState">Initial state.</param>
  6711. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6712. /// <param name="iterate">Iteration step function.</param>
  6713. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6714. /// <returns>The generated sequence.</returns>
  6715. /// <exception cref="T:System.ArgumentNullException">
  6716. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> is null.</exception>
  6717. public static IQbservable<TResult> Generate<TState, TResult>(this IQbservableProvider provider, TState initialState, Expression<Func<TState, bool>> condition, Expression<Func<TState, TState>> iterate, Expression<Func<TState, TResult>> resultSelector)
  6718. {
  6719. if (provider == null)
  6720. throw new ArgumentNullException("provider");
  6721. if (condition == null)
  6722. throw new ArgumentNullException("condition");
  6723. if (iterate == null)
  6724. throw new ArgumentNullException("iterate");
  6725. if (resultSelector == null)
  6726. throw new ArgumentNullException("resultSelector");
  6727. return provider.CreateQuery<TResult>(
  6728. Expression.Call(
  6729. null,
  6730. #if CRIPPLED_REFLECTION
  6731. InfoOf(() => Qbservable.Generate<TState, TResult>(default(IQbservableProvider), default(TState), default(Expression<Func<TState, bool>>), default(Expression<Func<TState, TState>>), default(Expression<Func<TState, TResult>>))),
  6732. #else
  6733. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6734. #endif
  6735. Expression.Constant(provider, typeof(IQbservableProvider)),
  6736. Expression.Constant(initialState, typeof(TState)),
  6737. condition,
  6738. iterate,
  6739. resultSelector
  6740. )
  6741. );
  6742. }
  6743. /// <summary>
  6744. /// Generates an observable sequence by running a state-driven loop producing the sequence's elements, using the specified scheduler to send out observer messages.
  6745. /// </summary>
  6746. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6747. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6748. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6749. /// <param name="initialState">Initial state.</param>
  6750. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6751. /// <param name="iterate">Iteration step function.</param>
  6752. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6753. /// <param name="scheduler">Scheduler on which to run the generator loop.</param>
  6754. /// <returns>The generated sequence.</returns>
  6755. /// <exception cref="T:System.ArgumentNullException">
  6756. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> or <paramref name="scheduler" /> is null.</exception>
  6757. public static IQbservable<TResult> Generate<TState, TResult>(this IQbservableProvider provider, TState initialState, Expression<Func<TState, bool>> condition, Expression<Func<TState, TState>> iterate, Expression<Func<TState, TResult>> resultSelector, IScheduler scheduler)
  6758. {
  6759. if (provider == null)
  6760. throw new ArgumentNullException("provider");
  6761. if (condition == null)
  6762. throw new ArgumentNullException("condition");
  6763. if (iterate == null)
  6764. throw new ArgumentNullException("iterate");
  6765. if (resultSelector == null)
  6766. throw new ArgumentNullException("resultSelector");
  6767. if (scheduler == null)
  6768. throw new ArgumentNullException("scheduler");
  6769. return provider.CreateQuery<TResult>(
  6770. Expression.Call(
  6771. null,
  6772. #if CRIPPLED_REFLECTION
  6773. InfoOf(() => Qbservable.Generate<TState, TResult>(default(IQbservableProvider), default(TState), default(Expression<Func<TState, bool>>), default(Expression<Func<TState, TState>>), default(Expression<Func<TState, TResult>>), default(IScheduler))),
  6774. #else
  6775. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6776. #endif
  6777. Expression.Constant(provider, typeof(IQbservableProvider)),
  6778. Expression.Constant(initialState, typeof(TState)),
  6779. condition,
  6780. iterate,
  6781. resultSelector,
  6782. Expression.Constant(scheduler, typeof(IScheduler))
  6783. )
  6784. );
  6785. }
  6786. /// <summary>
  6787. /// Generates an observable sequence by running a state-driven and temporal loop producing the sequence's elements.
  6788. /// </summary>
  6789. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6790. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6791. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6792. /// <param name="initialState">Initial state.</param>
  6793. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6794. /// <param name="iterate">Iteration step function.</param>
  6795. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6796. /// <param name="timeSelector">Time selector function to control the speed of values being produced each iteration.</param>
  6797. /// <returns>The generated sequence.</returns>
  6798. /// <exception cref="T:System.ArgumentNullException">
  6799. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> or <paramref name="timeSelector" /> is null.</exception>
  6800. public static IQbservable<TResult> Generate<TState, TResult>(this IQbservableProvider provider, TState initialState, Expression<Func<TState, bool>> condition, Expression<Func<TState, TState>> iterate, Expression<Func<TState, TResult>> resultSelector, Expression<Func<TState, TimeSpan>> timeSelector)
  6801. {
  6802. if (provider == null)
  6803. throw new ArgumentNullException("provider");
  6804. if (condition == null)
  6805. throw new ArgumentNullException("condition");
  6806. if (iterate == null)
  6807. throw new ArgumentNullException("iterate");
  6808. if (resultSelector == null)
  6809. throw new ArgumentNullException("resultSelector");
  6810. if (timeSelector == null)
  6811. throw new ArgumentNullException("timeSelector");
  6812. return provider.CreateQuery<TResult>(
  6813. Expression.Call(
  6814. null,
  6815. #if CRIPPLED_REFLECTION
  6816. InfoOf(() => Qbservable.Generate<TState, TResult>(default(IQbservableProvider), default(TState), default(Expression<Func<TState, bool>>), default(Expression<Func<TState, TState>>), default(Expression<Func<TState, TResult>>), default(Expression<Func<TState, TimeSpan>>))),
  6817. #else
  6818. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6819. #endif
  6820. Expression.Constant(provider, typeof(IQbservableProvider)),
  6821. Expression.Constant(initialState, typeof(TState)),
  6822. condition,
  6823. iterate,
  6824. resultSelector,
  6825. timeSelector
  6826. )
  6827. );
  6828. }
  6829. /// <summary>
  6830. /// Generates an observable sequence by running a state-driven and temporal loop producing the sequence's elements.
  6831. /// </summary>
  6832. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6833. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6834. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6835. /// <param name="initialState">Initial state.</param>
  6836. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6837. /// <param name="iterate">Iteration step function.</param>
  6838. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6839. /// <param name="timeSelector">Time selector function to control the speed of values being produced each iteration.</param>
  6840. /// <returns>The generated sequence.</returns>
  6841. /// <exception cref="T:System.ArgumentNullException">
  6842. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> or <paramref name="timeSelector" /> is null.</exception>
  6843. public static IQbservable<TResult> Generate<TState, TResult>(this IQbservableProvider provider, TState initialState, Expression<Func<TState, bool>> condition, Expression<Func<TState, TState>> iterate, Expression<Func<TState, TResult>> resultSelector, Expression<Func<TState, DateTimeOffset>> timeSelector)
  6844. {
  6845. if (provider == null)
  6846. throw new ArgumentNullException("provider");
  6847. if (condition == null)
  6848. throw new ArgumentNullException("condition");
  6849. if (iterate == null)
  6850. throw new ArgumentNullException("iterate");
  6851. if (resultSelector == null)
  6852. throw new ArgumentNullException("resultSelector");
  6853. if (timeSelector == null)
  6854. throw new ArgumentNullException("timeSelector");
  6855. return provider.CreateQuery<TResult>(
  6856. Expression.Call(
  6857. null,
  6858. #if CRIPPLED_REFLECTION
  6859. InfoOf(() => Qbservable.Generate<TState, TResult>(default(IQbservableProvider), default(TState), default(Expression<Func<TState, bool>>), default(Expression<Func<TState, TState>>), default(Expression<Func<TState, TResult>>), default(Expression<Func<TState, DateTimeOffset>>))),
  6860. #else
  6861. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6862. #endif
  6863. Expression.Constant(provider, typeof(IQbservableProvider)),
  6864. Expression.Constant(initialState, typeof(TState)),
  6865. condition,
  6866. iterate,
  6867. resultSelector,
  6868. timeSelector
  6869. )
  6870. );
  6871. }
  6872. /// <summary>
  6873. /// Generates an observable sequence by running a state-driven and temporal loop producing the sequence's elements, using the specified scheduler to run timers and to send out observer messages.
  6874. /// </summary>
  6875. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6876. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6877. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6878. /// <param name="initialState">Initial state.</param>
  6879. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6880. /// <param name="iterate">Iteration step function.</param>
  6881. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6882. /// <param name="timeSelector">Time selector function to control the speed of values being produced each iteration.</param>
  6883. /// <param name="scheduler">Scheduler on which to run the generator loop.</param>
  6884. /// <returns>The generated sequence.</returns>
  6885. /// <exception cref="T:System.ArgumentNullException">
  6886. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> or <paramref name="timeSelector" /> or <paramref name="scheduler" /> is null.</exception>
  6887. public static IQbservable<TResult> Generate<TState, TResult>(this IQbservableProvider provider, TState initialState, Expression<Func<TState, bool>> condition, Expression<Func<TState, TState>> iterate, Expression<Func<TState, TResult>> resultSelector, Expression<Func<TState, TimeSpan>> timeSelector, IScheduler scheduler)
  6888. {
  6889. if (provider == null)
  6890. throw new ArgumentNullException("provider");
  6891. if (condition == null)
  6892. throw new ArgumentNullException("condition");
  6893. if (iterate == null)
  6894. throw new ArgumentNullException("iterate");
  6895. if (resultSelector == null)
  6896. throw new ArgumentNullException("resultSelector");
  6897. if (timeSelector == null)
  6898. throw new ArgumentNullException("timeSelector");
  6899. if (scheduler == null)
  6900. throw new ArgumentNullException("scheduler");
  6901. return provider.CreateQuery<TResult>(
  6902. Expression.Call(
  6903. null,
  6904. #if CRIPPLED_REFLECTION
  6905. InfoOf(() => Qbservable.Generate<TState, TResult>(default(IQbservableProvider), default(TState), default(Expression<Func<TState, bool>>), default(Expression<Func<TState, TState>>), default(Expression<Func<TState, TResult>>), default(Expression<Func<TState, TimeSpan>>), default(IScheduler))),
  6906. #else
  6907. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6908. #endif
  6909. Expression.Constant(provider, typeof(IQbservableProvider)),
  6910. Expression.Constant(initialState, typeof(TState)),
  6911. condition,
  6912. iterate,
  6913. resultSelector,
  6914. timeSelector,
  6915. Expression.Constant(scheduler, typeof(IScheduler))
  6916. )
  6917. );
  6918. }
  6919. /// <summary>
  6920. /// Generates an observable sequence by running a state-driven and temporal loop producing the sequence's elements, using the specified scheduler to run timers and to send out observer messages.
  6921. /// </summary>
  6922. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  6923. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6924. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6925. /// <param name="initialState">Initial state.</param>
  6926. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6927. /// <param name="iterate">Iteration step function.</param>
  6928. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6929. /// <param name="timeSelector">Time selector function to control the speed of values being produced each iteration.</param>
  6930. /// <param name="scheduler">Scheduler on which to run the generator loop.</param>
  6931. /// <returns>The generated sequence.</returns>
  6932. /// <exception cref="T:System.ArgumentNullException">
  6933. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> or <paramref name="timeSelector" /> or <paramref name="scheduler" /> is null.</exception>
  6934. public static IQbservable<TResult> Generate<TState, TResult>(this IQbservableProvider provider, TState initialState, Expression<Func<TState, bool>> condition, Expression<Func<TState, TState>> iterate, Expression<Func<TState, TResult>> resultSelector, Expression<Func<TState, DateTimeOffset>> timeSelector, IScheduler scheduler)
  6935. {
  6936. if (provider == null)
  6937. throw new ArgumentNullException("provider");
  6938. if (condition == null)
  6939. throw new ArgumentNullException("condition");
  6940. if (iterate == null)
  6941. throw new ArgumentNullException("iterate");
  6942. if (resultSelector == null)
  6943. throw new ArgumentNullException("resultSelector");
  6944. if (timeSelector == null)
  6945. throw new ArgumentNullException("timeSelector");
  6946. if (scheduler == null)
  6947. throw new ArgumentNullException("scheduler");
  6948. return provider.CreateQuery<TResult>(
  6949. Expression.Call(
  6950. null,
  6951. #if CRIPPLED_REFLECTION
  6952. InfoOf(() => Qbservable.Generate<TState, TResult>(default(IQbservableProvider), default(TState), default(Expression<Func<TState, bool>>), default(Expression<Func<TState, TState>>), default(Expression<Func<TState, TResult>>), default(Expression<Func<TState, DateTimeOffset>>), default(IScheduler))),
  6953. #else
  6954. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6955. #endif
  6956. Expression.Constant(provider, typeof(IQbservableProvider)),
  6957. Expression.Constant(initialState, typeof(TState)),
  6958. condition,
  6959. iterate,
  6960. resultSelector,
  6961. timeSelector,
  6962. Expression.Constant(scheduler, typeof(IScheduler))
  6963. )
  6964. );
  6965. }
  6966. /// <summary>
  6967. /// Groups the elements of an observable sequence according to a specified key selector function.
  6968. /// </summary>
  6969. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  6970. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  6971. /// <param name="source">An observable sequence whose elements to group.</param>
  6972. /// <param name="keySelector">A function to extract the key for each element.</param>
  6973. /// <returns>A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.</returns>
  6974. /// <exception cref="T:System.ArgumentNullException">
  6975. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  6976. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  6977. {
  6978. if (source == null)
  6979. throw new ArgumentNullException("source");
  6980. if (keySelector == null)
  6981. throw new ArgumentNullException("keySelector");
  6982. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  6983. Expression.Call(
  6984. null,
  6985. #if CRIPPLED_REFLECTION
  6986. InfoOf(() => Qbservable.GroupBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  6987. #else
  6988. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  6989. #endif
  6990. source.Expression,
  6991. keySelector
  6992. )
  6993. );
  6994. }
  6995. /// <summary>
  6996. /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function.
  6997. /// </summary>
  6998. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  6999. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7000. /// <param name="source">An observable sequence whose elements to group.</param>
  7001. /// <param name="keySelector">A function to extract the key for each element.</param>
  7002. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7003. /// <returns>A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.</returns>
  7004. /// <exception cref="T:System.ArgumentNullException">
  7005. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  7006. /// <exception cref="T:System.ArgumentOutOfRangeException">
  7007. /// <paramref name="capacity" /> is less than 0.</exception>
  7008. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, int capacity)
  7009. {
  7010. if (source == null)
  7011. throw new ArgumentNullException("source");
  7012. if (keySelector == null)
  7013. throw new ArgumentNullException("keySelector");
  7014. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7015. Expression.Call(
  7016. null,
  7017. #if CRIPPLED_REFLECTION
  7018. InfoOf(() => Qbservable.GroupBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(int))),
  7019. #else
  7020. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  7021. #endif
  7022. source.Expression,
  7023. keySelector,
  7024. Expression.Constant(capacity, typeof(int))
  7025. )
  7026. );
  7027. }
  7028. /// <summary>
  7029. /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function and comparer.
  7030. /// </summary>
  7031. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7032. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7033. /// <param name="source">An observable sequence whose elements to group.</param>
  7034. /// <param name="keySelector">A function to extract the key for each element.</param>
  7035. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7036. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7037. /// <returns>A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.</returns>
  7038. /// <exception cref="T:System.ArgumentNullException">
  7039. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  7040. /// <exception cref="T:System.ArgumentOutOfRangeException">
  7041. /// <paramref name="capacity" /> is less than 0.</exception>
  7042. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, int capacity, IEqualityComparer<TKey> comparer)
  7043. {
  7044. if (source == null)
  7045. throw new ArgumentNullException("source");
  7046. if (keySelector == null)
  7047. throw new ArgumentNullException("keySelector");
  7048. if (comparer == null)
  7049. throw new ArgumentNullException("comparer");
  7050. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7051. Expression.Call(
  7052. null,
  7053. #if CRIPPLED_REFLECTION
  7054. InfoOf(() => Qbservable.GroupBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(int), default(IEqualityComparer<TKey>))),
  7055. #else
  7056. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  7057. #endif
  7058. source.Expression,
  7059. keySelector,
  7060. Expression.Constant(capacity, typeof(int)),
  7061. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7062. )
  7063. );
  7064. }
  7065. /// <summary>
  7066. /// Groups the elements of an observable sequence according to a specified key selector function and comparer.
  7067. /// </summary>
  7068. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7069. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7070. /// <param name="source">An observable sequence whose elements to group.</param>
  7071. /// <param name="keySelector">A function to extract the key for each element.</param>
  7072. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7073. /// <returns>A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.</returns>
  7074. /// <exception cref="T:System.ArgumentNullException">
  7075. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  7076. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  7077. {
  7078. if (source == null)
  7079. throw new ArgumentNullException("source");
  7080. if (keySelector == null)
  7081. throw new ArgumentNullException("keySelector");
  7082. if (comparer == null)
  7083. throw new ArgumentNullException("comparer");
  7084. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7085. Expression.Call(
  7086. null,
  7087. #if CRIPPLED_REFLECTION
  7088. InfoOf(() => Qbservable.GroupBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IEqualityComparer<TKey>))),
  7089. #else
  7090. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  7091. #endif
  7092. source.Expression,
  7093. keySelector,
  7094. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7095. )
  7096. );
  7097. }
  7098. /// <summary>
  7099. /// Groups the elements of an observable sequence and selects the resulting elements by using a specified function.
  7100. /// </summary>
  7101. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7102. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7103. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7104. /// <param name="source">An observable sequence whose elements to group.</param>
  7105. /// <param name="keySelector">A function to extract the key for each element.</param>
  7106. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7107. /// <returns>A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.</returns>
  7108. /// <exception cref="T:System.ArgumentNullException">
  7109. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> is null.</exception>
  7110. public static IQbservable<IGroupedObservable<TKey, TElement>> GroupBy<TSource, TKey, TElement>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector)
  7111. {
  7112. if (source == null)
  7113. throw new ArgumentNullException("source");
  7114. if (keySelector == null)
  7115. throw new ArgumentNullException("keySelector");
  7116. if (elementSelector == null)
  7117. throw new ArgumentNullException("elementSelector");
  7118. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7119. Expression.Call(
  7120. null,
  7121. #if CRIPPLED_REFLECTION
  7122. InfoOf(() => Qbservable.GroupBy<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>))),
  7123. #else
  7124. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  7125. #endif
  7126. source.Expression,
  7127. keySelector,
  7128. elementSelector
  7129. )
  7130. );
  7131. }
  7132. /// <summary>
  7133. /// Groups the elements of an observable sequence with the specified initial capacity and selects the resulting elements by using a specified function.
  7134. /// </summary>
  7135. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7136. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7137. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7138. /// <param name="source">An observable sequence whose elements to group.</param>
  7139. /// <param name="keySelector">A function to extract the key for each element.</param>
  7140. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7141. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7142. /// <returns>A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.</returns>
  7143. /// <exception cref="T:System.ArgumentNullException">
  7144. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> is null.</exception>
  7145. /// <exception cref="T:System.ArgumentOutOfRangeException">
  7146. /// <paramref name="capacity" /> is less than 0.</exception>
  7147. public static IQbservable<IGroupedObservable<TKey, TElement>> GroupBy<TSource, TKey, TElement>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector, int capacity)
  7148. {
  7149. if (source == null)
  7150. throw new ArgumentNullException("source");
  7151. if (keySelector == null)
  7152. throw new ArgumentNullException("keySelector");
  7153. if (elementSelector == null)
  7154. throw new ArgumentNullException("elementSelector");
  7155. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7156. Expression.Call(
  7157. null,
  7158. #if CRIPPLED_REFLECTION
  7159. InfoOf(() => Qbservable.GroupBy<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(int))),
  7160. #else
  7161. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  7162. #endif
  7163. source.Expression,
  7164. keySelector,
  7165. elementSelector,
  7166. Expression.Constant(capacity, typeof(int))
  7167. )
  7168. );
  7169. }
  7170. /// <summary>
  7171. /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function and comparer and selects the resulting elements by using a specified function.
  7172. /// </summary>
  7173. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7174. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7175. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7176. /// <param name="source">An observable sequence whose elements to group.</param>
  7177. /// <param name="keySelector">A function to extract the key for each element.</param>
  7178. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7179. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7180. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7181. /// <returns>A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.</returns>
  7182. /// <exception cref="T:System.ArgumentNullException">
  7183. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="comparer" /> is null.</exception>
  7184. /// <exception cref="T:System.ArgumentOutOfRangeException">
  7185. /// <paramref name="capacity" /> is less than 0.</exception>
  7186. public static IQbservable<IGroupedObservable<TKey, TElement>> GroupBy<TSource, TKey, TElement>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector, int capacity, IEqualityComparer<TKey> comparer)
  7187. {
  7188. if (source == null)
  7189. throw new ArgumentNullException("source");
  7190. if (keySelector == null)
  7191. throw new ArgumentNullException("keySelector");
  7192. if (elementSelector == null)
  7193. throw new ArgumentNullException("elementSelector");
  7194. if (comparer == null)
  7195. throw new ArgumentNullException("comparer");
  7196. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7197. Expression.Call(
  7198. null,
  7199. #if CRIPPLED_REFLECTION
  7200. InfoOf(() => Qbservable.GroupBy<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(int), default(IEqualityComparer<TKey>))),
  7201. #else
  7202. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  7203. #endif
  7204. source.Expression,
  7205. keySelector,
  7206. elementSelector,
  7207. Expression.Constant(capacity, typeof(int)),
  7208. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7209. )
  7210. );
  7211. }
  7212. /// <summary>
  7213. /// Groups the elements of an observable sequence according to a specified key selector function and comparer and selects the resulting elements by using a specified function.
  7214. /// </summary>
  7215. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7216. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7217. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7218. /// <param name="source">An observable sequence whose elements to group.</param>
  7219. /// <param name="keySelector">A function to extract the key for each element.</param>
  7220. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7221. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7222. /// <returns>A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.</returns>
  7223. /// <exception cref="T:System.ArgumentNullException">
  7224. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="comparer" /> is null.</exception>
  7225. public static IQbservable<IGroupedObservable<TKey, TElement>> GroupBy<TSource, TKey, TElement>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector, IEqualityComparer<TKey> comparer)
  7226. {
  7227. if (source == null)
  7228. throw new ArgumentNullException("source");
  7229. if (keySelector == null)
  7230. throw new ArgumentNullException("keySelector");
  7231. if (elementSelector == null)
  7232. throw new ArgumentNullException("elementSelector");
  7233. if (comparer == null)
  7234. throw new ArgumentNullException("comparer");
  7235. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7236. Expression.Call(
  7237. null,
  7238. #if CRIPPLED_REFLECTION
  7239. InfoOf(() => Qbservable.GroupBy<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(IEqualityComparer<TKey>))),
  7240. #else
  7241. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  7242. #endif
  7243. source.Expression,
  7244. keySelector,
  7245. elementSelector,
  7246. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7247. )
  7248. );
  7249. }
  7250. /// <summary>
  7251. /// Groups the elements of an observable sequence according to a specified key selector function.
  7252. /// A duration selector function is used to control the lifetime of groups. When a group expires, it receives an OnCompleted notification. When a new element with the same
  7253. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7254. /// </summary>
  7255. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7256. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7257. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7258. /// <param name="source">An observable sequence whose elements to group.</param>
  7259. /// <param name="keySelector">A function to extract the key for each element.</param>
  7260. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7261. /// <returns>
  7262. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7263. /// If a group's lifetime expires, a new group with the same key value can be created once an element with such a key value is encoutered.
  7264. /// </returns>
  7265. /// <exception cref="T:System.ArgumentNullException">
  7266. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="durationSelector" /> is null.</exception>
  7267. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupByUntil<TSource, TKey, TDuration>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<IGroupedObservable<TKey, TSource>, IObservable<TDuration>>> durationSelector)
  7268. {
  7269. if (source == null)
  7270. throw new ArgumentNullException("source");
  7271. if (keySelector == null)
  7272. throw new ArgumentNullException("keySelector");
  7273. if (durationSelector == null)
  7274. throw new ArgumentNullException("durationSelector");
  7275. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7276. Expression.Call(
  7277. null,
  7278. #if CRIPPLED_REFLECTION
  7279. InfoOf(() => Qbservable.GroupByUntil<TSource, TKey, TDuration>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<IGroupedObservable<TKey, TSource>, IObservable<TDuration>>>))),
  7280. #else
  7281. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TDuration)),
  7282. #endif
  7283. source.Expression,
  7284. keySelector,
  7285. durationSelector
  7286. )
  7287. );
  7288. }
  7289. /// <summary>
  7290. /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function.
  7291. /// A duration selector function is used to control the lifetime of groups. When a group expires, it receives an OnCompleted notification. When a new element with the same
  7292. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7293. /// </summary>
  7294. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7295. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7296. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7297. /// <param name="source">An observable sequence whose elements to group.</param>
  7298. /// <param name="keySelector">A function to extract the key for each element.</param>
  7299. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7300. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7301. /// <returns>
  7302. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7303. /// If a group's lifetime expires, a new group with the same key value can be created once an element with such a key value is encoutered.
  7304. /// </returns>
  7305. /// <exception cref="T:System.ArgumentNullException">
  7306. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="durationSelector" /> is null.</exception>
  7307. /// <exception cref="T:System.ArgumentOutOfRangeException">
  7308. /// <paramref name="capacity" /> is less than 0.</exception>
  7309. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupByUntil<TSource, TKey, TDuration>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<IGroupedObservable<TKey, TSource>, IObservable<TDuration>>> durationSelector, int capacity)
  7310. {
  7311. if (source == null)
  7312. throw new ArgumentNullException("source");
  7313. if (keySelector == null)
  7314. throw new ArgumentNullException("keySelector");
  7315. if (durationSelector == null)
  7316. throw new ArgumentNullException("durationSelector");
  7317. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7318. Expression.Call(
  7319. null,
  7320. #if CRIPPLED_REFLECTION
  7321. InfoOf(() => Qbservable.GroupByUntil<TSource, TKey, TDuration>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<IGroupedObservable<TKey, TSource>, IObservable<TDuration>>>), default(int))),
  7322. #else
  7323. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TDuration)),
  7324. #endif
  7325. source.Expression,
  7326. keySelector,
  7327. durationSelector,
  7328. Expression.Constant(capacity, typeof(int))
  7329. )
  7330. );
  7331. }
  7332. /// <summary>
  7333. /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function and comparer.
  7334. /// A duration selector function is used to control the lifetime of groups. When a group expires, it receives an OnCompleted notification. When a new element with the same
  7335. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7336. /// </summary>
  7337. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7338. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7339. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7340. /// <param name="source">An observable sequence whose elements to group.</param>
  7341. /// <param name="keySelector">A function to extract the key for each element.</param>
  7342. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7343. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7344. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7345. /// <returns>
  7346. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7347. /// If a group's lifetime expires, a new group with the same key value can be created once an element with such a key value is encoutered.
  7348. /// </returns>
  7349. /// <exception cref="T:System.ArgumentNullException">
  7350. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="durationSelector" /> or <paramref name="comparer" /> is null.</exception>
  7351. /// <exception cref="T:System.ArgumentOutOfRangeException">
  7352. /// <paramref name="capacity" /> is less than 0.</exception>
  7353. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupByUntil<TSource, TKey, TDuration>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<IGroupedObservable<TKey, TSource>, IObservable<TDuration>>> durationSelector, int capacity, IEqualityComparer<TKey> comparer)
  7354. {
  7355. if (source == null)
  7356. throw new ArgumentNullException("source");
  7357. if (keySelector == null)
  7358. throw new ArgumentNullException("keySelector");
  7359. if (durationSelector == null)
  7360. throw new ArgumentNullException("durationSelector");
  7361. if (comparer == null)
  7362. throw new ArgumentNullException("comparer");
  7363. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7364. Expression.Call(
  7365. null,
  7366. #if CRIPPLED_REFLECTION
  7367. InfoOf(() => Qbservable.GroupByUntil<TSource, TKey, TDuration>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<IGroupedObservable<TKey, TSource>, IObservable<TDuration>>>), default(int), default(IEqualityComparer<TKey>))),
  7368. #else
  7369. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TDuration)),
  7370. #endif
  7371. source.Expression,
  7372. keySelector,
  7373. durationSelector,
  7374. Expression.Constant(capacity, typeof(int)),
  7375. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7376. )
  7377. );
  7378. }
  7379. /// <summary>
  7380. /// Groups the elements of an observable sequence according to a specified key selector function and comparer.
  7381. /// A duration selector function is used to control the lifetime of groups. When a group expires, it receives an OnCompleted notification. When a new element with the same
  7382. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7383. /// </summary>
  7384. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7385. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7386. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7387. /// <param name="source">An observable sequence whose elements to group.</param>
  7388. /// <param name="keySelector">A function to extract the key for each element.</param>
  7389. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7390. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7391. /// <returns>
  7392. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7393. /// If a group's lifetime expires, a new group with the same key value can be created once an element with such a key value is encoutered.
  7394. /// </returns>
  7395. /// <exception cref="T:System.ArgumentNullException">
  7396. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="durationSelector" /> or <paramref name="comparer" /> is null.</exception>
  7397. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupByUntil<TSource, TKey, TDuration>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<IGroupedObservable<TKey, TSource>, IObservable<TDuration>>> durationSelector, IEqualityComparer<TKey> comparer)
  7398. {
  7399. if (source == null)
  7400. throw new ArgumentNullException("source");
  7401. if (keySelector == null)
  7402. throw new ArgumentNullException("keySelector");
  7403. if (durationSelector == null)
  7404. throw new ArgumentNullException("durationSelector");
  7405. if (comparer == null)
  7406. throw new ArgumentNullException("comparer");
  7407. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7408. Expression.Call(
  7409. null,
  7410. #if CRIPPLED_REFLECTION
  7411. InfoOf(() => Qbservable.GroupByUntil<TSource, TKey, TDuration>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<IGroupedObservable<TKey, TSource>, IObservable<TDuration>>>), default(IEqualityComparer<TKey>))),
  7412. #else
  7413. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TDuration)),
  7414. #endif
  7415. source.Expression,
  7416. keySelector,
  7417. durationSelector,
  7418. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7419. )
  7420. );
  7421. }
  7422. /// <summary>
  7423. /// Groups the elements of an observable sequence according to a specified key selector function and selects the resulting elements by using a specified function.
  7424. /// A duration selector function is used to control the lifetime of groups. When a group expires, it receives an OnCompleted notification. When a new element with the same
  7425. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7426. /// </summary>
  7427. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7428. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7429. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7430. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7431. /// <param name="source">An observable sequence whose elements to group.</param>
  7432. /// <param name="keySelector">A function to extract the key for each element.</param>
  7433. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7434. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7435. /// <returns>
  7436. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7437. /// If a group's lifetime expires, a new group with the same key value can be created once an element with such a key value is encoutered.
  7438. /// </returns>
  7439. /// <exception cref="T:System.ArgumentNullException">
  7440. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="durationSelector" /> is null.</exception>
  7441. public static IQbservable<IGroupedObservable<TKey, TElement>> GroupByUntil<TSource, TKey, TElement, TDuration>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector, Expression<Func<IGroupedObservable<TKey, TElement>, IObservable<TDuration>>> durationSelector)
  7442. {
  7443. if (source == null)
  7444. throw new ArgumentNullException("source");
  7445. if (keySelector == null)
  7446. throw new ArgumentNullException("keySelector");
  7447. if (elementSelector == null)
  7448. throw new ArgumentNullException("elementSelector");
  7449. if (durationSelector == null)
  7450. throw new ArgumentNullException("durationSelector");
  7451. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7452. Expression.Call(
  7453. null,
  7454. #if CRIPPLED_REFLECTION
  7455. InfoOf(() => Qbservable.GroupByUntil<TSource, TKey, TElement, TDuration>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(Expression<Func<IGroupedObservable<TKey, TElement>, IObservable<TDuration>>>))),
  7456. #else
  7457. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TDuration)),
  7458. #endif
  7459. source.Expression,
  7460. keySelector,
  7461. elementSelector,
  7462. durationSelector
  7463. )
  7464. );
  7465. }
  7466. /// <summary>
  7467. /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function and selects the resulting elements by using a specified function.
  7468. /// A duration selector function is used to control the lifetime of groups. When a group expires, it receives an OnCompleted notification. When a new element with the same
  7469. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7470. /// </summary>
  7471. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7472. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7473. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7474. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7475. /// <param name="source">An observable sequence whose elements to group.</param>
  7476. /// <param name="keySelector">A function to extract the key for each element.</param>
  7477. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7478. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7479. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7480. /// <returns>
  7481. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7482. /// If a group's lifetime expires, a new group with the same key value can be created once an element with such a key value is encoutered.
  7483. /// </returns>
  7484. /// <exception cref="T:System.ArgumentNullException">
  7485. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="durationSelector" /> is null.</exception>
  7486. /// <exception cref="T:System.ArgumentOutOfRangeException">
  7487. /// <paramref name="capacity" /> is less than 0.</exception>
  7488. public static IQbservable<IGroupedObservable<TKey, TElement>> GroupByUntil<TSource, TKey, TElement, TDuration>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector, Expression<Func<IGroupedObservable<TKey, TElement>, IObservable<TDuration>>> durationSelector, int capacity)
  7489. {
  7490. if (source == null)
  7491. throw new ArgumentNullException("source");
  7492. if (keySelector == null)
  7493. throw new ArgumentNullException("keySelector");
  7494. if (elementSelector == null)
  7495. throw new ArgumentNullException("elementSelector");
  7496. if (durationSelector == null)
  7497. throw new ArgumentNullException("durationSelector");
  7498. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7499. Expression.Call(
  7500. null,
  7501. #if CRIPPLED_REFLECTION
  7502. InfoOf(() => Qbservable.GroupByUntil<TSource, TKey, TElement, TDuration>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(Expression<Func<IGroupedObservable<TKey, TElement>, IObservable<TDuration>>>), default(int))),
  7503. #else
  7504. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TDuration)),
  7505. #endif
  7506. source.Expression,
  7507. keySelector,
  7508. elementSelector,
  7509. durationSelector,
  7510. Expression.Constant(capacity, typeof(int))
  7511. )
  7512. );
  7513. }
  7514. /// <summary>
  7515. /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function and comparer and selects the resulting elements by using a specified function.
  7516. /// A duration selector function is used to control the lifetime of groups. When a group expires, it receives an OnCompleted notification. When a new element with the same
  7517. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7518. /// </summary>
  7519. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7520. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7521. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7522. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7523. /// <param name="source">An observable sequence whose elements to group.</param>
  7524. /// <param name="keySelector">A function to extract the key for each element.</param>
  7525. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7526. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7527. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7528. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7529. /// <returns>
  7530. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7531. /// If a group's lifetime expires, a new group with the same key value can be created once an element with such a key value is encountered.
  7532. /// </returns>
  7533. /// <exception cref="T:System.ArgumentNullException">
  7534. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="durationSelector" /> or <paramref name="comparer" /> is null.</exception>
  7535. /// <exception cref="T:System.ArgumentOutOfRangeException">
  7536. /// <paramref name="capacity" /> is less than 0.</exception>
  7537. public static IQbservable<IGroupedObservable<TKey, TElement>> GroupByUntil<TSource, TKey, TElement, TDuration>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector, Expression<Func<IGroupedObservable<TKey, TElement>, IObservable<TDuration>>> durationSelector, int capacity, IEqualityComparer<TKey> comparer)
  7538. {
  7539. if (source == null)
  7540. throw new ArgumentNullException("source");
  7541. if (keySelector == null)
  7542. throw new ArgumentNullException("keySelector");
  7543. if (elementSelector == null)
  7544. throw new ArgumentNullException("elementSelector");
  7545. if (durationSelector == null)
  7546. throw new ArgumentNullException("durationSelector");
  7547. if (comparer == null)
  7548. throw new ArgumentNullException("comparer");
  7549. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7550. Expression.Call(
  7551. null,
  7552. #if CRIPPLED_REFLECTION
  7553. InfoOf(() => Qbservable.GroupByUntil<TSource, TKey, TElement, TDuration>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(Expression<Func<IGroupedObservable<TKey, TElement>, IObservable<TDuration>>>), default(int), default(IEqualityComparer<TKey>))),
  7554. #else
  7555. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TDuration)),
  7556. #endif
  7557. source.Expression,
  7558. keySelector,
  7559. elementSelector,
  7560. durationSelector,
  7561. Expression.Constant(capacity, typeof(int)),
  7562. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7563. )
  7564. );
  7565. }
  7566. /// <summary>
  7567. /// Groups the elements of an observable sequence according to a specified key selector function and comparer and selects the resulting elements by using a specified function.
  7568. /// A duration selector function is used to control the lifetime of groups. When a group expires, it receives an OnCompleted notification. When a new element with the same
  7569. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7570. /// </summary>
  7571. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7572. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7573. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7574. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7575. /// <param name="source">An observable sequence whose elements to group.</param>
  7576. /// <param name="keySelector">A function to extract the key for each element.</param>
  7577. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7578. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7579. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7580. /// <returns>
  7581. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7582. /// If a group's lifetime expires, a new group with the same key value can be created once an element with such a key value is encountered.
  7583. /// </returns>
  7584. /// <exception cref="T:System.ArgumentNullException">
  7585. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="durationSelector" /> or <paramref name="comparer" /> is null.</exception>
  7586. public static IQbservable<IGroupedObservable<TKey, TElement>> GroupByUntil<TSource, TKey, TElement, TDuration>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector, Expression<Func<IGroupedObservable<TKey, TElement>, IObservable<TDuration>>> durationSelector, IEqualityComparer<TKey> comparer)
  7587. {
  7588. if (source == null)
  7589. throw new ArgumentNullException("source");
  7590. if (keySelector == null)
  7591. throw new ArgumentNullException("keySelector");
  7592. if (elementSelector == null)
  7593. throw new ArgumentNullException("elementSelector");
  7594. if (durationSelector == null)
  7595. throw new ArgumentNullException("durationSelector");
  7596. if (comparer == null)
  7597. throw new ArgumentNullException("comparer");
  7598. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7599. Expression.Call(
  7600. null,
  7601. #if CRIPPLED_REFLECTION
  7602. InfoOf(() => Qbservable.GroupByUntil<TSource, TKey, TElement, TDuration>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(Expression<Func<IGroupedObservable<TKey, TElement>, IObservable<TDuration>>>), default(IEqualityComparer<TKey>))),
  7603. #else
  7604. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TDuration)),
  7605. #endif
  7606. source.Expression,
  7607. keySelector,
  7608. elementSelector,
  7609. durationSelector,
  7610. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7611. )
  7612. );
  7613. }
  7614. /// <summary>
  7615. /// Correlates the elements of two sequences based on overlapping durations, and groups the results.
  7616. /// </summary>
  7617. /// <typeparam name="TLeft">The type of the elements in the left source sequence.</typeparam>
  7618. /// <typeparam name="TRight">The type of the elements in the right source sequence.</typeparam>
  7619. /// <typeparam name="TLeftDuration">The type of the elements in the duration sequence denoting the computed duration of each element in the left source sequence.</typeparam>
  7620. /// <typeparam name="TRightDuration">The type of the elements in the duration sequence denoting the computed duration of each element in the right source sequence.</typeparam>
  7621. /// <typeparam name="TResult">The type of the elements in the result sequence, obtained by invoking the result selector function for source elements with overlapping duration.</typeparam>
  7622. /// <param name="left">The left observable sequence to join elements for.</param>
  7623. /// <param name="right">The right observable sequence to join elements for.</param>
  7624. /// <param name="leftDurationSelector">A function to select the duration of each element of the left observable sequence, used to determine overlap.</param>
  7625. /// <param name="rightDurationSelector">A function to select the duration of each element of the right observable sequence, used to determine overlap.</param>
  7626. /// <param name="resultSelector">A function invoked to compute a result element for any element of the left sequence with overlapping elements from the right observable sequence.</param>
  7627. /// <returns>An observable sequence that contains result elements computed from source elements that have an overlapping duration.</returns>
  7628. /// <exception cref="T:System.ArgumentNullException">
  7629. /// <paramref name="left" /> or <paramref name="right" /> or <paramref name="leftDurationSelector" /> or <paramref name="rightDurationSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  7630. public static IQbservable<TResult> GroupJoin<TLeft, TRight, TLeftDuration, TRightDuration, TResult>(this IQbservable<TLeft> left, IObservable<TRight> right, Expression<Func<TLeft, IObservable<TLeftDuration>>> leftDurationSelector, Expression<Func<TRight, IObservable<TRightDuration>>> rightDurationSelector, Expression<Func<TLeft, IObservable<TRight>, TResult>> resultSelector)
  7631. {
  7632. if (left == null)
  7633. throw new ArgumentNullException("left");
  7634. if (right == null)
  7635. throw new ArgumentNullException("right");
  7636. if (leftDurationSelector == null)
  7637. throw new ArgumentNullException("leftDurationSelector");
  7638. if (rightDurationSelector == null)
  7639. throw new ArgumentNullException("rightDurationSelector");
  7640. if (resultSelector == null)
  7641. throw new ArgumentNullException("resultSelector");
  7642. return left.Provider.CreateQuery<TResult>(
  7643. Expression.Call(
  7644. null,
  7645. #if CRIPPLED_REFLECTION
  7646. InfoOf(() => Qbservable.GroupJoin<TLeft, TRight, TLeftDuration, TRightDuration, TResult>(default(IQbservable<TLeft>), default(IObservable<TRight>), default(Expression<Func<TLeft, IObservable<TLeftDuration>>>), default(Expression<Func<TRight, IObservable<TRightDuration>>>), default(Expression<Func<TLeft, IObservable<TRight>, TResult>>))),
  7647. #else
  7648. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TLeft), typeof(TRight), typeof(TLeftDuration), typeof(TRightDuration), typeof(TResult)),
  7649. #endif
  7650. left.Expression,
  7651. GetSourceExpression(right),
  7652. leftDurationSelector,
  7653. rightDurationSelector,
  7654. resultSelector
  7655. )
  7656. );
  7657. }
  7658. /// <summary>
  7659. /// If the specified <paramref name="condition" /> evaluates true, select the <paramref name="thenSource" /> sequence. Otherwise, return an empty sequence.
  7660. /// </summary>
  7661. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  7662. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  7663. /// <param name="condition">Condition evaluated to decide which sequence to return.</param>
  7664. /// <param name="thenSource">Sequence returned in case <paramref name="condition" /> evaluates true.</param>
  7665. /// <returns>
  7666. /// <paramref name="thenSource" /> if <paramref name="condition" /> evaluates true; an empty sequence otherwise.</returns>
  7667. /// <exception cref="T:System.ArgumentNullException">
  7668. /// <paramref name="condition" /> or <paramref name="thenSource" /> is null.</exception>
  7669. public static IQbservable<TResult> If<TResult>(this IQbservableProvider provider, Expression<Func<bool>> condition, IObservable<TResult> thenSource)
  7670. {
  7671. if (provider == null)
  7672. throw new ArgumentNullException("provider");
  7673. if (condition == null)
  7674. throw new ArgumentNullException("condition");
  7675. if (thenSource == null)
  7676. throw new ArgumentNullException("thenSource");
  7677. return provider.CreateQuery<TResult>(
  7678. Expression.Call(
  7679. null,
  7680. #if CRIPPLED_REFLECTION
  7681. InfoOf(() => Qbservable.If<TResult>(default(IQbservableProvider), default(Expression<Func<bool>>), default(IObservable<TResult>))),
  7682. #else
  7683. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  7684. #endif
  7685. Expression.Constant(provider, typeof(IQbservableProvider)),
  7686. condition,
  7687. GetSourceExpression(thenSource)
  7688. )
  7689. );
  7690. }
  7691. /// <summary>
  7692. /// If the specified <paramref name="condition" /> evaluates true, select the <paramref name="thenSource" /> sequence. Otherwise, select the <paramref name="elseSource" /> sequence.
  7693. /// </summary>
  7694. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  7695. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  7696. /// <param name="condition">Condition evaluated to decide which sequence to return.</param>
  7697. /// <param name="thenSource">Sequence returned in case <paramref name="condition" /> evaluates true.</param>
  7698. /// <param name="elseSource">Sequence returned in case <paramref name="condition" /> evaluates false.</param>
  7699. /// <returns>
  7700. /// <paramref name="thenSource" /> if <paramref name="condition" /> evaluates true; <paramref name="elseSource" /> otherwise.</returns>
  7701. /// <exception cref="T:System.ArgumentNullException">
  7702. /// <paramref name="condition" /> or <paramref name="thenSource" /> or <paramref name="elseSource" /> is null.</exception>
  7703. public static IQbservable<TResult> If<TResult>(this IQbservableProvider provider, Expression<Func<bool>> condition, IObservable<TResult> thenSource, IObservable<TResult> elseSource)
  7704. {
  7705. if (provider == null)
  7706. throw new ArgumentNullException("provider");
  7707. if (condition == null)
  7708. throw new ArgumentNullException("condition");
  7709. if (thenSource == null)
  7710. throw new ArgumentNullException("thenSource");
  7711. if (elseSource == null)
  7712. throw new ArgumentNullException("elseSource");
  7713. return provider.CreateQuery<TResult>(
  7714. Expression.Call(
  7715. null,
  7716. #if CRIPPLED_REFLECTION
  7717. InfoOf(() => Qbservable.If<TResult>(default(IQbservableProvider), default(Expression<Func<bool>>), default(IObservable<TResult>), default(IObservable<TResult>))),
  7718. #else
  7719. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  7720. #endif
  7721. Expression.Constant(provider, typeof(IQbservableProvider)),
  7722. condition,
  7723. GetSourceExpression(thenSource),
  7724. GetSourceExpression(elseSource)
  7725. )
  7726. );
  7727. }
  7728. /// <summary>
  7729. /// If the specified <paramref name="condition" /> evaluates true, select the <paramref name="thenSource" /> sequence. Otherwise, return an empty sequence generated on the specified scheduler.
  7730. /// </summary>
  7731. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  7732. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  7733. /// <param name="condition">Condition evaluated to decide which sequence to return.</param>
  7734. /// <param name="thenSource">Sequence returned in case <paramref name="condition" /> evaluates true.</param>
  7735. /// <param name="scheduler">Scheduler to generate an empty sequence on in case <paramref name="condition" /> evaluates false.</param>
  7736. /// <returns>
  7737. /// <paramref name="thenSource" /> if <paramref name="condition" /> evaluates true; an empty sequence otherwise.</returns>
  7738. /// <exception cref="T:System.ArgumentNullException">
  7739. /// <paramref name="condition" /> or <paramref name="thenSource" /> or <paramref name="scheduler" /> is null.</exception>
  7740. public static IQbservable<TResult> If<TResult>(this IQbservableProvider provider, Expression<Func<bool>> condition, IObservable<TResult> thenSource, IScheduler scheduler)
  7741. {
  7742. if (provider == null)
  7743. throw new ArgumentNullException("provider");
  7744. if (condition == null)
  7745. throw new ArgumentNullException("condition");
  7746. if (thenSource == null)
  7747. throw new ArgumentNullException("thenSource");
  7748. if (scheduler == null)
  7749. throw new ArgumentNullException("scheduler");
  7750. return provider.CreateQuery<TResult>(
  7751. Expression.Call(
  7752. null,
  7753. #if CRIPPLED_REFLECTION
  7754. InfoOf(() => Qbservable.If<TResult>(default(IQbservableProvider), default(Expression<Func<bool>>), default(IObservable<TResult>), default(IScheduler))),
  7755. #else
  7756. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  7757. #endif
  7758. Expression.Constant(provider, typeof(IQbservableProvider)),
  7759. condition,
  7760. GetSourceExpression(thenSource),
  7761. Expression.Constant(scheduler, typeof(IScheduler))
  7762. )
  7763. );
  7764. }
  7765. /// <summary>
  7766. /// Ignores all elements in an observable sequence leaving only the termination messages.
  7767. /// </summary>
  7768. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7769. /// <param name="source">Source sequence.</param>
  7770. /// <returns>An empty observable sequence that signals termination, successful or exceptional, of the source sequence.</returns>
  7771. /// <exception cref="T:System.ArgumentNullException">
  7772. /// <paramref name="source" /> is null.</exception>
  7773. public static IQbservable<TSource> IgnoreElements<TSource>(this IQbservable<TSource> source)
  7774. {
  7775. if (source == null)
  7776. throw new ArgumentNullException("source");
  7777. return source.Provider.CreateQuery<TSource>(
  7778. Expression.Call(
  7779. null,
  7780. #if CRIPPLED_REFLECTION
  7781. InfoOf(() => Qbservable.IgnoreElements<TSource>(default(IQbservable<TSource>))),
  7782. #else
  7783. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7784. #endif
  7785. source.Expression
  7786. )
  7787. );
  7788. }
  7789. /// <summary>
  7790. /// Returns an observable sequence that produces a value after each period.
  7791. /// </summary>
  7792. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  7793. /// <param name="period">Period for producing the values in the resulting sequence. If this value is equal to TimeSpan.Zero, the timer will recur as fast as possible.</param>
  7794. /// <returns>An observable sequence that produces a value after each period.</returns>
  7795. /// <exception cref="T:System.ArgumentOutOfRangeException">
  7796. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  7797. /// <remarks>
  7798. /// Intervals are measured between the start of subsequent notifications, not between the end of the previous and the start of the next notification.
  7799. /// If the observer takes longer than the interval period to handle the message, the subsequent notification will be delivered immediately after the
  7800. /// current one has been handled. In case you need to control the time between the end and the start of consecutive notifications, consider using the
  7801. /// <see cref="M:System.Reactive.Linq.Observable.Generate``2(``0,System.Func{``0,System.Boolean},System.Func{``0,``0},System.Func{``0,``1},System.Func{``0,System.TimeSpan})" />
  7802. /// operator instead.
  7803. /// </remarks>
  7804. public static IQbservable<long> Interval(this IQbservableProvider provider, TimeSpan period)
  7805. {
  7806. if (provider == null)
  7807. throw new ArgumentNullException("provider");
  7808. return provider.CreateQuery<long>(
  7809. Expression.Call(
  7810. null,
  7811. #if CRIPPLED_REFLECTION
  7812. InfoOf(() => Qbservable.Interval(default(IQbservableProvider), default(TimeSpan))),
  7813. #else
  7814. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7815. #endif
  7816. Expression.Constant(provider, typeof(IQbservableProvider)),
  7817. Expression.Constant(period, typeof(TimeSpan))
  7818. )
  7819. );
  7820. }
  7821. /// <summary>
  7822. /// Returns an observable sequence that produces a value after each period, using the specified scheduler to run timers and to send out observer messages.
  7823. /// </summary>
  7824. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  7825. /// <param name="period">Period for producing the values in the resulting sequence. If this value is equal to TimeSpan.Zero, the timer will recur as fast as possible.</param>
  7826. /// <param name="scheduler">Scheduler to run the timer on.</param>
  7827. /// <returns>An observable sequence that produces a value after each period.</returns>
  7828. /// <exception cref="T:System.ArgumentOutOfRangeException">
  7829. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  7830. /// <exception cref="T:System.ArgumentNullException">
  7831. /// <paramref name="scheduler" /> is null.</exception>
  7832. /// <remarks>
  7833. /// Intervals are measured between the start of subsequent notifications, not between the end of the previous and the start of the next notification.
  7834. /// If the observer takes longer than the interval period to handle the message, the subsequent notification will be delivered immediately after the
  7835. /// current one has been handled. In case you need to control the time between the end and the start of consecutive notifications, consider using the
  7836. /// <see cref="M:System.Reactive.Linq.Observable.Generate``2(``0,System.Func{``0,System.Boolean},System.Func{``0,``0},System.Func{``0,``1},System.Func{``0,System.TimeSpan},System.Reactive.Concurrency.IScheduler)" />
  7837. /// operator instead.
  7838. /// </remarks>
  7839. public static IQbservable<long> Interval(this IQbservableProvider provider, TimeSpan period, IScheduler scheduler)
  7840. {
  7841. if (provider == null)
  7842. throw new ArgumentNullException("provider");
  7843. if (scheduler == null)
  7844. throw new ArgumentNullException("scheduler");
  7845. return provider.CreateQuery<long>(
  7846. Expression.Call(
  7847. null,
  7848. #if CRIPPLED_REFLECTION
  7849. InfoOf(() => Qbservable.Interval(default(IQbservableProvider), default(TimeSpan), default(IScheduler))),
  7850. #else
  7851. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7852. #endif
  7853. Expression.Constant(provider, typeof(IQbservableProvider)),
  7854. Expression.Constant(period, typeof(TimeSpan)),
  7855. Expression.Constant(scheduler, typeof(IScheduler))
  7856. )
  7857. );
  7858. }
  7859. /// <summary>
  7860. /// Determines whether an observable sequence is empty.
  7861. /// </summary>
  7862. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7863. /// <param name="source">An observable sequence to check for emptiness.</param>
  7864. /// <returns>An observable sequence containing a single element determining whether the source sequence is empty.</returns>
  7865. /// <exception cref="T:System.ArgumentNullException">
  7866. /// <paramref name="source" /> is null.</exception>
  7867. public static IQbservable<bool> IsEmpty<TSource>(this IQbservable<TSource> source)
  7868. {
  7869. if (source == null)
  7870. throw new ArgumentNullException("source");
  7871. return source.Provider.CreateQuery<bool>(
  7872. Expression.Call(
  7873. null,
  7874. #if CRIPPLED_REFLECTION
  7875. InfoOf(() => Qbservable.IsEmpty<TSource>(default(IQbservable<TSource>))),
  7876. #else
  7877. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7878. #endif
  7879. source.Expression
  7880. )
  7881. );
  7882. }
  7883. /// <summary>
  7884. /// Correlates the elements of two sequences based on overlapping durations.
  7885. /// </summary>
  7886. /// <typeparam name="TLeft">The type of the elements in the left source sequence.</typeparam>
  7887. /// <typeparam name="TRight">The type of the elements in the right source sequence.</typeparam>
  7888. /// <typeparam name="TLeftDuration">The type of the elements in the duration sequence denoting the computed duration of each element in the left source sequence.</typeparam>
  7889. /// <typeparam name="TRightDuration">The type of the elements in the duration sequence denoting the computed duration of each element in the right source sequence.</typeparam>
  7890. /// <typeparam name="TResult">The type of the elements in the result sequence, obtained by invoking the result selector function for source elements with overlapping duration.</typeparam>
  7891. /// <param name="left">The left observable sequence to join elements for.</param>
  7892. /// <param name="right">The right observable sequence to join elements for.</param>
  7893. /// <param name="leftDurationSelector">A function to select the duration of each element of the left observable sequence, used to determine overlap.</param>
  7894. /// <param name="rightDurationSelector">A function to select the duration of each element of the right observable sequence, used to determine overlap.</param>
  7895. /// <param name="resultSelector">A function invoked to compute a result element for any two overlapping elements of the left and right observable sequences.</param>
  7896. /// <returns>An observable sequence that contains result elements computed from source elements that have an overlapping duration.</returns>
  7897. /// <exception cref="T:System.ArgumentNullException">
  7898. /// <paramref name="left" /> or <paramref name="right" /> or <paramref name="leftDurationSelector" /> or <paramref name="rightDurationSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  7899. public static IQbservable<TResult> Join<TLeft, TRight, TLeftDuration, TRightDuration, TResult>(this IQbservable<TLeft> left, IObservable<TRight> right, Expression<Func<TLeft, IObservable<TLeftDuration>>> leftDurationSelector, Expression<Func<TRight, IObservable<TRightDuration>>> rightDurationSelector, Expression<Func<TLeft, TRight, TResult>> resultSelector)
  7900. {
  7901. if (left == null)
  7902. throw new ArgumentNullException("left");
  7903. if (right == null)
  7904. throw new ArgumentNullException("right");
  7905. if (leftDurationSelector == null)
  7906. throw new ArgumentNullException("leftDurationSelector");
  7907. if (rightDurationSelector == null)
  7908. throw new ArgumentNullException("rightDurationSelector");
  7909. if (resultSelector == null)
  7910. throw new ArgumentNullException("resultSelector");
  7911. return left.Provider.CreateQuery<TResult>(
  7912. Expression.Call(
  7913. null,
  7914. #if CRIPPLED_REFLECTION
  7915. InfoOf(() => Qbservable.Join<TLeft, TRight, TLeftDuration, TRightDuration, TResult>(default(IQbservable<TLeft>), default(IObservable<TRight>), default(Expression<Func<TLeft, IObservable<TLeftDuration>>>), default(Expression<Func<TRight, IObservable<TRightDuration>>>), default(Expression<Func<TLeft, TRight, TResult>>))),
  7916. #else
  7917. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TLeft), typeof(TRight), typeof(TLeftDuration), typeof(TRightDuration), typeof(TResult)),
  7918. #endif
  7919. left.Expression,
  7920. GetSourceExpression(right),
  7921. leftDurationSelector,
  7922. rightDurationSelector,
  7923. resultSelector
  7924. )
  7925. );
  7926. }
  7927. /// <summary>
  7928. /// Returns the last element of an observable sequence.
  7929. /// </summary>
  7930. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7931. /// <param name="source">Source observable sequence.</param>
  7932. /// <returns>Sequence containing the last element in the observable sequence.</returns>
  7933. /// <exception cref="T:System.ArgumentNullException">
  7934. /// <paramref name="source" /> is null.</exception>
  7935. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  7936. public static IQbservable<TSource> LastAsync<TSource>(this IQbservable<TSource> source)
  7937. {
  7938. if (source == null)
  7939. throw new ArgumentNullException("source");
  7940. return source.Provider.CreateQuery<TSource>(
  7941. Expression.Call(
  7942. null,
  7943. #if CRIPPLED_REFLECTION
  7944. InfoOf(() => Qbservable.LastAsync<TSource>(default(IQbservable<TSource>))),
  7945. #else
  7946. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7947. #endif
  7948. source.Expression
  7949. )
  7950. );
  7951. }
  7952. /// <summary>
  7953. /// Returns the last element of an observable sequence that satisfies the condition in the predicate.
  7954. /// </summary>
  7955. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7956. /// <param name="source">Source observable sequence.</param>
  7957. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  7958. /// <returns>Sequence containing the last element in the observable sequence that satisfies the condition in the predicate.</returns>
  7959. /// <exception cref="T:System.ArgumentNullException">
  7960. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  7961. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) No element satisfies the condition in the predicate. -or- The source sequence is empty.</exception>
  7962. public static IQbservable<TSource> LastAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  7963. {
  7964. if (source == null)
  7965. throw new ArgumentNullException("source");
  7966. if (predicate == null)
  7967. throw new ArgumentNullException("predicate");
  7968. return source.Provider.CreateQuery<TSource>(
  7969. Expression.Call(
  7970. null,
  7971. #if CRIPPLED_REFLECTION
  7972. InfoOf(() => Qbservable.LastAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  7973. #else
  7974. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7975. #endif
  7976. source.Expression,
  7977. predicate
  7978. )
  7979. );
  7980. }
  7981. /// <summary>
  7982. /// Returns the last element of an observable sequence, or a default value if no such element exists.
  7983. /// </summary>
  7984. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7985. /// <param name="source">Source observable sequence.</param>
  7986. /// <returns>Sequence containing the last element in the observable sequence, or a default value if no such element exists.</returns>
  7987. /// <exception cref="T:System.ArgumentNullException">
  7988. /// <paramref name="source" /> is null.</exception>
  7989. public static IQbservable<TSource> LastOrDefaultAsync<TSource>(this IQbservable<TSource> source)
  7990. {
  7991. if (source == null)
  7992. throw new ArgumentNullException("source");
  7993. return source.Provider.CreateQuery<TSource>(
  7994. Expression.Call(
  7995. null,
  7996. #if CRIPPLED_REFLECTION
  7997. InfoOf(() => Qbservable.LastOrDefaultAsync<TSource>(default(IQbservable<TSource>))),
  7998. #else
  7999. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8000. #endif
  8001. source.Expression
  8002. )
  8003. );
  8004. }
  8005. /// <summary>
  8006. /// Returns the last element of an observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.
  8007. /// </summary>
  8008. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8009. /// <param name="source">Source observable sequence.</param>
  8010. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  8011. /// <returns>Sequence containing the last element in the observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.</returns>
  8012. /// <exception cref="T:System.ArgumentNullException">
  8013. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  8014. public static IQbservable<TSource> LastOrDefaultAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  8015. {
  8016. if (source == null)
  8017. throw new ArgumentNullException("source");
  8018. if (predicate == null)
  8019. throw new ArgumentNullException("predicate");
  8020. return source.Provider.CreateQuery<TSource>(
  8021. Expression.Call(
  8022. null,
  8023. #if CRIPPLED_REFLECTION
  8024. InfoOf(() => Qbservable.LastOrDefaultAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  8025. #else
  8026. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8027. #endif
  8028. source.Expression,
  8029. predicate
  8030. )
  8031. );
  8032. }
  8033. /// <summary>
  8034. /// Returns an enumerable sequence whose enumeration returns the latest observed element in the source observable sequence.
  8035. /// Enumerators on the resulting sequence will never produce the same element repeatedly, and will block until the next element becomes available.
  8036. /// </summary>
  8037. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8038. /// <param name="source">Source observable sequence.</param>
  8039. /// <returns>The enumerable sequence that returns the last sampled element upon each iteration and subsequently blocks until the next element in the observable source sequence becomes available.</returns>
  8040. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  8041. public static IQueryable<TSource> Latest<TSource>(this IQbservable<TSource> source)
  8042. {
  8043. if (source == null)
  8044. throw new ArgumentNullException("source");
  8045. return ((IQueryProvider)source.Provider).CreateQuery<TSource>(
  8046. Expression.Call(
  8047. null,
  8048. #if CRIPPLED_REFLECTION
  8049. InfoOf(() => Qbservable.Latest<TSource>(default(IQbservable<TSource>))),
  8050. #else
  8051. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8052. #endif
  8053. source.Expression
  8054. )
  8055. );
  8056. }
  8057. /// <summary>
  8058. /// Returns an observable sequence containing an <see cref="T:System.Int64" /> that represents the total number of elements in an observable sequence.
  8059. /// </summary>
  8060. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8061. /// <param name="source">An observable sequence that contains elements to be counted.</param>
  8062. /// <returns>An observable sequence containing a single element with the number of elements in the input sequence.</returns>
  8063. /// <exception cref="T:System.ArgumentNullException">
  8064. /// <paramref name="source" /> is null.</exception>
  8065. /// <exception cref="T:System.OverflowException">(Asynchronous) The number of elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue" />.</exception>
  8066. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8067. public static IQbservable<long> LongCount<TSource>(this IQbservable<TSource> source)
  8068. {
  8069. if (source == null)
  8070. throw new ArgumentNullException("source");
  8071. return source.Provider.CreateQuery<long>(
  8072. Expression.Call(
  8073. null,
  8074. #if CRIPPLED_REFLECTION
  8075. InfoOf(() => Qbservable.LongCount<TSource>(default(IQbservable<TSource>))),
  8076. #else
  8077. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8078. #endif
  8079. source.Expression
  8080. )
  8081. );
  8082. }
  8083. /// <summary>
  8084. /// Returns an observable sequence containing an <see cref="T:System.Int64" /> that represents how many elements in the specified observable sequence satisfy a condition.
  8085. /// </summary>
  8086. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8087. /// <param name="source">An observable sequence that contains elements to be counted.</param>
  8088. /// <param name="predicate">A function to test each element for a condition.</param>
  8089. /// <returns>An observable sequence containing a single element with a number that represents how many elements in the input sequence satisfy the condition in the predicate function.</returns>
  8090. /// <exception cref="T:System.ArgumentNullException">
  8091. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  8092. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8093. public static IQbservable<long> LongCount<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  8094. {
  8095. if (source == null)
  8096. throw new ArgumentNullException("source");
  8097. if (predicate == null)
  8098. throw new ArgumentNullException("predicate");
  8099. return source.Provider.CreateQuery<long>(
  8100. Expression.Call(
  8101. null,
  8102. #if CRIPPLED_REFLECTION
  8103. InfoOf(() => Qbservable.LongCount<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  8104. #else
  8105. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8106. #endif
  8107. source.Expression,
  8108. predicate
  8109. )
  8110. );
  8111. }
  8112. /// <summary>
  8113. /// Materializes the implicit notifications of an observable sequence as explicit notification values.
  8114. /// </summary>
  8115. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8116. /// <param name="source">An observable sequence to get notification values for.</param>
  8117. /// <returns>An observable sequence containing the materialized notification values from the source sequence.</returns>
  8118. /// <exception cref="T:System.ArgumentNullException">
  8119. /// <paramref name="source" /> is null.</exception>
  8120. public static IQbservable<Notification<TSource>> Materialize<TSource>(this IQbservable<TSource> source)
  8121. {
  8122. if (source == null)
  8123. throw new ArgumentNullException("source");
  8124. return source.Provider.CreateQuery<Notification<TSource>>(
  8125. Expression.Call(
  8126. null,
  8127. #if CRIPPLED_REFLECTION
  8128. InfoOf(() => Qbservable.Materialize<TSource>(default(IQbservable<TSource>))),
  8129. #else
  8130. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8131. #endif
  8132. source.Expression
  8133. )
  8134. );
  8135. }
  8136. /// <summary>
  8137. /// Returns the maximum value in an observable sequence of <see cref="T:System.Decimal" /> values.
  8138. /// </summary>
  8139. /// <param name="source">A sequence of <see cref="T:System.Decimal" /> values to determine the maximum value of.</param>
  8140. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8141. /// <exception cref="T:System.ArgumentNullException">
  8142. /// <paramref name="source" /> is null.</exception>
  8143. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8144. public static IQbservable<decimal> Max(this IQbservable<decimal> source)
  8145. {
  8146. if (source == null)
  8147. throw new ArgumentNullException("source");
  8148. return source.Provider.CreateQuery<decimal>(
  8149. Expression.Call(
  8150. null,
  8151. #if CRIPPLED_REFLECTION
  8152. InfoOf(() => Qbservable.Max(default(IQbservable<decimal>))),
  8153. #else
  8154. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8155. #endif
  8156. source.Expression
  8157. )
  8158. );
  8159. }
  8160. /// <summary>
  8161. /// Returns the maximum value in an observable sequence of <see cref="T:System.Double" /> values.
  8162. /// </summary>
  8163. /// <param name="source">A sequence of <see cref="T:System.Double" /> values to determine the maximum value of.</param>
  8164. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8165. /// <exception cref="T:System.ArgumentNullException">
  8166. /// <paramref name="source" /> is null.</exception>
  8167. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8168. public static IQbservable<double> Max(this IQbservable<double> source)
  8169. {
  8170. if (source == null)
  8171. throw new ArgumentNullException("source");
  8172. return source.Provider.CreateQuery<double>(
  8173. Expression.Call(
  8174. null,
  8175. #if CRIPPLED_REFLECTION
  8176. InfoOf(() => Qbservable.Max(default(IQbservable<double>))),
  8177. #else
  8178. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8179. #endif
  8180. source.Expression
  8181. )
  8182. );
  8183. }
  8184. /// <summary>
  8185. /// Returns the maximum value in an observable sequence of <see cref="T:System.Int32" /> values.
  8186. /// </summary>
  8187. /// <param name="source">A sequence of <see cref="T:System.Int32" /> values to determine the maximum value of.</param>
  8188. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8189. /// <exception cref="T:System.ArgumentNullException">
  8190. /// <paramref name="source" /> is null.</exception>
  8191. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8192. public static IQbservable<int> Max(this IQbservable<int> source)
  8193. {
  8194. if (source == null)
  8195. throw new ArgumentNullException("source");
  8196. return source.Provider.CreateQuery<int>(
  8197. Expression.Call(
  8198. null,
  8199. #if CRIPPLED_REFLECTION
  8200. InfoOf(() => Qbservable.Max(default(IQbservable<int>))),
  8201. #else
  8202. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8203. #endif
  8204. source.Expression
  8205. )
  8206. );
  8207. }
  8208. /// <summary>
  8209. /// Returns the maximum value in an observable sequence of <see cref="T:System.Int64" /> values.
  8210. /// </summary>
  8211. /// <param name="source">A sequence of <see cref="T:System.Int64" /> values to determine the maximum value of.</param>
  8212. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8213. /// <exception cref="T:System.ArgumentNullException">
  8214. /// <paramref name="source" /> is null.</exception>
  8215. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8216. public static IQbservable<long> Max(this IQbservable<long> source)
  8217. {
  8218. if (source == null)
  8219. throw new ArgumentNullException("source");
  8220. return source.Provider.CreateQuery<long>(
  8221. Expression.Call(
  8222. null,
  8223. #if CRIPPLED_REFLECTION
  8224. InfoOf(() => Qbservable.Max(default(IQbservable<long>))),
  8225. #else
  8226. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8227. #endif
  8228. source.Expression
  8229. )
  8230. );
  8231. }
  8232. /// <summary>
  8233. /// Returns the maximum value in an observable sequence of nullable <see cref="T:System.Decimal" /> values.
  8234. /// </summary>
  8235. /// <param name="source">A sequence of nullable <see cref="T:System.Decimal" /> values to determine the maximum value of.</param>
  8236. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8237. /// <exception cref="T:System.ArgumentNullException">
  8238. /// <paramref name="source" /> is null.</exception>
  8239. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8240. public static IQbservable<decimal?> Max(this IQbservable<decimal?> source)
  8241. {
  8242. if (source == null)
  8243. throw new ArgumentNullException("source");
  8244. return source.Provider.CreateQuery<decimal?>(
  8245. Expression.Call(
  8246. null,
  8247. #if CRIPPLED_REFLECTION
  8248. InfoOf(() => Qbservable.Max(default(IQbservable<decimal?>))),
  8249. #else
  8250. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8251. #endif
  8252. source.Expression
  8253. )
  8254. );
  8255. }
  8256. /// <summary>
  8257. /// Returns the maximum value in an observable sequence of nullable <see cref="T:System.Double" /> values.
  8258. /// </summary>
  8259. /// <param name="source">A sequence of nullable <see cref="T:System.Double" /> values to determine the maximum value of.</param>
  8260. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8261. /// <exception cref="T:System.ArgumentNullException">
  8262. /// <paramref name="source" /> is null.</exception>
  8263. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8264. public static IQbservable<double?> Max(this IQbservable<double?> source)
  8265. {
  8266. if (source == null)
  8267. throw new ArgumentNullException("source");
  8268. return source.Provider.CreateQuery<double?>(
  8269. Expression.Call(
  8270. null,
  8271. #if CRIPPLED_REFLECTION
  8272. InfoOf(() => Qbservable.Max(default(IQbservable<double?>))),
  8273. #else
  8274. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8275. #endif
  8276. source.Expression
  8277. )
  8278. );
  8279. }
  8280. /// <summary>
  8281. /// Returns the maximum value in an observable sequence of nullable <see cref="T:System.Int32" /> values.
  8282. /// </summary>
  8283. /// <param name="source">A sequence of nullable <see cref="T:System.Int32" /> values to determine the maximum value of.</param>
  8284. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8285. /// <exception cref="T:System.ArgumentNullException">
  8286. /// <paramref name="source" /> is null.</exception>
  8287. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8288. public static IQbservable<int?> Max(this IQbservable<int?> source)
  8289. {
  8290. if (source == null)
  8291. throw new ArgumentNullException("source");
  8292. return source.Provider.CreateQuery<int?>(
  8293. Expression.Call(
  8294. null,
  8295. #if CRIPPLED_REFLECTION
  8296. InfoOf(() => Qbservable.Max(default(IQbservable<int?>))),
  8297. #else
  8298. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8299. #endif
  8300. source.Expression
  8301. )
  8302. );
  8303. }
  8304. /// <summary>
  8305. /// Returns the maximum value in an observable sequence of nullable <see cref="T:System.Int64" /> values.
  8306. /// </summary>
  8307. /// <param name="source">A sequence of nullable <see cref="T:System.Int64" /> values to determine the maximum value of.</param>
  8308. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8309. /// <exception cref="T:System.ArgumentNullException">
  8310. /// <paramref name="source" /> is null.</exception>
  8311. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8312. public static IQbservable<long?> Max(this IQbservable<long?> source)
  8313. {
  8314. if (source == null)
  8315. throw new ArgumentNullException("source");
  8316. return source.Provider.CreateQuery<long?>(
  8317. Expression.Call(
  8318. null,
  8319. #if CRIPPLED_REFLECTION
  8320. InfoOf(() => Qbservable.Max(default(IQbservable<long?>))),
  8321. #else
  8322. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8323. #endif
  8324. source.Expression
  8325. )
  8326. );
  8327. }
  8328. /// <summary>
  8329. /// Returns the maximum value in an observable sequence of nullable <see cref="T:System.Single" /> values.
  8330. /// </summary>
  8331. /// <param name="source">A sequence of nullable <see cref="T:System.Single" /> values to determine the maximum value of.</param>
  8332. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8333. /// <exception cref="T:System.ArgumentNullException">
  8334. /// <paramref name="source" /> is null.</exception>
  8335. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8336. public static IQbservable<float?> Max(this IQbservable<float?> source)
  8337. {
  8338. if (source == null)
  8339. throw new ArgumentNullException("source");
  8340. return source.Provider.CreateQuery<float?>(
  8341. Expression.Call(
  8342. null,
  8343. #if CRIPPLED_REFLECTION
  8344. InfoOf(() => Qbservable.Max(default(IQbservable<float?>))),
  8345. #else
  8346. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8347. #endif
  8348. source.Expression
  8349. )
  8350. );
  8351. }
  8352. /// <summary>
  8353. /// Returns the maximum value in an observable sequence of <see cref="T:System.Single" /> values.
  8354. /// </summary>
  8355. /// <param name="source">A sequence of <see cref="T:System.Single" /> values to determine the maximum value of.</param>
  8356. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8357. /// <exception cref="T:System.ArgumentNullException">
  8358. /// <paramref name="source" /> is null.</exception>
  8359. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8360. public static IQbservable<float> Max(this IQbservable<float> source)
  8361. {
  8362. if (source == null)
  8363. throw new ArgumentNullException("source");
  8364. return source.Provider.CreateQuery<float>(
  8365. Expression.Call(
  8366. null,
  8367. #if CRIPPLED_REFLECTION
  8368. InfoOf(() => Qbservable.Max(default(IQbservable<float>))),
  8369. #else
  8370. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8371. #endif
  8372. source.Expression
  8373. )
  8374. );
  8375. }
  8376. /// <summary>
  8377. /// Returns the maximum element in an observable sequence.
  8378. /// </summary>
  8379. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8380. /// <param name="source">An observable sequence to determine the maximum element of.</param>
  8381. /// <returns>An observable sequence containing a single element with the maximum element in the source sequence.</returns>
  8382. /// <exception cref="T:System.ArgumentNullException">
  8383. /// <paramref name="source" /> is null.</exception>
  8384. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8385. public static IQbservable<TSource> Max<TSource>(this IQbservable<TSource> source)
  8386. {
  8387. if (source == null)
  8388. throw new ArgumentNullException("source");
  8389. return source.Provider.CreateQuery<TSource>(
  8390. Expression.Call(
  8391. null,
  8392. #if CRIPPLED_REFLECTION
  8393. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>))),
  8394. #else
  8395. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8396. #endif
  8397. source.Expression
  8398. )
  8399. );
  8400. }
  8401. /// <summary>
  8402. /// Returns the maximum value in an observable sequence according to the specified comparer.
  8403. /// </summary>
  8404. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8405. /// <param name="source">An observable sequence to determine the maximum element of.</param>
  8406. /// <param name="comparer">Comparer used to compare elements.</param>
  8407. /// <returns>An observable sequence containing a single element with the maximum element in the source sequence.</returns>
  8408. /// <exception cref="T:System.ArgumentNullException">
  8409. /// <paramref name="source" /> or <paramref name="comparer" /> is null.</exception>
  8410. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8411. public static IQbservable<TSource> Max<TSource>(this IQbservable<TSource> source, IComparer<TSource> comparer)
  8412. {
  8413. if (source == null)
  8414. throw new ArgumentNullException("source");
  8415. if (comparer == null)
  8416. throw new ArgumentNullException("comparer");
  8417. return source.Provider.CreateQuery<TSource>(
  8418. Expression.Call(
  8419. null,
  8420. #if CRIPPLED_REFLECTION
  8421. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(IComparer<TSource>))),
  8422. #else
  8423. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8424. #endif
  8425. source.Expression,
  8426. Expression.Constant(comparer, typeof(IComparer<TSource>))
  8427. )
  8428. );
  8429. }
  8430. /// <summary>
  8431. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="T:System.Double" /> value.
  8432. /// </summary>
  8433. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8434. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8435. /// <param name="selector">A transform function to apply to each element.</param>
  8436. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Double" /> that corresponds to the maximum value in the source sequence.</returns>
  8437. /// <exception cref="T:System.ArgumentNullException">
  8438. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8439. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8440. public static IQbservable<double> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double>> selector)
  8441. {
  8442. if (source == null)
  8443. throw new ArgumentNullException("source");
  8444. if (selector == null)
  8445. throw new ArgumentNullException("selector");
  8446. return source.Provider.CreateQuery<double>(
  8447. Expression.Call(
  8448. null,
  8449. #if CRIPPLED_REFLECTION
  8450. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double>>))),
  8451. #else
  8452. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8453. #endif
  8454. source.Expression,
  8455. selector
  8456. )
  8457. );
  8458. }
  8459. /// <summary>
  8460. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="T:System.Single" /> value.
  8461. /// </summary>
  8462. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8463. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8464. /// <param name="selector">A transform function to apply to each element.</param>
  8465. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Single" /> that corresponds to the maximum value in the source sequence.</returns>
  8466. /// <exception cref="T:System.ArgumentNullException">
  8467. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8468. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8469. public static IQbservable<float> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float>> selector)
  8470. {
  8471. if (source == null)
  8472. throw new ArgumentNullException("source");
  8473. if (selector == null)
  8474. throw new ArgumentNullException("selector");
  8475. return source.Provider.CreateQuery<float>(
  8476. Expression.Call(
  8477. null,
  8478. #if CRIPPLED_REFLECTION
  8479. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float>>))),
  8480. #else
  8481. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8482. #endif
  8483. source.Expression,
  8484. selector
  8485. )
  8486. );
  8487. }
  8488. /// <summary>
  8489. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="T:System.Decimal" /> value.
  8490. /// </summary>
  8491. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8492. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8493. /// <param name="selector">A transform function to apply to each element.</param>
  8494. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Decimal" /> that corresponds to the maximum value in the source sequence.</returns>
  8495. /// <exception cref="T:System.ArgumentNullException">
  8496. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8497. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8498. public static IQbservable<decimal> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal>> selector)
  8499. {
  8500. if (source == null)
  8501. throw new ArgumentNullException("source");
  8502. if (selector == null)
  8503. throw new ArgumentNullException("selector");
  8504. return source.Provider.CreateQuery<decimal>(
  8505. Expression.Call(
  8506. null,
  8507. #if CRIPPLED_REFLECTION
  8508. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal>>))),
  8509. #else
  8510. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8511. #endif
  8512. source.Expression,
  8513. selector
  8514. )
  8515. );
  8516. }
  8517. /// <summary>
  8518. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="T:System.Int32" /> value.
  8519. /// </summary>
  8520. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8521. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8522. /// <param name="selector">A transform function to apply to each element.</param>
  8523. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Int32" /> that corresponds to the maximum value in the source sequence.</returns>
  8524. /// <exception cref="T:System.ArgumentNullException">
  8525. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8526. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8527. public static IQbservable<int> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int>> selector)
  8528. {
  8529. if (source == null)
  8530. throw new ArgumentNullException("source");
  8531. if (selector == null)
  8532. throw new ArgumentNullException("selector");
  8533. return source.Provider.CreateQuery<int>(
  8534. Expression.Call(
  8535. null,
  8536. #if CRIPPLED_REFLECTION
  8537. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int>>))),
  8538. #else
  8539. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8540. #endif
  8541. source.Expression,
  8542. selector
  8543. )
  8544. );
  8545. }
  8546. /// <summary>
  8547. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="T:System.Int64" /> value.
  8548. /// </summary>
  8549. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8550. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8551. /// <param name="selector">A transform function to apply to each element.</param>
  8552. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Int64" /> that corresponds to the maximum value in the source sequence.</returns>
  8553. /// <exception cref="T:System.ArgumentNullException">
  8554. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8555. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8556. public static IQbservable<long> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long>> selector)
  8557. {
  8558. if (source == null)
  8559. throw new ArgumentNullException("source");
  8560. if (selector == null)
  8561. throw new ArgumentNullException("selector");
  8562. return source.Provider.CreateQuery<long>(
  8563. Expression.Call(
  8564. null,
  8565. #if CRIPPLED_REFLECTION
  8566. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long>>))),
  8567. #else
  8568. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8569. #endif
  8570. source.Expression,
  8571. selector
  8572. )
  8573. );
  8574. }
  8575. /// <summary>
  8576. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="T:System.Double" /> value.
  8577. /// </summary>
  8578. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8579. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8580. /// <param name="selector">A transform function to apply to each element.</param>
  8581. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable&lt;System.Double&gt;" /> that corresponds to the maximum value in the source sequence.</returns>
  8582. /// <exception cref="T:System.ArgumentNullException">
  8583. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8584. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8585. public static IQbservable<double?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double?>> selector)
  8586. {
  8587. if (source == null)
  8588. throw new ArgumentNullException("source");
  8589. if (selector == null)
  8590. throw new ArgumentNullException("selector");
  8591. return source.Provider.CreateQuery<double?>(
  8592. Expression.Call(
  8593. null,
  8594. #if CRIPPLED_REFLECTION
  8595. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double?>>))),
  8596. #else
  8597. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8598. #endif
  8599. source.Expression,
  8600. selector
  8601. )
  8602. );
  8603. }
  8604. /// <summary>
  8605. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="T:System.Single" /> value.
  8606. /// </summary>
  8607. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8608. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8609. /// <param name="selector">A transform function to apply to each element.</param>
  8610. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable&lt;System.Single&gt;" /> that corresponds to the maximum value in the source sequence.</returns>
  8611. /// <exception cref="T:System.ArgumentNullException">
  8612. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8613. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8614. public static IQbservable<float?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float?>> selector)
  8615. {
  8616. if (source == null)
  8617. throw new ArgumentNullException("source");
  8618. if (selector == null)
  8619. throw new ArgumentNullException("selector");
  8620. return source.Provider.CreateQuery<float?>(
  8621. Expression.Call(
  8622. null,
  8623. #if CRIPPLED_REFLECTION
  8624. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float?>>))),
  8625. #else
  8626. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8627. #endif
  8628. source.Expression,
  8629. selector
  8630. )
  8631. );
  8632. }
  8633. /// <summary>
  8634. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="T:System.Decimal" /> value.
  8635. /// </summary>
  8636. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8637. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8638. /// <param name="selector">A transform function to apply to each element.</param>
  8639. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable&lt;System.Decimal&gt;" /> that corresponds to the maximum value in the source sequence.</returns>
  8640. /// <exception cref="T:System.ArgumentNullException">
  8641. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8642. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8643. public static IQbservable<decimal?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal?>> selector)
  8644. {
  8645. if (source == null)
  8646. throw new ArgumentNullException("source");
  8647. if (selector == null)
  8648. throw new ArgumentNullException("selector");
  8649. return source.Provider.CreateQuery<decimal?>(
  8650. Expression.Call(
  8651. null,
  8652. #if CRIPPLED_REFLECTION
  8653. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal?>>))),
  8654. #else
  8655. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8656. #endif
  8657. source.Expression,
  8658. selector
  8659. )
  8660. );
  8661. }
  8662. /// <summary>
  8663. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="T:System.Int32" /> value.
  8664. /// </summary>
  8665. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8666. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8667. /// <param name="selector">A transform function to apply to each element.</param>
  8668. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable&lt;System.Int32&gt;" /> that corresponds to the maximum value in the source sequence.</returns>
  8669. /// <exception cref="T:System.ArgumentNullException">
  8670. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8671. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8672. public static IQbservable<int?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int?>> selector)
  8673. {
  8674. if (source == null)
  8675. throw new ArgumentNullException("source");
  8676. if (selector == null)
  8677. throw new ArgumentNullException("selector");
  8678. return source.Provider.CreateQuery<int?>(
  8679. Expression.Call(
  8680. null,
  8681. #if CRIPPLED_REFLECTION
  8682. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int?>>))),
  8683. #else
  8684. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8685. #endif
  8686. source.Expression,
  8687. selector
  8688. )
  8689. );
  8690. }
  8691. /// <summary>
  8692. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="T:System.Int64" /> value.
  8693. /// </summary>
  8694. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8695. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8696. /// <param name="selector">A transform function to apply to each element.</param>
  8697. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable&lt;System.Int64&gt;" /> that corresponds to the maximum value in the source sequence.</returns>
  8698. /// <exception cref="T:System.ArgumentNullException">
  8699. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8700. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8701. public static IQbservable<long?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long?>> selector)
  8702. {
  8703. if (source == null)
  8704. throw new ArgumentNullException("source");
  8705. if (selector == null)
  8706. throw new ArgumentNullException("selector");
  8707. return source.Provider.CreateQuery<long?>(
  8708. Expression.Call(
  8709. null,
  8710. #if CRIPPLED_REFLECTION
  8711. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long?>>))),
  8712. #else
  8713. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8714. #endif
  8715. source.Expression,
  8716. selector
  8717. )
  8718. );
  8719. }
  8720. /// <summary>
  8721. /// Invokes a transform function on each element of a sequence and returns the maximum value.
  8722. /// </summary>
  8723. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8724. /// <typeparam name="TResult">The type of the objects derived from the elements in the source sequence to determine the maximum of.</typeparam>
  8725. /// <param name="source">An observable sequence to determine the mimimum element of.</param>
  8726. /// <param name="selector">A transform function to apply to each element.</param>
  8727. /// <returns>An observable sequence containing a single element with the value that corresponds to the maximum element in the source sequence.</returns>
  8728. /// <exception cref="T:System.ArgumentNullException">
  8729. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8730. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8731. public static IQbservable<TResult> Max<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector)
  8732. {
  8733. if (source == null)
  8734. throw new ArgumentNullException("source");
  8735. if (selector == null)
  8736. throw new ArgumentNullException("selector");
  8737. return source.Provider.CreateQuery<TResult>(
  8738. Expression.Call(
  8739. null,
  8740. #if CRIPPLED_REFLECTION
  8741. InfoOf(() => Qbservable.Max<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>))),
  8742. #else
  8743. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  8744. #endif
  8745. source.Expression,
  8746. selector
  8747. )
  8748. );
  8749. }
  8750. /// <summary>
  8751. /// Invokes a transform function on each element of a sequence and returns the maximum value according to the specified comparer.
  8752. /// </summary>
  8753. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8754. /// <typeparam name="TResult">The type of the objects derived from the elements in the source sequence to determine the maximum of.</typeparam>
  8755. /// <param name="source">An observable sequence to determine the mimimum element of.</param>
  8756. /// <param name="selector">A transform function to apply to each element.</param>
  8757. /// <param name="comparer">Comparer used to compare elements.</param>
  8758. /// <returns>An observable sequence containing a single element with the value that corresponds to the maximum element in the source sequence.</returns>
  8759. /// <exception cref="T:System.ArgumentNullException">
  8760. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="comparer" /> is null.</exception>
  8761. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8762. public static IQbservable<TResult> Max<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector, IComparer<TResult> comparer)
  8763. {
  8764. if (source == null)
  8765. throw new ArgumentNullException("source");
  8766. if (selector == null)
  8767. throw new ArgumentNullException("selector");
  8768. if (comparer == null)
  8769. throw new ArgumentNullException("comparer");
  8770. return source.Provider.CreateQuery<TResult>(
  8771. Expression.Call(
  8772. null,
  8773. #if CRIPPLED_REFLECTION
  8774. InfoOf(() => Qbservable.Max<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>), default(IComparer<TResult>))),
  8775. #else
  8776. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  8777. #endif
  8778. source.Expression,
  8779. selector,
  8780. Expression.Constant(comparer, typeof(IComparer<TResult>))
  8781. )
  8782. );
  8783. }
  8784. /// <summary>
  8785. /// Returns the elements in an observable sequence with the maximum key value.
  8786. /// </summary>
  8787. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8788. /// <typeparam name="TKey">The type of the key computed for each element in the source sequence.</typeparam>
  8789. /// <param name="source">An observable sequence to get the maximum elements for.</param>
  8790. /// <param name="keySelector">Key selector function.</param>
  8791. /// <returns>An observable sequence containing a list of zero or more elements that have a maximum key value.</returns>
  8792. /// <exception cref="T:System.ArgumentNullException">
  8793. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  8794. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8795. public static IQbservable<IList<TSource>> MaxBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  8796. {
  8797. if (source == null)
  8798. throw new ArgumentNullException("source");
  8799. if (keySelector == null)
  8800. throw new ArgumentNullException("keySelector");
  8801. return source.Provider.CreateQuery<IList<TSource>>(
  8802. Expression.Call(
  8803. null,
  8804. #if CRIPPLED_REFLECTION
  8805. InfoOf(() => Qbservable.MaxBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  8806. #else
  8807. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  8808. #endif
  8809. source.Expression,
  8810. keySelector
  8811. )
  8812. );
  8813. }
  8814. /// <summary>
  8815. /// Returns the elements in an observable sequence with the maximum key value according to the specified comparer.
  8816. /// </summary>
  8817. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8818. /// <typeparam name="TKey">The type of the key computed for each element in the source sequence.</typeparam>
  8819. /// <param name="source">An observable sequence to get the maximum elements for.</param>
  8820. /// <param name="keySelector">Key selector function.</param>
  8821. /// <param name="comparer">Comparer used to compare key values.</param>
  8822. /// <returns>An observable sequence containing a list of zero or more elements that have a maximum key value.</returns>
  8823. /// <exception cref="T:System.ArgumentNullException">
  8824. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  8825. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8826. public static IQbservable<IList<TSource>> MaxBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer)
  8827. {
  8828. if (source == null)
  8829. throw new ArgumentNullException("source");
  8830. if (keySelector == null)
  8831. throw new ArgumentNullException("keySelector");
  8832. if (comparer == null)
  8833. throw new ArgumentNullException("comparer");
  8834. return source.Provider.CreateQuery<IList<TSource>>(
  8835. Expression.Call(
  8836. null,
  8837. #if CRIPPLED_REFLECTION
  8838. InfoOf(() => Qbservable.MaxBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IComparer<TKey>))),
  8839. #else
  8840. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  8841. #endif
  8842. source.Expression,
  8843. keySelector,
  8844. Expression.Constant(comparer, typeof(IComparer<TKey>))
  8845. )
  8846. );
  8847. }
  8848. /// <summary>
  8849. /// Merges elements from two observable sequences into a single observable sequence.
  8850. /// </summary>
  8851. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8852. /// <param name="first">First observable sequence.</param>
  8853. /// <param name="second">Second observable sequence.</param>
  8854. /// <returns>The observable sequence that merges the elements of the given sequences.</returns>
  8855. /// <exception cref="T:System.ArgumentNullException">
  8856. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  8857. public static IQbservable<TSource> Merge<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  8858. {
  8859. if (first == null)
  8860. throw new ArgumentNullException("first");
  8861. if (second == null)
  8862. throw new ArgumentNullException("second");
  8863. return first.Provider.CreateQuery<TSource>(
  8864. Expression.Call(
  8865. null,
  8866. #if CRIPPLED_REFLECTION
  8867. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  8868. #else
  8869. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8870. #endif
  8871. first.Expression,
  8872. GetSourceExpression(second)
  8873. )
  8874. );
  8875. }
  8876. /// <summary>
  8877. /// Merges elements from two observable sequences into a single observable sequence, using the specified scheduler for enumeration of and subscription to the sources.
  8878. /// </summary>
  8879. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8880. /// <param name="first">First observable sequence.</param>
  8881. /// <param name="second">Second observable sequence.</param>
  8882. /// <param name="scheduler">Scheduler used to introduce concurrency for making subscriptions to the given sequences.</param>
  8883. /// <returns>The observable sequence that merges the elements of the given sequences.</returns>
  8884. /// <exception cref="T:System.ArgumentNullException">
  8885. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="scheduler" /> is null.</exception>
  8886. public static IQbservable<TSource> Merge<TSource>(this IQbservable<TSource> first, IObservable<TSource> second, IScheduler scheduler)
  8887. {
  8888. if (first == null)
  8889. throw new ArgumentNullException("first");
  8890. if (second == null)
  8891. throw new ArgumentNullException("second");
  8892. if (scheduler == null)
  8893. throw new ArgumentNullException("scheduler");
  8894. return first.Provider.CreateQuery<TSource>(
  8895. Expression.Call(
  8896. null,
  8897. #if CRIPPLED_REFLECTION
  8898. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>), default(IScheduler))),
  8899. #else
  8900. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8901. #endif
  8902. first.Expression,
  8903. GetSourceExpression(second),
  8904. Expression.Constant(scheduler, typeof(IScheduler))
  8905. )
  8906. );
  8907. }
  8908. /// <summary>
  8909. /// Merges elements from all of the specified observable sequences into a single observable sequence, using the specified scheduler for enumeration of and subscription to the sources.
  8910. /// </summary>
  8911. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  8912. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8913. /// <param name="sources">Observable sequences.</param>
  8914. /// <param name="scheduler">Scheduler to run the enumeration of the sequence of sources on.</param>
  8915. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  8916. /// <exception cref="T:System.ArgumentNullException">
  8917. /// <paramref name="scheduler" /> or <paramref name="sources" /> is null.</exception>
  8918. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IScheduler scheduler, params IObservable<TSource>[] sources)
  8919. {
  8920. if (provider == null)
  8921. throw new ArgumentNullException("provider");
  8922. if (scheduler == null)
  8923. throw new ArgumentNullException("scheduler");
  8924. if (sources == null)
  8925. throw new ArgumentNullException("sources");
  8926. return provider.CreateQuery<TSource>(
  8927. Expression.Call(
  8928. null,
  8929. #if CRIPPLED_REFLECTION
  8930. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IScheduler), default(IObservable<TSource>[]))),
  8931. #else
  8932. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8933. #endif
  8934. Expression.Constant(provider, typeof(IQbservableProvider)),
  8935. Expression.Constant(scheduler, typeof(IScheduler)),
  8936. GetSourceExpression(sources)
  8937. )
  8938. );
  8939. }
  8940. /// <summary>
  8941. /// Merges elements from all inner observable sequences into a single observable sequence.
  8942. /// </summary>
  8943. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8944. /// <param name="sources">Observable sequence of inner observable sequences.</param>
  8945. /// <returns>The observable sequence that merges the elements of the inner sequences.</returns>
  8946. /// <exception cref="T:System.ArgumentNullException">
  8947. /// <paramref name="sources" /> is null.</exception>
  8948. public static IQbservable<TSource> Merge<TSource>(this IQbservable<IObservable<TSource>> sources)
  8949. {
  8950. if (sources == null)
  8951. throw new ArgumentNullException("sources");
  8952. return sources.Provider.CreateQuery<TSource>(
  8953. Expression.Call(
  8954. null,
  8955. #if CRIPPLED_REFLECTION
  8956. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<IObservable<TSource>>))),
  8957. #else
  8958. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8959. #endif
  8960. sources.Expression
  8961. )
  8962. );
  8963. }
  8964. #if !NO_TPL
  8965. /// <summary>
  8966. /// Merges results from all source tasks into a single observable sequence.
  8967. /// </summary>
  8968. /// <typeparam name="TSource">The type of the results produced by the source tasks.</typeparam>
  8969. /// <param name="sources">Observable sequence of tasks.</param>
  8970. /// <returns>The observable sequence that merges the results of the source tasks.</returns>
  8971. /// <exception cref="T:System.ArgumentNullException">
  8972. /// <paramref name="sources" /> is null.</exception>
  8973. /// <remarks>If the tasks support cancellation, consider manual conversion of the tasks using <see cref="M:System.Reactive.Linq.Observable.FromAsync``1(System.Func{System.Threading.CancellationToken,System.Threading.Tasks.Task{``0}})" />, followed by a merge operation using <see cref="M:System.Reactive.Linq.Observable.Merge``1(System.IObservable{System.IObservable{``0}})" />.</remarks>
  8974. public static IQbservable<TSource> Merge<TSource>(this IQbservable<Task<TSource>> sources)
  8975. {
  8976. if (sources == null)
  8977. throw new ArgumentNullException("sources");
  8978. return sources.Provider.CreateQuery<TSource>(
  8979. Expression.Call(
  8980. null,
  8981. #if CRIPPLED_REFLECTION
  8982. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<Task<TSource>>))),
  8983. #else
  8984. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8985. #endif
  8986. sources.Expression
  8987. )
  8988. );
  8989. }
  8990. #endif
  8991. /// <summary>
  8992. /// Merges elements from all of the specified observable sequences into a single observable sequence.
  8993. /// </summary>
  8994. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  8995. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8996. /// <param name="sources">Observable sequences.</param>
  8997. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  8998. /// <exception cref="T:System.ArgumentNullException">
  8999. /// <paramref name="sources" /> is null.</exception>
  9000. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  9001. {
  9002. if (provider == null)
  9003. throw new ArgumentNullException("provider");
  9004. if (sources == null)
  9005. throw new ArgumentNullException("sources");
  9006. return provider.CreateQuery<TSource>(
  9007. Expression.Call(
  9008. null,
  9009. #if CRIPPLED_REFLECTION
  9010. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  9011. #else
  9012. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9013. #endif
  9014. Expression.Constant(provider, typeof(IQbservableProvider)),
  9015. GetSourceExpression(sources)
  9016. )
  9017. );
  9018. }
  9019. /// <summary>
  9020. /// Merges elements from all observable sequences in the given enumerable sequence into a single observable sequence.
  9021. /// </summary>
  9022. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  9023. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  9024. /// <param name="sources">Enumerable sequence of observable sequences.</param>
  9025. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  9026. /// <exception cref="T:System.ArgumentNullException">
  9027. /// <paramref name="sources" /> is null.</exception>
  9028. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  9029. {
  9030. if (provider == null)
  9031. throw new ArgumentNullException("provider");
  9032. if (sources == null)
  9033. throw new ArgumentNullException("sources");
  9034. return provider.CreateQuery<TSource>(
  9035. Expression.Call(
  9036. null,
  9037. #if CRIPPLED_REFLECTION
  9038. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  9039. #else
  9040. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9041. #endif
  9042. Expression.Constant(provider, typeof(IQbservableProvider)),
  9043. GetSourceExpression(sources)
  9044. )
  9045. );
  9046. }
  9047. /// <summary>
  9048. /// Merges elements from all inner observable sequences into a single observable sequence, limiting the number of concurrent subscriptions to inner sequences.
  9049. /// </summary>
  9050. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  9051. /// <param name="sources">Observable sequence of inner observable sequences.</param>
  9052. /// <param name="maxConcurrent">Maximum number of inner observable sequences being subscribed to concurrently.</param>
  9053. /// <returns>The observable sequence that merges the elements of the inner sequences.</returns>
  9054. /// <exception cref="T:System.ArgumentNullException">
  9055. /// <paramref name="sources" /> is null.</exception>
  9056. /// <exception cref="T:System.ArgumentOutOfRangeException">
  9057. /// <paramref name="maxConcurrent" /> is less than or equal to zero.</exception>
  9058. public static IQbservable<TSource> Merge<TSource>(this IQbservable<IObservable<TSource>> sources, int maxConcurrent)
  9059. {
  9060. if (sources == null)
  9061. throw new ArgumentNullException("sources");
  9062. return sources.Provider.CreateQuery<TSource>(
  9063. Expression.Call(
  9064. null,
  9065. #if CRIPPLED_REFLECTION
  9066. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<IObservable<TSource>>), default(int))),
  9067. #else
  9068. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9069. #endif
  9070. sources.Expression,
  9071. Expression.Constant(maxConcurrent, typeof(int))
  9072. )
  9073. );
  9074. }
  9075. /// <summary>
  9076. /// Merges elements from all observable sequences in the given enumerable sequence into a single observable sequence, limiting the number of concurrent subscriptions to inner sequences.
  9077. /// </summary>
  9078. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  9079. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  9080. /// <param name="sources">Enumerable sequence of observable sequences.</param>
  9081. /// <param name="maxConcurrent">Maximum number of observable sequences being subscribed to concurrently.</param>
  9082. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  9083. /// <exception cref="T:System.ArgumentNullException">
  9084. /// <paramref name="sources" /> is null.</exception>
  9085. /// <exception cref="T:System.ArgumentOutOfRangeException">
  9086. /// <paramref name="maxConcurrent" /> is less than or equal to zero.</exception>
  9087. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, int maxConcurrent)
  9088. {
  9089. if (provider == null)
  9090. throw new ArgumentNullException("provider");
  9091. if (sources == null)
  9092. throw new ArgumentNullException("sources");
  9093. return provider.CreateQuery<TSource>(
  9094. Expression.Call(
  9095. null,
  9096. #if CRIPPLED_REFLECTION
  9097. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(int))),
  9098. #else
  9099. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9100. #endif
  9101. Expression.Constant(provider, typeof(IQbservableProvider)),
  9102. GetSourceExpression(sources),
  9103. Expression.Constant(maxConcurrent, typeof(int))
  9104. )
  9105. );
  9106. }
  9107. /// <summary>
  9108. /// Merges elements from all observable sequences in the given enumerable sequence into a single observable sequence, limiting the number of concurrent subscriptions to inner sequences, and using the specified scheduler for enumeration of and subscription to the sources.
  9109. /// </summary>
  9110. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  9111. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  9112. /// <param name="sources">Enumerable sequence of observable sequences.</param>
  9113. /// <param name="maxConcurrent">Maximum number of observable sequences being subscribed to concurrently.</param>
  9114. /// <param name="scheduler">Scheduler to run the enumeration of the sequence of sources on.</param>
  9115. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  9116. /// <exception cref="T:System.ArgumentNullException">
  9117. /// <paramref name="sources" /> or <paramref name="scheduler" /> is null.</exception>
  9118. /// <exception cref="T:System.ArgumentOutOfRangeException">
  9119. /// <paramref name="maxConcurrent" /> is less than or equal to zero.</exception>
  9120. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, int maxConcurrent, IScheduler scheduler)
  9121. {
  9122. if (provider == null)
  9123. throw new ArgumentNullException("provider");
  9124. if (sources == null)
  9125. throw new ArgumentNullException("sources");
  9126. if (scheduler == null)
  9127. throw new ArgumentNullException("scheduler");
  9128. return provider.CreateQuery<TSource>(
  9129. Expression.Call(
  9130. null,
  9131. #if CRIPPLED_REFLECTION
  9132. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(int), default(IScheduler))),
  9133. #else
  9134. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9135. #endif
  9136. Expression.Constant(provider, typeof(IQbservableProvider)),
  9137. GetSourceExpression(sources),
  9138. Expression.Constant(maxConcurrent, typeof(int)),
  9139. Expression.Constant(scheduler, typeof(IScheduler))
  9140. )
  9141. );
  9142. }
  9143. /// <summary>
  9144. /// Merges elements from all observable sequences in the given enumerable sequence into a single observable sequence, using the specified scheduler for enumeration of and subscription to the sources.
  9145. /// </summary>
  9146. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  9147. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  9148. /// <param name="sources">Enumerable sequence of observable sequences.</param>
  9149. /// <param name="scheduler">Scheduler to run the enumeration of the sequence of sources on.</param>
  9150. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  9151. /// <exception cref="T:System.ArgumentNullException">
  9152. /// <paramref name="sources" /> or <paramref name="scheduler" /> is null.</exception>
  9153. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, IScheduler scheduler)
  9154. {
  9155. if (provider == null)
  9156. throw new ArgumentNullException("provider");
  9157. if (sources == null)
  9158. throw new ArgumentNullException("sources");
  9159. if (scheduler == null)
  9160. throw new ArgumentNullException("scheduler");
  9161. return provider.CreateQuery<TSource>(
  9162. Expression.Call(
  9163. null,
  9164. #if CRIPPLED_REFLECTION
  9165. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(IScheduler))),
  9166. #else
  9167. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9168. #endif
  9169. Expression.Constant(provider, typeof(IQbservableProvider)),
  9170. GetSourceExpression(sources),
  9171. Expression.Constant(scheduler, typeof(IScheduler))
  9172. )
  9173. );
  9174. }
  9175. /// <summary>
  9176. /// Returns the minimum value in an observable sequence of <see cref="T:System.Decimal" /> values.
  9177. /// </summary>
  9178. /// <param name="source">A sequence of <see cref="T:System.Decimal" /> values to determine the minimum value of.</param>
  9179. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9180. /// <exception cref="T:System.ArgumentNullException">
  9181. /// <paramref name="source" /> is null.</exception>
  9182. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9183. public static IQbservable<decimal> Min(this IQbservable<decimal> source)
  9184. {
  9185. if (source == null)
  9186. throw new ArgumentNullException("source");
  9187. return source.Provider.CreateQuery<decimal>(
  9188. Expression.Call(
  9189. null,
  9190. #if CRIPPLED_REFLECTION
  9191. InfoOf(() => Qbservable.Min(default(IQbservable<decimal>))),
  9192. #else
  9193. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9194. #endif
  9195. source.Expression
  9196. )
  9197. );
  9198. }
  9199. /// <summary>
  9200. /// Returns the minimum value in an observable sequence of <see cref="T:System.Double" /> values.
  9201. /// </summary>
  9202. /// <param name="source">A sequence of <see cref="T:System.Double" /> values to determine the minimum value of.</param>
  9203. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9204. /// <exception cref="T:System.ArgumentNullException">
  9205. /// <paramref name="source" /> is null.</exception>
  9206. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9207. public static IQbservable<double> Min(this IQbservable<double> source)
  9208. {
  9209. if (source == null)
  9210. throw new ArgumentNullException("source");
  9211. return source.Provider.CreateQuery<double>(
  9212. Expression.Call(
  9213. null,
  9214. #if CRIPPLED_REFLECTION
  9215. InfoOf(() => Qbservable.Min(default(IQbservable<double>))),
  9216. #else
  9217. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9218. #endif
  9219. source.Expression
  9220. )
  9221. );
  9222. }
  9223. /// <summary>
  9224. /// Returns the minimum value in an observable sequence of <see cref="T:System.Int32" /> values.
  9225. /// </summary>
  9226. /// <param name="source">A sequence of <see cref="T:System.Int32" /> values to determine the minimum value of.</param>
  9227. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9228. /// <exception cref="T:System.ArgumentNullException">
  9229. /// <paramref name="source" /> is null.</exception>
  9230. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9231. public static IQbservable<int> Min(this IQbservable<int> source)
  9232. {
  9233. if (source == null)
  9234. throw new ArgumentNullException("source");
  9235. return source.Provider.CreateQuery<int>(
  9236. Expression.Call(
  9237. null,
  9238. #if CRIPPLED_REFLECTION
  9239. InfoOf(() => Qbservable.Min(default(IQbservable<int>))),
  9240. #else
  9241. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9242. #endif
  9243. source.Expression
  9244. )
  9245. );
  9246. }
  9247. /// <summary>
  9248. /// Returns the minimum value in an observable sequence of <see cref="T:System.Int64" /> values.
  9249. /// </summary>
  9250. /// <param name="source">A sequence of <see cref="T:System.Int64" /> values to determine the minimum value of.</param>
  9251. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9252. /// <exception cref="T:System.ArgumentNullException">
  9253. /// <paramref name="source" /> is null.</exception>
  9254. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9255. public static IQbservable<long> Min(this IQbservable<long> source)
  9256. {
  9257. if (source == null)
  9258. throw new ArgumentNullException("source");
  9259. return source.Provider.CreateQuery<long>(
  9260. Expression.Call(
  9261. null,
  9262. #if CRIPPLED_REFLECTION
  9263. InfoOf(() => Qbservable.Min(default(IQbservable<long>))),
  9264. #else
  9265. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9266. #endif
  9267. source.Expression
  9268. )
  9269. );
  9270. }
  9271. /// <summary>
  9272. /// Returns the minimum value in an observable sequence of nullable <see cref="T:System.Decimal" /> values.
  9273. /// </summary>
  9274. /// <param name="source">A sequence of nullable <see cref="T:System.Decimal" /> values to determine the minimum value of.</param>
  9275. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9276. /// <exception cref="T:System.ArgumentNullException">
  9277. /// <paramref name="source" /> is null.</exception>
  9278. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9279. public static IQbservable<decimal?> Min(this IQbservable<decimal?> source)
  9280. {
  9281. if (source == null)
  9282. throw new ArgumentNullException("source");
  9283. return source.Provider.CreateQuery<decimal?>(
  9284. Expression.Call(
  9285. null,
  9286. #if CRIPPLED_REFLECTION
  9287. InfoOf(() => Qbservable.Min(default(IQbservable<decimal?>))),
  9288. #else
  9289. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9290. #endif
  9291. source.Expression
  9292. )
  9293. );
  9294. }
  9295. /// <summary>
  9296. /// Returns the minimum value in an observable sequence of nullable <see cref="T:System.Double" /> values.
  9297. /// </summary>
  9298. /// <param name="source">A sequence of nullable <see cref="T:System.Double" /> values to determine the minimum value of.</param>
  9299. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9300. /// <exception cref="T:System.ArgumentNullException">
  9301. /// <paramref name="source" /> is null.</exception>
  9302. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9303. public static IQbservable<double?> Min(this IQbservable<double?> source)
  9304. {
  9305. if (source == null)
  9306. throw new ArgumentNullException("source");
  9307. return source.Provider.CreateQuery<double?>(
  9308. Expression.Call(
  9309. null,
  9310. #if CRIPPLED_REFLECTION
  9311. InfoOf(() => Qbservable.Min(default(IQbservable<double?>))),
  9312. #else
  9313. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9314. #endif
  9315. source.Expression
  9316. )
  9317. );
  9318. }
  9319. /// <summary>
  9320. /// Returns the minimum value in an observable sequence of nullable <see cref="T:System.Int32" /> values.
  9321. /// </summary>
  9322. /// <param name="source">A sequence of nullable <see cref="T:System.Int32" /> values to determine the minimum value of.</param>
  9323. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9324. /// <exception cref="T:System.ArgumentNullException">
  9325. /// <paramref name="source" /> is null.</exception>
  9326. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9327. public static IQbservable<int?> Min(this IQbservable<int?> source)
  9328. {
  9329. if (source == null)
  9330. throw new ArgumentNullException("source");
  9331. return source.Provider.CreateQuery<int?>(
  9332. Expression.Call(
  9333. null,
  9334. #if CRIPPLED_REFLECTION
  9335. InfoOf(() => Qbservable.Min(default(IQbservable<int?>))),
  9336. #else
  9337. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9338. #endif
  9339. source.Expression
  9340. )
  9341. );
  9342. }
  9343. /// <summary>
  9344. /// Returns the minimum value in an observable sequence of nullable <see cref="T:System.Int64" /> values.
  9345. /// </summary>
  9346. /// <param name="source">A sequence of nullable <see cref="T:System.Int64" /> values to determine the minimum value of.</param>
  9347. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9348. /// <exception cref="T:System.ArgumentNullException">
  9349. /// <paramref name="source" /> is null.</exception>
  9350. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9351. public static IQbservable<long?> Min(this IQbservable<long?> source)
  9352. {
  9353. if (source == null)
  9354. throw new ArgumentNullException("source");
  9355. return source.Provider.CreateQuery<long?>(
  9356. Expression.Call(
  9357. null,
  9358. #if CRIPPLED_REFLECTION
  9359. InfoOf(() => Qbservable.Min(default(IQbservable<long?>))),
  9360. #else
  9361. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9362. #endif
  9363. source.Expression
  9364. )
  9365. );
  9366. }
  9367. /// <summary>
  9368. /// Returns the minimum value in an observable sequence of nullable <see cref="T:System.Single" /> values.
  9369. /// </summary>
  9370. /// <param name="source">A sequence of nullable <see cref="T:System.Single" /> values to determine the minimum value of.</param>
  9371. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9372. /// <exception cref="T:System.ArgumentNullException">
  9373. /// <paramref name="source" /> is null.</exception>
  9374. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9375. public static IQbservable<float?> Min(this IQbservable<float?> source)
  9376. {
  9377. if (source == null)
  9378. throw new ArgumentNullException("source");
  9379. return source.Provider.CreateQuery<float?>(
  9380. Expression.Call(
  9381. null,
  9382. #if CRIPPLED_REFLECTION
  9383. InfoOf(() => Qbservable.Min(default(IQbservable<float?>))),
  9384. #else
  9385. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9386. #endif
  9387. source.Expression
  9388. )
  9389. );
  9390. }
  9391. /// <summary>
  9392. /// Returns the minimum value in an observable sequence of <see cref="T:System.Single" /> values.
  9393. /// </summary>
  9394. /// <param name="source">A sequence of <see cref="T:System.Single" /> values to determine the minimum value of.</param>
  9395. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9396. /// <exception cref="T:System.ArgumentNullException">
  9397. /// <paramref name="source" /> is null.</exception>
  9398. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9399. public static IQbservable<float> Min(this IQbservable<float> source)
  9400. {
  9401. if (source == null)
  9402. throw new ArgumentNullException("source");
  9403. return source.Provider.CreateQuery<float>(
  9404. Expression.Call(
  9405. null,
  9406. #if CRIPPLED_REFLECTION
  9407. InfoOf(() => Qbservable.Min(default(IQbservable<float>))),
  9408. #else
  9409. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9410. #endif
  9411. source.Expression
  9412. )
  9413. );
  9414. }
  9415. /// <summary>
  9416. /// Returns the minimum element in an observable sequence.
  9417. /// </summary>
  9418. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9419. /// <param name="source">An observable sequence to determine the mimimum element of.</param>
  9420. /// <returns>An observable sequence containing a single element with the minimum element in the source sequence.</returns>
  9421. /// <exception cref="T:System.ArgumentNullException">
  9422. /// <paramref name="source" /> is null.</exception>
  9423. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9424. public static IQbservable<TSource> Min<TSource>(this IQbservable<TSource> source)
  9425. {
  9426. if (source == null)
  9427. throw new ArgumentNullException("source");
  9428. return source.Provider.CreateQuery<TSource>(
  9429. Expression.Call(
  9430. null,
  9431. #if CRIPPLED_REFLECTION
  9432. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>))),
  9433. #else
  9434. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9435. #endif
  9436. source.Expression
  9437. )
  9438. );
  9439. }
  9440. /// <summary>
  9441. /// Returns the minimum element in an observable sequence according to the specified comparer.
  9442. /// </summary>
  9443. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9444. /// <param name="source">An observable sequence to determine the mimimum element of.</param>
  9445. /// <param name="comparer">Comparer used to compare elements.</param>
  9446. /// <returns>An observable sequence containing a single element with the minimum element in the source sequence.</returns>
  9447. /// <exception cref="T:System.ArgumentNullException">
  9448. /// <paramref name="source" /> or <paramref name="comparer" /> is null.</exception>
  9449. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9450. public static IQbservable<TSource> Min<TSource>(this IQbservable<TSource> source, IComparer<TSource> comparer)
  9451. {
  9452. if (source == null)
  9453. throw new ArgumentNullException("source");
  9454. if (comparer == null)
  9455. throw new ArgumentNullException("comparer");
  9456. return source.Provider.CreateQuery<TSource>(
  9457. Expression.Call(
  9458. null,
  9459. #if CRIPPLED_REFLECTION
  9460. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(IComparer<TSource>))),
  9461. #else
  9462. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9463. #endif
  9464. source.Expression,
  9465. Expression.Constant(comparer, typeof(IComparer<TSource>))
  9466. )
  9467. );
  9468. }
  9469. /// <summary>
  9470. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="T:System.Double" /> value.
  9471. /// </summary>
  9472. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9473. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9474. /// <param name="selector">A transform function to apply to each element.</param>
  9475. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Double" /> that corresponds to the minimum value in the source sequence.</returns>
  9476. /// <exception cref="T:System.ArgumentNullException">
  9477. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9478. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9479. public static IQbservable<double> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double>> selector)
  9480. {
  9481. if (source == null)
  9482. throw new ArgumentNullException("source");
  9483. if (selector == null)
  9484. throw new ArgumentNullException("selector");
  9485. return source.Provider.CreateQuery<double>(
  9486. Expression.Call(
  9487. null,
  9488. #if CRIPPLED_REFLECTION
  9489. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double>>))),
  9490. #else
  9491. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9492. #endif
  9493. source.Expression,
  9494. selector
  9495. )
  9496. );
  9497. }
  9498. /// <summary>
  9499. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="T:System.Single" /> value.
  9500. /// </summary>
  9501. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9502. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9503. /// <param name="selector">A transform function to apply to each element.</param>
  9504. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Single" /> that corresponds to the minimum value in the source sequence.</returns>
  9505. /// <exception cref="T:System.ArgumentNullException">
  9506. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9507. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9508. public static IQbservable<float> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float>> selector)
  9509. {
  9510. if (source == null)
  9511. throw new ArgumentNullException("source");
  9512. if (selector == null)
  9513. throw new ArgumentNullException("selector");
  9514. return source.Provider.CreateQuery<float>(
  9515. Expression.Call(
  9516. null,
  9517. #if CRIPPLED_REFLECTION
  9518. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float>>))),
  9519. #else
  9520. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9521. #endif
  9522. source.Expression,
  9523. selector
  9524. )
  9525. );
  9526. }
  9527. /// <summary>
  9528. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="T:System.Decimal" /> value.
  9529. /// </summary>
  9530. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9531. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9532. /// <param name="selector">A transform function to apply to each element.</param>
  9533. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Decimal" /> that corresponds to the minimum value in the source sequence.</returns>
  9534. /// <exception cref="T:System.ArgumentNullException">
  9535. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9536. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9537. public static IQbservable<decimal> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal>> selector)
  9538. {
  9539. if (source == null)
  9540. throw new ArgumentNullException("source");
  9541. if (selector == null)
  9542. throw new ArgumentNullException("selector");
  9543. return source.Provider.CreateQuery<decimal>(
  9544. Expression.Call(
  9545. null,
  9546. #if CRIPPLED_REFLECTION
  9547. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal>>))),
  9548. #else
  9549. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9550. #endif
  9551. source.Expression,
  9552. selector
  9553. )
  9554. );
  9555. }
  9556. /// <summary>
  9557. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="T:System.Int32" /> value.
  9558. /// </summary>
  9559. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9560. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9561. /// <param name="selector">A transform function to apply to each element.</param>
  9562. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Int32" /> that corresponds to the minimum value in the source sequence.</returns>
  9563. /// <exception cref="T:System.ArgumentNullException">
  9564. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9565. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9566. public static IQbservable<int> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int>> selector)
  9567. {
  9568. if (source == null)
  9569. throw new ArgumentNullException("source");
  9570. if (selector == null)
  9571. throw new ArgumentNullException("selector");
  9572. return source.Provider.CreateQuery<int>(
  9573. Expression.Call(
  9574. null,
  9575. #if CRIPPLED_REFLECTION
  9576. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int>>))),
  9577. #else
  9578. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9579. #endif
  9580. source.Expression,
  9581. selector
  9582. )
  9583. );
  9584. }
  9585. /// <summary>
  9586. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="T:System.Int64" /> value.
  9587. /// </summary>
  9588. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9589. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9590. /// <param name="selector">A transform function to apply to each element.</param>
  9591. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Int64" /> that corresponds to the minimum value in the source sequence.</returns>
  9592. /// <exception cref="T:System.ArgumentNullException">
  9593. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9594. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9595. public static IQbservable<long> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long>> selector)
  9596. {
  9597. if (source == null)
  9598. throw new ArgumentNullException("source");
  9599. if (selector == null)
  9600. throw new ArgumentNullException("selector");
  9601. return source.Provider.CreateQuery<long>(
  9602. Expression.Call(
  9603. null,
  9604. #if CRIPPLED_REFLECTION
  9605. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long>>))),
  9606. #else
  9607. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9608. #endif
  9609. source.Expression,
  9610. selector
  9611. )
  9612. );
  9613. }
  9614. /// <summary>
  9615. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="T:System.Double" /> value.
  9616. /// </summary>
  9617. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9618. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9619. /// <param name="selector">A transform function to apply to each element.</param>
  9620. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable&lt;System.Double&gt;" /> that corresponds to the minimum value in the source sequence.</returns>
  9621. /// <exception cref="T:System.ArgumentNullException">
  9622. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9623. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9624. public static IQbservable<double?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double?>> selector)
  9625. {
  9626. if (source == null)
  9627. throw new ArgumentNullException("source");
  9628. if (selector == null)
  9629. throw new ArgumentNullException("selector");
  9630. return source.Provider.CreateQuery<double?>(
  9631. Expression.Call(
  9632. null,
  9633. #if CRIPPLED_REFLECTION
  9634. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double?>>))),
  9635. #else
  9636. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9637. #endif
  9638. source.Expression,
  9639. selector
  9640. )
  9641. );
  9642. }
  9643. /// <summary>
  9644. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="T:System.Single" /> value.
  9645. /// </summary>
  9646. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9647. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9648. /// <param name="selector">A transform function to apply to each element.</param>
  9649. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable&lt;System.Single&gt;" /> that corresponds to the minimum value in the source sequence.</returns>
  9650. /// <exception cref="T:System.ArgumentNullException">
  9651. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9652. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9653. public static IQbservable<float?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float?>> selector)
  9654. {
  9655. if (source == null)
  9656. throw new ArgumentNullException("source");
  9657. if (selector == null)
  9658. throw new ArgumentNullException("selector");
  9659. return source.Provider.CreateQuery<float?>(
  9660. Expression.Call(
  9661. null,
  9662. #if CRIPPLED_REFLECTION
  9663. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float?>>))),
  9664. #else
  9665. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9666. #endif
  9667. source.Expression,
  9668. selector
  9669. )
  9670. );
  9671. }
  9672. /// <summary>
  9673. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="T:System.Decimal" /> value.
  9674. /// </summary>
  9675. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9676. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9677. /// <param name="selector">A transform function to apply to each element.</param>
  9678. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable&lt;System.Decimal&gt;" /> that corresponds to the minimum value in the source sequence.</returns>
  9679. /// <exception cref="T:System.ArgumentNullException">
  9680. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9681. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9682. public static IQbservable<decimal?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal?>> selector)
  9683. {
  9684. if (source == null)
  9685. throw new ArgumentNullException("source");
  9686. if (selector == null)
  9687. throw new ArgumentNullException("selector");
  9688. return source.Provider.CreateQuery<decimal?>(
  9689. Expression.Call(
  9690. null,
  9691. #if CRIPPLED_REFLECTION
  9692. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal?>>))),
  9693. #else
  9694. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9695. #endif
  9696. source.Expression,
  9697. selector
  9698. )
  9699. );
  9700. }
  9701. /// <summary>
  9702. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="T:System.Int32" /> value.
  9703. /// </summary>
  9704. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9705. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9706. /// <param name="selector">A transform function to apply to each element.</param>
  9707. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable&lt;System.Int32&gt;" /> that corresponds to the minimum value in the source sequence.</returns>
  9708. /// <exception cref="T:System.ArgumentNullException">
  9709. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9710. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9711. public static IQbservable<int?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int?>> selector)
  9712. {
  9713. if (source == null)
  9714. throw new ArgumentNullException("source");
  9715. if (selector == null)
  9716. throw new ArgumentNullException("selector");
  9717. return source.Provider.CreateQuery<int?>(
  9718. Expression.Call(
  9719. null,
  9720. #if CRIPPLED_REFLECTION
  9721. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int?>>))),
  9722. #else
  9723. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9724. #endif
  9725. source.Expression,
  9726. selector
  9727. )
  9728. );
  9729. }
  9730. /// <summary>
  9731. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="T:System.Int64" /> value.
  9732. /// </summary>
  9733. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9734. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9735. /// <param name="selector">A transform function to apply to each element.</param>
  9736. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable&lt;System.Int64&gt;" /> that corresponds to the minimum value in the source sequence.</returns>
  9737. /// <exception cref="T:System.ArgumentNullException">
  9738. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9739. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9740. public static IQbservable<long?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long?>> selector)
  9741. {
  9742. if (source == null)
  9743. throw new ArgumentNullException("source");
  9744. if (selector == null)
  9745. throw new ArgumentNullException("selector");
  9746. return source.Provider.CreateQuery<long?>(
  9747. Expression.Call(
  9748. null,
  9749. #if CRIPPLED_REFLECTION
  9750. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long?>>))),
  9751. #else
  9752. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9753. #endif
  9754. source.Expression,
  9755. selector
  9756. )
  9757. );
  9758. }
  9759. /// <summary>
  9760. /// Invokes a transform function on each element of a sequence and returns the minimum value.
  9761. /// </summary>
  9762. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9763. /// <typeparam name="TResult">The type of the objects derived from the elements in the source sequence to determine the minimum of.</typeparam>
  9764. /// <param name="source">An observable sequence to determine the mimimum element of.</param>
  9765. /// <param name="selector">A transform function to apply to each element.</param>
  9766. /// <returns>An observable sequence containing a single element with the value that corresponds to the minimum element in the source sequence.</returns>
  9767. /// <exception cref="T:System.ArgumentNullException">
  9768. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9769. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9770. public static IQbservable<TResult> Min<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector)
  9771. {
  9772. if (source == null)
  9773. throw new ArgumentNullException("source");
  9774. if (selector == null)
  9775. throw new ArgumentNullException("selector");
  9776. return source.Provider.CreateQuery<TResult>(
  9777. Expression.Call(
  9778. null,
  9779. #if CRIPPLED_REFLECTION
  9780. InfoOf(() => Qbservable.Min<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>))),
  9781. #else
  9782. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  9783. #endif
  9784. source.Expression,
  9785. selector
  9786. )
  9787. );
  9788. }
  9789. /// <summary>
  9790. /// Invokes a transform function on each element of a sequence and returns the minimum value according to the specified comparer.
  9791. /// </summary>
  9792. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9793. /// <typeparam name="TResult">The type of the objects derived from the elements in the source sequence to determine the minimum of.</typeparam>
  9794. /// <param name="source">An observable sequence to determine the mimimum element of.</param>
  9795. /// <param name="selector">A transform function to apply to each element.</param>
  9796. /// <param name="comparer">Comparer used to compare elements.</param>
  9797. /// <returns>An observable sequence containing a single element with the value that corresponds to the minimum element in the source sequence.</returns>
  9798. /// <exception cref="T:System.ArgumentNullException">
  9799. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="comparer" /> is null.</exception>
  9800. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9801. public static IQbservable<TResult> Min<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector, IComparer<TResult> comparer)
  9802. {
  9803. if (source == null)
  9804. throw new ArgumentNullException("source");
  9805. if (selector == null)
  9806. throw new ArgumentNullException("selector");
  9807. if (comparer == null)
  9808. throw new ArgumentNullException("comparer");
  9809. return source.Provider.CreateQuery<TResult>(
  9810. Expression.Call(
  9811. null,
  9812. #if CRIPPLED_REFLECTION
  9813. InfoOf(() => Qbservable.Min<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>), default(IComparer<TResult>))),
  9814. #else
  9815. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  9816. #endif
  9817. source.Expression,
  9818. selector,
  9819. Expression.Constant(comparer, typeof(IComparer<TResult>))
  9820. )
  9821. );
  9822. }
  9823. /// <summary>
  9824. /// Returns the elements in an observable sequence with the minimum key value.
  9825. /// </summary>
  9826. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9827. /// <typeparam name="TKey">The type of the key computed for each element in the source sequence.</typeparam>
  9828. /// <param name="source">An observable sequence to get the minimum elements for.</param>
  9829. /// <param name="keySelector">Key selector function.</param>
  9830. /// <returns>An observable sequence containing a list of zero or more elements that have a minimum key value.</returns>
  9831. /// <exception cref="T:System.ArgumentNullException">
  9832. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  9833. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9834. public static IQbservable<IList<TSource>> MinBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  9835. {
  9836. if (source == null)
  9837. throw new ArgumentNullException("source");
  9838. if (keySelector == null)
  9839. throw new ArgumentNullException("keySelector");
  9840. return source.Provider.CreateQuery<IList<TSource>>(
  9841. Expression.Call(
  9842. null,
  9843. #if CRIPPLED_REFLECTION
  9844. InfoOf(() => Qbservable.MinBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  9845. #else
  9846. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  9847. #endif
  9848. source.Expression,
  9849. keySelector
  9850. )
  9851. );
  9852. }
  9853. /// <summary>
  9854. /// Returns the elements in an observable sequence with the minimum key value according to the specified comparer.
  9855. /// </summary>
  9856. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9857. /// <typeparam name="TKey">The type of the key computed for each element in the source sequence.</typeparam>
  9858. /// <param name="source">An observable sequence to get the minimum elements for.</param>
  9859. /// <param name="keySelector">Key selector function.</param>
  9860. /// <param name="comparer">Comparer used to compare key values.</param>
  9861. /// <returns>An observable sequence containing a list of zero or more elements that have a minimum key value.</returns>
  9862. /// <exception cref="T:System.ArgumentNullException">
  9863. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  9864. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9865. public static IQbservable<IList<TSource>> MinBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer)
  9866. {
  9867. if (source == null)
  9868. throw new ArgumentNullException("source");
  9869. if (keySelector == null)
  9870. throw new ArgumentNullException("keySelector");
  9871. if (comparer == null)
  9872. throw new ArgumentNullException("comparer");
  9873. return source.Provider.CreateQuery<IList<TSource>>(
  9874. Expression.Call(
  9875. null,
  9876. #if CRIPPLED_REFLECTION
  9877. InfoOf(() => Qbservable.MinBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IComparer<TKey>))),
  9878. #else
  9879. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  9880. #endif
  9881. source.Expression,
  9882. keySelector,
  9883. Expression.Constant(comparer, typeof(IComparer<TKey>))
  9884. )
  9885. );
  9886. }
  9887. /// <summary>
  9888. /// Returns an enumerable sequence whose enumeration returns the most recently observed element in the source observable sequence, using the specified initial value in case no element has been sampled yet.
  9889. /// Enumerators on the resulting sequence never block and can produce the same element repeatedly.
  9890. /// </summary>
  9891. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9892. /// <param name="source">Source observable sequence.</param>
  9893. /// <param name="initialValue">Initial value that will be yielded by the enumerable sequence if no element has been sampled yet.</param>
  9894. /// <returns>The enumerable sequence that returns the last sampled element upon each iteration.</returns>
  9895. /// <exception cref="T:System.ArgumentNullException">
  9896. /// <paramref name="source" /> is null.</exception>
  9897. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  9898. public static IQueryable<TSource> MostRecent<TSource>(this IQbservable<TSource> source, TSource initialValue)
  9899. {
  9900. if (source == null)
  9901. throw new ArgumentNullException("source");
  9902. return ((IQueryProvider)source.Provider).CreateQuery<TSource>(
  9903. Expression.Call(
  9904. null,
  9905. #if CRIPPLED_REFLECTION
  9906. InfoOf(() => Qbservable.MostRecent<TSource>(default(IQbservable<TSource>), default(TSource))),
  9907. #else
  9908. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9909. #endif
  9910. source.Expression,
  9911. Expression.Constant(initialValue, typeof(TSource))
  9912. )
  9913. );
  9914. }
  9915. /// <summary>
  9916. /// Multicasts the source sequence notifications through an instantiated subject into all uses of the sequence within a selector function. Each
  9917. /// subscription to the resulting sequence causes a separate multicast invocation, exposing the sequence resulting from the selector function's
  9918. /// invocation. For specializations with fixed subject types, see Publish, PublishLast, and Replay.
  9919. /// </summary>
  9920. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9921. /// <typeparam name="TIntermediate">The type of the elements produced by the intermediate subject.</typeparam>
  9922. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  9923. /// <param name="source">Source sequence which will be multicasted in the specified selector function.</param>
  9924. /// <param name="subjectSelector">Factory function to create an intermediate subject through which the source sequence's elements will be multicast to the selector function.</param>
  9925. /// <param name="selector">Selector function which can use the multicasted source sequence subject to the policies enforced by the created subject.</param>
  9926. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  9927. /// <exception cref="T:System.ArgumentNullException">
  9928. /// <paramref name="source" /> or <paramref name="subjectSelector" /> or <paramref name="selector" /> is null.</exception>
  9929. public static IQbservable<TResult> Multicast<TSource, TIntermediate, TResult>(this IQbservable<TSource> source, Expression<Func<ISubject<TSource, TIntermediate>>> subjectSelector, Expression<Func<IObservable<TIntermediate>, IObservable<TResult>>> selector)
  9930. {
  9931. if (source == null)
  9932. throw new ArgumentNullException("source");
  9933. if (subjectSelector == null)
  9934. throw new ArgumentNullException("subjectSelector");
  9935. if (selector == null)
  9936. throw new ArgumentNullException("selector");
  9937. return source.Provider.CreateQuery<TResult>(
  9938. Expression.Call(
  9939. null,
  9940. #if CRIPPLED_REFLECTION
  9941. InfoOf(() => Qbservable.Multicast<TSource, TIntermediate, TResult>(default(IQbservable<TSource>), default(Expression<Func<ISubject<TSource, TIntermediate>>>), default(Expression<Func<IObservable<TIntermediate>, IObservable<TResult>>>))),
  9942. #else
  9943. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TIntermediate), typeof(TResult)),
  9944. #endif
  9945. source.Expression,
  9946. subjectSelector,
  9947. selector
  9948. )
  9949. );
  9950. }
  9951. /// <summary>
  9952. /// Returns a non-terminating observable sequence, which can be used to denote an infinite duration (e.g. when using reactive joins).
  9953. /// </summary>
  9954. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  9955. /// <typeparam name="TResult">The type used for the IObservable&lt;T&gt; type parameter of the resulting sequence.</typeparam>
  9956. /// <returns>An observable sequence whose observers will never get called.</returns>
  9957. public static IQbservable<TResult> Never<TResult>(this IQbservableProvider provider)
  9958. {
  9959. if (provider == null)
  9960. throw new ArgumentNullException("provider");
  9961. return provider.CreateQuery<TResult>(
  9962. Expression.Call(
  9963. null,
  9964. #if CRIPPLED_REFLECTION
  9965. InfoOf(() => Qbservable.Never<TResult>(default(IQbservableProvider))),
  9966. #else
  9967. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  9968. #endif
  9969. Expression.Constant(provider, typeof(IQbservableProvider))
  9970. )
  9971. );
  9972. }
  9973. /// <summary>
  9974. /// Returns a non-terminating observable sequence, which can be used to denote an infinite duration (e.g. when using reactive joins).
  9975. /// </summary>
  9976. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  9977. /// <typeparam name="TResult">The type used for the IObservable&lt;T&gt; type parameter of the resulting sequence.</typeparam>
  9978. /// <param name="witness">Object solely used to infer the type of the <typeparamref name="TResult" /> type parameter. This parameter is typically used when creating a sequence of anonymously typed elements.</param>
  9979. /// <returns>An observable sequence whose observers will never get called.</returns>
  9980. public static IQbservable<TResult> Never<TResult>(this IQbservableProvider provider, TResult witness)
  9981. {
  9982. if (provider == null)
  9983. throw new ArgumentNullException("provider");
  9984. return provider.CreateQuery<TResult>(
  9985. Expression.Call(
  9986. null,
  9987. #if CRIPPLED_REFLECTION
  9988. InfoOf(() => Qbservable.Never<TResult>(default(IQbservableProvider), default(TResult))),
  9989. #else
  9990. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  9991. #endif
  9992. Expression.Constant(provider, typeof(IQbservableProvider)),
  9993. Expression.Constant(witness, typeof(TResult))
  9994. )
  9995. );
  9996. }
  9997. /// <summary>
  9998. /// Returns an enumerable sequence whose enumeration blocks until the next element in the source observable sequence becomes available.
  9999. /// Enumerators on the resulting sequence will block until the next element becomes available.
  10000. /// </summary>
  10001. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10002. /// <param name="source">Source observable sequence.</param>
  10003. /// <returns>The enumerable sequence that blocks upon each iteration until the next element in the observable source sequence becomes available.</returns>
  10004. /// <exception cref="T:System.ArgumentNullException">
  10005. /// <paramref name="source" /> is null.</exception>
  10006. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  10007. public static IQueryable<TSource> Next<TSource>(this IQbservable<TSource> source)
  10008. {
  10009. if (source == null)
  10010. throw new ArgumentNullException("source");
  10011. return ((IQueryProvider)source.Provider).CreateQuery<TSource>(
  10012. Expression.Call(
  10013. null,
  10014. #if CRIPPLED_REFLECTION
  10015. InfoOf(() => Qbservable.Next<TSource>(default(IQbservable<TSource>))),
  10016. #else
  10017. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10018. #endif
  10019. source.Expression
  10020. )
  10021. );
  10022. }
  10023. /// <summary>
  10024. /// Wraps the source sequence in order to run its observer callbacks on the specified synchronization context.
  10025. /// </summary>
  10026. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10027. /// <param name="source">Source sequence.</param>
  10028. /// <param name="context">Synchronization context to notify observers on.</param>
  10029. /// <returns>The source sequence whose observations happen on the specified synchronization context.</returns>
  10030. /// <exception cref="T:System.ArgumentNullException">
  10031. /// <paramref name="source" /> or <paramref name="context" /> is null.</exception>
  10032. /// <remarks>
  10033. /// This only invokes observer callbacks on a synchronization context. In case the subscription and/or unsubscription actions have side-effects
  10034. /// that require to be run on a synchronization context, use <see cref="M:System.Reactive.Linq.Observable.SubscribeOn``1(System.IObservable{``0},System.Threading.SynchronizationContext)" />.
  10035. /// </remarks>
  10036. public static IQbservable<TSource> ObserveOn<TSource>(this IQbservable<TSource> source, SynchronizationContext context)
  10037. {
  10038. if (source == null)
  10039. throw new ArgumentNullException("source");
  10040. if (context == null)
  10041. throw new ArgumentNullException("context");
  10042. return source.Provider.CreateQuery<TSource>(
  10043. Expression.Call(
  10044. null,
  10045. #if CRIPPLED_REFLECTION
  10046. InfoOf(() => Qbservable.ObserveOn<TSource>(default(IQbservable<TSource>), default(SynchronizationContext))),
  10047. #else
  10048. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10049. #endif
  10050. source.Expression,
  10051. Expression.Constant(context, typeof(SynchronizationContext))
  10052. )
  10053. );
  10054. }
  10055. /// <summary>
  10056. /// Wraps the source sequence in order to run its observer callbacks on the specified scheduler.
  10057. /// </summary>
  10058. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10059. /// <param name="source">Source sequence.</param>
  10060. /// <param name="scheduler">Scheduler to notify observers on.</param>
  10061. /// <returns>The source sequence whose observations happen on the specified scheduler.</returns>
  10062. /// <exception cref="T:System.ArgumentNullException">
  10063. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  10064. /// <remarks>
  10065. /// This only invokes observer callbacks on a scheduler. In case the subscription and/or unsubscription actions have side-effects
  10066. /// that require to be run on a scheduler, use <see cref="M:System.Reactive.Linq.Observable.SubscribeOn``1(System.IObservable{``0},System.Reactive.Concurrency.IScheduler)" />.
  10067. /// </remarks>
  10068. public static IQbservable<TSource> ObserveOn<TSource>(this IQbservable<TSource> source, IScheduler scheduler)
  10069. {
  10070. if (source == null)
  10071. throw new ArgumentNullException("source");
  10072. if (scheduler == null)
  10073. throw new ArgumentNullException("scheduler");
  10074. return source.Provider.CreateQuery<TSource>(
  10075. Expression.Call(
  10076. null,
  10077. #if CRIPPLED_REFLECTION
  10078. InfoOf(() => Qbservable.ObserveOn<TSource>(default(IQbservable<TSource>), default(IScheduler))),
  10079. #else
  10080. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10081. #endif
  10082. source.Expression,
  10083. Expression.Constant(scheduler, typeof(IScheduler))
  10084. )
  10085. );
  10086. }
  10087. /// <summary>
  10088. /// Filters the elements of an observable sequence based on the specified type.
  10089. /// </summary>
  10090. /// <typeparam name="TResult">The type to filter the elements in the source sequence on.</typeparam>
  10091. /// <param name="source">The observable sequence that contains the elements to be filtered.</param>
  10092. /// <returns>An observable sequence that contains elements from the input sequence of type TResult.</returns>
  10093. /// <exception cref="T:System.ArgumentNullException">
  10094. /// <paramref name="source" /> is null.</exception>
  10095. public static IQbservable<TResult> OfType<TResult>(this IQbservable<object> source)
  10096. {
  10097. if (source == null)
  10098. throw new ArgumentNullException("source");
  10099. return source.Provider.CreateQuery<TResult>(
  10100. Expression.Call(
  10101. null,
  10102. #if CRIPPLED_REFLECTION
  10103. InfoOf(() => Qbservable.OfType<TResult>(default(IQbservable<object>))),
  10104. #else
  10105. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10106. #endif
  10107. source.Expression
  10108. )
  10109. );
  10110. }
  10111. /// <summary>
  10112. /// Concatenates the second observable sequence to the first observable sequence upon successful or exceptional termination of the first.
  10113. /// </summary>
  10114. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  10115. /// <param name="first">First observable sequence whose exception (if any) is caught.</param>
  10116. /// <param name="second">Second observable sequence used to produce results after the first sequence terminates.</param>
  10117. /// <returns>An observable sequence that concatenates the first and second sequence, even if the first sequence terminates exceptionally.</returns>
  10118. /// <exception cref="T:System.ArgumentNullException">
  10119. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  10120. public static IQbservable<TSource> OnErrorResumeNext<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  10121. {
  10122. if (first == null)
  10123. throw new ArgumentNullException("first");
  10124. if (second == null)
  10125. throw new ArgumentNullException("second");
  10126. return first.Provider.CreateQuery<TSource>(
  10127. Expression.Call(
  10128. null,
  10129. #if CRIPPLED_REFLECTION
  10130. InfoOf(() => Qbservable.OnErrorResumeNext<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  10131. #else
  10132. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10133. #endif
  10134. first.Expression,
  10135. GetSourceExpression(second)
  10136. )
  10137. );
  10138. }
  10139. /// <summary>
  10140. /// Concatenates all of the specified observable sequences, even if the previous observable sequence terminated exceptionally.
  10141. /// </summary>
  10142. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10143. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  10144. /// <param name="sources">Observable sequences to concatenate.</param>
  10145. /// <returns>An observable sequence that concatenates the source sequences, even if a sequence terminates exceptionally.</returns>
  10146. /// <exception cref="T:System.ArgumentNullException">
  10147. /// <paramref name="sources" /> is null.</exception>
  10148. public static IQbservable<TSource> OnErrorResumeNext<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  10149. {
  10150. if (provider == null)
  10151. throw new ArgumentNullException("provider");
  10152. if (sources == null)
  10153. throw new ArgumentNullException("sources");
  10154. return provider.CreateQuery<TSource>(
  10155. Expression.Call(
  10156. null,
  10157. #if CRIPPLED_REFLECTION
  10158. InfoOf(() => Qbservable.OnErrorResumeNext<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  10159. #else
  10160. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10161. #endif
  10162. Expression.Constant(provider, typeof(IQbservableProvider)),
  10163. GetSourceExpression(sources)
  10164. )
  10165. );
  10166. }
  10167. /// <summary>
  10168. /// Concatenates all observable sequences in the given enumerable sequence, even if the previous observable sequence terminated exceptionally.
  10169. /// </summary>
  10170. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10171. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  10172. /// <param name="sources">Observable sequences to concatenate.</param>
  10173. /// <returns>An observable sequence that concatenates the source sequences, even if a sequence terminates exceptionally.</returns>
  10174. /// <exception cref="T:System.ArgumentNullException">
  10175. /// <paramref name="sources" /> is null.</exception>
  10176. public static IQbservable<TSource> OnErrorResumeNext<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  10177. {
  10178. if (provider == null)
  10179. throw new ArgumentNullException("provider");
  10180. if (sources == null)
  10181. throw new ArgumentNullException("sources");
  10182. return provider.CreateQuery<TSource>(
  10183. Expression.Call(
  10184. null,
  10185. #if CRIPPLED_REFLECTION
  10186. InfoOf(() => Qbservable.OnErrorResumeNext<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  10187. #else
  10188. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10189. #endif
  10190. Expression.Constant(provider, typeof(IQbservableProvider)),
  10191. GetSourceExpression(sources)
  10192. )
  10193. );
  10194. }
  10195. /// <summary>
  10196. /// 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.
  10197. /// This operator is a specialization of Multicast using a regular <see cref="T:System.Reactive.Subjects.Subject`1" />.
  10198. /// </summary>
  10199. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10200. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10201. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10202. /// <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>
  10203. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10204. /// <exception cref="T:System.ArgumentNullException">
  10205. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10206. /// <seealso cref="T:System.Reactive.Subjects.Subject`1" />
  10207. public static IQbservable<TResult> Publish<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector)
  10208. {
  10209. if (source == null)
  10210. throw new ArgumentNullException("source");
  10211. if (selector == null)
  10212. throw new ArgumentNullException("selector");
  10213. return source.Provider.CreateQuery<TResult>(
  10214. Expression.Call(
  10215. null,
  10216. #if CRIPPLED_REFLECTION
  10217. InfoOf(() => Qbservable.Publish<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>))),
  10218. #else
  10219. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10220. #endif
  10221. source.Expression,
  10222. selector
  10223. )
  10224. );
  10225. }
  10226. /// <summary>
  10227. /// 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.
  10228. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.BehaviorSubject`1" />.
  10229. /// </summary>
  10230. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10231. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10232. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10233. /// <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>
  10234. /// <param name="initialValue">Initial value received by observers upon subscription.</param>
  10235. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10236. /// <exception cref="T:System.ArgumentNullException">
  10237. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10238. /// <seealso cref="T:System.Reactive.Subjects.BehaviorSubject`1" />
  10239. public static IQbservable<TResult> Publish<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, TSource initialValue)
  10240. {
  10241. if (source == null)
  10242. throw new ArgumentNullException("source");
  10243. if (selector == null)
  10244. throw new ArgumentNullException("selector");
  10245. return source.Provider.CreateQuery<TResult>(
  10246. Expression.Call(
  10247. null,
  10248. #if CRIPPLED_REFLECTION
  10249. InfoOf(() => Qbservable.Publish<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(TSource))),
  10250. #else
  10251. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10252. #endif
  10253. source.Expression,
  10254. selector,
  10255. Expression.Constant(initialValue, typeof(TSource))
  10256. )
  10257. );
  10258. }
  10259. /// <summary>
  10260. /// 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.
  10261. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.AsyncSubject`1" />.
  10262. /// </summary>
  10263. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10264. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10265. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10266. /// <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>
  10267. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10268. /// <exception cref="T:System.ArgumentNullException">
  10269. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10270. /// <seealso cref="T:System.Reactive.Subjects.AsyncSubject`1" />
  10271. public static IQbservable<TResult> PublishLast<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector)
  10272. {
  10273. if (source == null)
  10274. throw new ArgumentNullException("source");
  10275. if (selector == null)
  10276. throw new ArgumentNullException("selector");
  10277. return source.Provider.CreateQuery<TResult>(
  10278. Expression.Call(
  10279. null,
  10280. #if CRIPPLED_REFLECTION
  10281. InfoOf(() => Qbservable.PublishLast<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>))),
  10282. #else
  10283. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10284. #endif
  10285. source.Expression,
  10286. selector
  10287. )
  10288. );
  10289. }
  10290. /// <summary>
  10291. /// Generates an observable sequence of integral numbers within a specified range.
  10292. /// </summary>
  10293. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10294. /// <param name="start">The value of the first integer in the sequence.</param>
  10295. /// <param name="count">The number of sequential integers to generate.</param>
  10296. /// <returns>An observable sequence that contains a range of sequential integral numbers.</returns>
  10297. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10298. /// <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>
  10299. public static IQbservable<int> Range(this IQbservableProvider provider, int start, int count)
  10300. {
  10301. if (provider == null)
  10302. throw new ArgumentNullException("provider");
  10303. return provider.CreateQuery<int>(
  10304. Expression.Call(
  10305. null,
  10306. #if CRIPPLED_REFLECTION
  10307. InfoOf(() => Qbservable.Range(default(IQbservableProvider), default(int), default(int))),
  10308. #else
  10309. (MethodInfo)MethodInfo.GetCurrentMethod(),
  10310. #endif
  10311. Expression.Constant(provider, typeof(IQbservableProvider)),
  10312. Expression.Constant(start, typeof(int)),
  10313. Expression.Constant(count, typeof(int))
  10314. )
  10315. );
  10316. }
  10317. /// <summary>
  10318. /// Generates an observable sequence of integral numbers within a specified range, using the specified scheduler to send out observer messages.
  10319. /// </summary>
  10320. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10321. /// <param name="start">The value of the first integer in the sequence.</param>
  10322. /// <param name="count">The number of sequential integers to generate.</param>
  10323. /// <param name="scheduler">Scheduler to run the generator loop on.</param>
  10324. /// <returns>An observable sequence that contains a range of sequential integral numbers.</returns>
  10325. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10326. /// <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>
  10327. /// <exception cref="T:System.ArgumentNullException">
  10328. /// <paramref name="scheduler" /> is null.</exception>
  10329. public static IQbservable<int> Range(this IQbservableProvider provider, int start, int count, IScheduler scheduler)
  10330. {
  10331. if (provider == null)
  10332. throw new ArgumentNullException("provider");
  10333. if (scheduler == null)
  10334. throw new ArgumentNullException("scheduler");
  10335. return provider.CreateQuery<int>(
  10336. Expression.Call(
  10337. null,
  10338. #if CRIPPLED_REFLECTION
  10339. InfoOf(() => Qbservable.Range(default(IQbservableProvider), default(int), default(int), default(IScheduler))),
  10340. #else
  10341. (MethodInfo)MethodInfo.GetCurrentMethod(),
  10342. #endif
  10343. Expression.Constant(provider, typeof(IQbservableProvider)),
  10344. Expression.Constant(start, typeof(int)),
  10345. Expression.Constant(count, typeof(int)),
  10346. Expression.Constant(scheduler, typeof(IScheduler))
  10347. )
  10348. );
  10349. }
  10350. /// <summary>
  10351. /// Returns an observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence.
  10352. /// </summary>
  10353. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10354. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10355. /// <param name="source">Connectable observable sequence.</param>
  10356. /// <returns>An observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence.</returns>
  10357. /// <exception cref="T:System.ArgumentNullException">
  10358. /// <paramref name="source" /> is null.</exception>
  10359. public static IQbservable<TSource> RefCount<TSource>(this IQbservableProvider provider, IConnectableObservable<TSource> source)
  10360. {
  10361. if (provider == null)
  10362. throw new ArgumentNullException("provider");
  10363. if (source == null)
  10364. throw new ArgumentNullException("source");
  10365. return provider.CreateQuery<TSource>(
  10366. Expression.Call(
  10367. null,
  10368. #if CRIPPLED_REFLECTION
  10369. InfoOf(() => Qbservable.RefCount<TSource>(default(IQbservableProvider), default(IConnectableObservable<TSource>))),
  10370. #else
  10371. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10372. #endif
  10373. Expression.Constant(provider, typeof(IQbservableProvider)),
  10374. Expression.Constant(source, typeof(IConnectableObservable<TSource>))
  10375. )
  10376. );
  10377. }
  10378. /// <summary>
  10379. /// Generates an observable sequence that repeats the given element infinitely.
  10380. /// </summary>
  10381. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10382. /// <typeparam name="TResult">The type of the element that will be repeated in the produced sequence.</typeparam>
  10383. /// <param name="value">Element to repeat.</param>
  10384. /// <returns>An observable sequence that repeats the given element infinitely.</returns>
  10385. public static IQbservable<TResult> Repeat<TResult>(this IQbservableProvider provider, TResult value)
  10386. {
  10387. if (provider == null)
  10388. throw new ArgumentNullException("provider");
  10389. return provider.CreateQuery<TResult>(
  10390. Expression.Call(
  10391. null,
  10392. #if CRIPPLED_REFLECTION
  10393. InfoOf(() => Qbservable.Repeat<TResult>(default(IQbservableProvider), default(TResult))),
  10394. #else
  10395. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10396. #endif
  10397. Expression.Constant(provider, typeof(IQbservableProvider)),
  10398. Expression.Constant(value, typeof(TResult))
  10399. )
  10400. );
  10401. }
  10402. /// <summary>
  10403. /// Generates an observable sequence that repeats the given element the specified number of times.
  10404. /// </summary>
  10405. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10406. /// <typeparam name="TResult">The type of the element that will be repeated in the produced sequence.</typeparam>
  10407. /// <param name="value">Element to repeat.</param>
  10408. /// <param name="repeatCount">Number of times to repeat the element.</param>
  10409. /// <returns>An observable sequence that repeats the given element the specified number of times.</returns>
  10410. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10411. /// <paramref name="repeatCount" /> is less than zero.</exception>
  10412. public static IQbservable<TResult> Repeat<TResult>(this IQbservableProvider provider, TResult value, int repeatCount)
  10413. {
  10414. if (provider == null)
  10415. throw new ArgumentNullException("provider");
  10416. return provider.CreateQuery<TResult>(
  10417. Expression.Call(
  10418. null,
  10419. #if CRIPPLED_REFLECTION
  10420. InfoOf(() => Qbservable.Repeat<TResult>(default(IQbservableProvider), default(TResult), default(int))),
  10421. #else
  10422. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10423. #endif
  10424. Expression.Constant(provider, typeof(IQbservableProvider)),
  10425. Expression.Constant(value, typeof(TResult)),
  10426. Expression.Constant(repeatCount, typeof(int))
  10427. )
  10428. );
  10429. }
  10430. /// <summary>
  10431. /// Generates an observable sequence that repeats the given element the specified number of times, using the specified scheduler to send out observer messages.
  10432. /// </summary>
  10433. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10434. /// <typeparam name="TResult">The type of the element that will be repeated in the produced sequence.</typeparam>
  10435. /// <param name="value">Element to repeat.</param>
  10436. /// <param name="repeatCount">Number of times to repeat the element.</param>
  10437. /// <param name="scheduler">Scheduler to run the producer loop on.</param>
  10438. /// <returns>An observable sequence that repeats the given element the specified number of times.</returns>
  10439. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10440. /// <paramref name="repeatCount" /> is less than zero.</exception>
  10441. /// <exception cref="T:System.ArgumentNullException">
  10442. /// <paramref name="scheduler" /> is null.</exception>
  10443. public static IQbservable<TResult> Repeat<TResult>(this IQbservableProvider provider, TResult value, int repeatCount, IScheduler scheduler)
  10444. {
  10445. if (provider == null)
  10446. throw new ArgumentNullException("provider");
  10447. if (scheduler == null)
  10448. throw new ArgumentNullException("scheduler");
  10449. return provider.CreateQuery<TResult>(
  10450. Expression.Call(
  10451. null,
  10452. #if CRIPPLED_REFLECTION
  10453. InfoOf(() => Qbservable.Repeat<TResult>(default(IQbservableProvider), default(TResult), default(int), default(IScheduler))),
  10454. #else
  10455. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10456. #endif
  10457. Expression.Constant(provider, typeof(IQbservableProvider)),
  10458. Expression.Constant(value, typeof(TResult)),
  10459. Expression.Constant(repeatCount, typeof(int)),
  10460. Expression.Constant(scheduler, typeof(IScheduler))
  10461. )
  10462. );
  10463. }
  10464. /// <summary>
  10465. /// Generates an observable sequence that repeats the given element infinitely, using the specified scheduler to send out observer messages.
  10466. /// </summary>
  10467. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10468. /// <typeparam name="TResult">The type of the element that will be repeated in the produced sequence.</typeparam>
  10469. /// <param name="value">Element to repeat.</param>
  10470. /// <param name="scheduler">Scheduler to run the producer loop on.</param>
  10471. /// <returns>An observable sequence that repeats the given element infinitely.</returns>
  10472. /// <exception cref="T:System.ArgumentNullException">
  10473. /// <paramref name="scheduler" /> is null.</exception>
  10474. public static IQbservable<TResult> Repeat<TResult>(this IQbservableProvider provider, TResult value, IScheduler scheduler)
  10475. {
  10476. if (provider == null)
  10477. throw new ArgumentNullException("provider");
  10478. if (scheduler == null)
  10479. throw new ArgumentNullException("scheduler");
  10480. return provider.CreateQuery<TResult>(
  10481. Expression.Call(
  10482. null,
  10483. #if CRIPPLED_REFLECTION
  10484. InfoOf(() => Qbservable.Repeat<TResult>(default(IQbservableProvider), default(TResult), default(IScheduler))),
  10485. #else
  10486. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10487. #endif
  10488. Expression.Constant(provider, typeof(IQbservableProvider)),
  10489. Expression.Constant(value, typeof(TResult)),
  10490. Expression.Constant(scheduler, typeof(IScheduler))
  10491. )
  10492. );
  10493. }
  10494. /// <summary>
  10495. /// Repeats the observable sequence indefinitely.
  10496. /// </summary>
  10497. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10498. /// <param name="source">Observable sequence to repeat.</param>
  10499. /// <returns>The observable sequence producing the elements of the given sequence repeatedly and sequentially.</returns>
  10500. /// <exception cref="T:System.ArgumentNullException">
  10501. /// <paramref name="source" /> is null.</exception>
  10502. public static IQbservable<TSource> Repeat<TSource>(this IQbservable<TSource> source)
  10503. {
  10504. if (source == null)
  10505. throw new ArgumentNullException("source");
  10506. return source.Provider.CreateQuery<TSource>(
  10507. Expression.Call(
  10508. null,
  10509. #if CRIPPLED_REFLECTION
  10510. InfoOf(() => Qbservable.Repeat<TSource>(default(IQbservable<TSource>))),
  10511. #else
  10512. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10513. #endif
  10514. source.Expression
  10515. )
  10516. );
  10517. }
  10518. /// <summary>
  10519. /// Repeats the observable sequence a specified number of times.
  10520. /// </summary>
  10521. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10522. /// <param name="source">Observable sequence to repeat.</param>
  10523. /// <param name="repeatCount">Number of times to repeat the sequence.</param>
  10524. /// <returns>The observable sequence producing the elements of the given sequence repeatedly.</returns>
  10525. /// <exception cref="T:System.ArgumentNullException">
  10526. /// <paramref name="source" /> is null.</exception>
  10527. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10528. /// <paramref name="repeatCount" /> is less than zero.</exception>
  10529. public static IQbservable<TSource> Repeat<TSource>(this IQbservable<TSource> source, int repeatCount)
  10530. {
  10531. if (source == null)
  10532. throw new ArgumentNullException("source");
  10533. return source.Provider.CreateQuery<TSource>(
  10534. Expression.Call(
  10535. null,
  10536. #if CRIPPLED_REFLECTION
  10537. InfoOf(() => Qbservable.Repeat<TSource>(default(IQbservable<TSource>), default(int))),
  10538. #else
  10539. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10540. #endif
  10541. source.Expression,
  10542. Expression.Constant(repeatCount, typeof(int))
  10543. )
  10544. );
  10545. }
  10546. /// <summary>
  10547. /// 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.
  10548. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10549. /// </summary>
  10550. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10551. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10552. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10553. /// <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>
  10554. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10555. /// <exception cref="T:System.ArgumentNullException">
  10556. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10557. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10558. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector)
  10559. {
  10560. if (source == null)
  10561. throw new ArgumentNullException("source");
  10562. if (selector == null)
  10563. throw new ArgumentNullException("selector");
  10564. return source.Provider.CreateQuery<TResult>(
  10565. Expression.Call(
  10566. null,
  10567. #if CRIPPLED_REFLECTION
  10568. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>))),
  10569. #else
  10570. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10571. #endif
  10572. source.Expression,
  10573. selector
  10574. )
  10575. );
  10576. }
  10577. /// <summary>
  10578. /// 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.
  10579. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10580. /// </summary>
  10581. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10582. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10583. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10584. /// <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>
  10585. /// <param name="bufferSize">Maximum element count of the replay buffer.</param>
  10586. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10587. /// <exception cref="T:System.ArgumentNullException">
  10588. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10589. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10590. /// <paramref name="bufferSize" /> is less than zero.</exception>
  10591. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10592. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, int bufferSize)
  10593. {
  10594. if (source == null)
  10595. throw new ArgumentNullException("source");
  10596. if (selector == null)
  10597. throw new ArgumentNullException("selector");
  10598. return source.Provider.CreateQuery<TResult>(
  10599. Expression.Call(
  10600. null,
  10601. #if CRIPPLED_REFLECTION
  10602. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(int))),
  10603. #else
  10604. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10605. #endif
  10606. source.Expression,
  10607. selector,
  10608. Expression.Constant(bufferSize, typeof(int))
  10609. )
  10610. );
  10611. }
  10612. /// <summary>
  10613. /// 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.
  10614. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10615. /// </summary>
  10616. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10617. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10618. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10619. /// <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>
  10620. /// <param name="bufferSize">Maximum element count of the replay buffer.</param>
  10621. /// <param name="scheduler">Scheduler where connected observers within the selector function will be invoked on.</param>
  10622. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10623. /// <exception cref="T:System.ArgumentNullException">
  10624. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="scheduler" /> is null.</exception>
  10625. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10626. /// <paramref name="bufferSize" /> is less than zero.</exception>
  10627. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10628. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, int bufferSize, IScheduler scheduler)
  10629. {
  10630. if (source == null)
  10631. throw new ArgumentNullException("source");
  10632. if (selector == null)
  10633. throw new ArgumentNullException("selector");
  10634. if (scheduler == null)
  10635. throw new ArgumentNullException("scheduler");
  10636. return source.Provider.CreateQuery<TResult>(
  10637. Expression.Call(
  10638. null,
  10639. #if CRIPPLED_REFLECTION
  10640. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(int), default(IScheduler))),
  10641. #else
  10642. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10643. #endif
  10644. source.Expression,
  10645. selector,
  10646. Expression.Constant(bufferSize, typeof(int)),
  10647. Expression.Constant(scheduler, typeof(IScheduler))
  10648. )
  10649. );
  10650. }
  10651. /// <summary>
  10652. /// 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.
  10653. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10654. /// </summary>
  10655. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10656. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10657. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10658. /// <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>
  10659. /// <param name="bufferSize">Maximum element count of the replay buffer.</param>
  10660. /// <param name="window">Maximum time length of the replay buffer.</param>
  10661. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10662. /// <exception cref="T:System.ArgumentNullException">
  10663. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10664. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10665. /// <paramref name="bufferSize" /> is less than zero.</exception>
  10666. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10667. /// <paramref name="window" /> is less than TimeSpan.Zero.</exception>
  10668. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10669. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, int bufferSize, TimeSpan window)
  10670. {
  10671. if (source == null)
  10672. throw new ArgumentNullException("source");
  10673. if (selector == null)
  10674. throw new ArgumentNullException("selector");
  10675. return source.Provider.CreateQuery<TResult>(
  10676. Expression.Call(
  10677. null,
  10678. #if CRIPPLED_REFLECTION
  10679. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(int), default(TimeSpan))),
  10680. #else
  10681. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10682. #endif
  10683. source.Expression,
  10684. selector,
  10685. Expression.Constant(bufferSize, typeof(int)),
  10686. Expression.Constant(window, typeof(TimeSpan))
  10687. )
  10688. );
  10689. }
  10690. /// <summary>
  10691. /// 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.
  10692. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10693. /// </summary>
  10694. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10695. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10696. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10697. /// <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>
  10698. /// <param name="bufferSize">Maximum element count of the replay buffer.</param>
  10699. /// <param name="window">Maximum time length of the replay buffer.</param>
  10700. /// <param name="scheduler">Scheduler where connected observers within the selector function will be invoked on.</param>
  10701. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10702. /// <exception cref="T:System.ArgumentNullException">
  10703. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="scheduler" /> is null.</exception>
  10704. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10705. /// <paramref name="bufferSize" /> is less than zero.</exception>
  10706. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10707. /// <paramref name="window" /> is less than TimeSpan.Zero.</exception>
  10708. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10709. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, int bufferSize, TimeSpan window, IScheduler scheduler)
  10710. {
  10711. if (source == null)
  10712. throw new ArgumentNullException("source");
  10713. if (selector == null)
  10714. throw new ArgumentNullException("selector");
  10715. if (scheduler == null)
  10716. throw new ArgumentNullException("scheduler");
  10717. return source.Provider.CreateQuery<TResult>(
  10718. Expression.Call(
  10719. null,
  10720. #if CRIPPLED_REFLECTION
  10721. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(int), default(TimeSpan), default(IScheduler))),
  10722. #else
  10723. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10724. #endif
  10725. source.Expression,
  10726. selector,
  10727. Expression.Constant(bufferSize, typeof(int)),
  10728. Expression.Constant(window, typeof(TimeSpan)),
  10729. Expression.Constant(scheduler, typeof(IScheduler))
  10730. )
  10731. );
  10732. }
  10733. /// <summary>
  10734. /// 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.
  10735. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10736. /// </summary>
  10737. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10738. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10739. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10740. /// <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>
  10741. /// <param name="scheduler">Scheduler where connected observers within the selector function will be invoked on.</param>
  10742. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10743. /// <exception cref="T:System.ArgumentNullException">
  10744. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="scheduler" /> is null.</exception>
  10745. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10746. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, IScheduler scheduler)
  10747. {
  10748. if (source == null)
  10749. throw new ArgumentNullException("source");
  10750. if (selector == null)
  10751. throw new ArgumentNullException("selector");
  10752. if (scheduler == null)
  10753. throw new ArgumentNullException("scheduler");
  10754. return source.Provider.CreateQuery<TResult>(
  10755. Expression.Call(
  10756. null,
  10757. #if CRIPPLED_REFLECTION
  10758. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(IScheduler))),
  10759. #else
  10760. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10761. #endif
  10762. source.Expression,
  10763. selector,
  10764. Expression.Constant(scheduler, typeof(IScheduler))
  10765. )
  10766. );
  10767. }
  10768. /// <summary>
  10769. /// 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.
  10770. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10771. /// </summary>
  10772. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10773. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10774. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10775. /// <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>
  10776. /// <param name="window">Maximum time length of the replay buffer.</param>
  10777. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10778. /// <exception cref="T:System.ArgumentNullException">
  10779. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10780. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10781. /// <paramref name="window" /> is less than TimeSpan.Zero.</exception>
  10782. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10783. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, TimeSpan window)
  10784. {
  10785. if (source == null)
  10786. throw new ArgumentNullException("source");
  10787. if (selector == null)
  10788. throw new ArgumentNullException("selector");
  10789. return source.Provider.CreateQuery<TResult>(
  10790. Expression.Call(
  10791. null,
  10792. #if CRIPPLED_REFLECTION
  10793. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(TimeSpan))),
  10794. #else
  10795. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10796. #endif
  10797. source.Expression,
  10798. selector,
  10799. Expression.Constant(window, typeof(TimeSpan))
  10800. )
  10801. );
  10802. }
  10803. /// <summary>
  10804. /// 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.
  10805. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10806. /// </summary>
  10807. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10808. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10809. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10810. /// <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>
  10811. /// <param name="window">Maximum time length of the replay buffer.</param>
  10812. /// <param name="scheduler">Scheduler where connected observers within the selector function will be invoked on.</param>
  10813. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10814. /// <exception cref="T:System.ArgumentNullException">
  10815. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="scheduler" /> is null.</exception>
  10816. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10817. /// <paramref name="window" /> is less than TimeSpan.Zero.</exception>
  10818. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10819. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, TimeSpan window, IScheduler scheduler)
  10820. {
  10821. if (source == null)
  10822. throw new ArgumentNullException("source");
  10823. if (selector == null)
  10824. throw new ArgumentNullException("selector");
  10825. if (scheduler == null)
  10826. throw new ArgumentNullException("scheduler");
  10827. return source.Provider.CreateQuery<TResult>(
  10828. Expression.Call(
  10829. null,
  10830. #if CRIPPLED_REFLECTION
  10831. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(TimeSpan), default(IScheduler))),
  10832. #else
  10833. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10834. #endif
  10835. source.Expression,
  10836. selector,
  10837. Expression.Constant(window, typeof(TimeSpan)),
  10838. Expression.Constant(scheduler, typeof(IScheduler))
  10839. )
  10840. );
  10841. }
  10842. /// <summary>
  10843. /// Repeats the source observable sequence until it successfully terminates.
  10844. /// </summary>
  10845. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10846. /// <param name="source">Observable sequence to repeat until it successfully terminates.</param>
  10847. /// <returns>An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.</returns>
  10848. /// <exception cref="T:System.ArgumentNullException">
  10849. /// <paramref name="source" /> is null.</exception>
  10850. public static IQbservable<TSource> Retry<TSource>(this IQbservable<TSource> source)
  10851. {
  10852. if (source == null)
  10853. throw new ArgumentNullException("source");
  10854. return source.Provider.CreateQuery<TSource>(
  10855. Expression.Call(
  10856. null,
  10857. #if CRIPPLED_REFLECTION
  10858. InfoOf(() => Qbservable.Retry<TSource>(default(IQbservable<TSource>))),
  10859. #else
  10860. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10861. #endif
  10862. source.Expression
  10863. )
  10864. );
  10865. }
  10866. /// <summary>
  10867. /// Repeats the source observable sequence the specified number of times or until it successfully terminates.
  10868. /// </summary>
  10869. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10870. /// <param name="source">Observable sequence to repeat until it successfully terminates.</param>
  10871. /// <param name="retryCount">Number of times to repeat the sequence.</param>
  10872. /// <returns>An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.</returns>
  10873. /// <exception cref="T:System.ArgumentNullException">
  10874. /// <paramref name="source" /> is null.</exception>
  10875. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10876. /// <paramref name="retryCount" /> is less than zero.</exception>
  10877. public static IQbservable<TSource> Retry<TSource>(this IQbservable<TSource> source, int retryCount)
  10878. {
  10879. if (source == null)
  10880. throw new ArgumentNullException("source");
  10881. return source.Provider.CreateQuery<TSource>(
  10882. Expression.Call(
  10883. null,
  10884. #if CRIPPLED_REFLECTION
  10885. InfoOf(() => Qbservable.Retry<TSource>(default(IQbservable<TSource>), default(int))),
  10886. #else
  10887. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10888. #endif
  10889. source.Expression,
  10890. Expression.Constant(retryCount, typeof(int))
  10891. )
  10892. );
  10893. }
  10894. /// <summary>
  10895. /// Returns an observable sequence that contains a single element.
  10896. /// </summary>
  10897. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10898. /// <typeparam name="TResult">The type of the element that will be returned in the produced sequence.</typeparam>
  10899. /// <param name="value">Single element in the resulting observable sequence.</param>
  10900. /// <returns>An observable sequence containing the single specified element.</returns>
  10901. public static IQbservable<TResult> Return<TResult>(this IQbservableProvider provider, TResult value)
  10902. {
  10903. if (provider == null)
  10904. throw new ArgumentNullException("provider");
  10905. return provider.CreateQuery<TResult>(
  10906. Expression.Call(
  10907. null,
  10908. #if CRIPPLED_REFLECTION
  10909. InfoOf(() => Qbservable.Return<TResult>(default(IQbservableProvider), default(TResult))),
  10910. #else
  10911. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10912. #endif
  10913. Expression.Constant(provider, typeof(IQbservableProvider)),
  10914. Expression.Constant(value, typeof(TResult))
  10915. )
  10916. );
  10917. }
  10918. /// <summary>
  10919. /// Returns an observable sequence that contains a single element, using the specified scheduler to send out observer messages.
  10920. /// </summary>
  10921. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  10922. /// <typeparam name="TResult">The type of the element that will be returned in the produced sequence.</typeparam>
  10923. /// <param name="value">Single element in the resulting observable sequence.</param>
  10924. /// <param name="scheduler">Scheduler to send the single element on.</param>
  10925. /// <returns>An observable sequence containing the single specified element.</returns>
  10926. /// <exception cref="T:System.ArgumentNullException">
  10927. /// <paramref name="scheduler" /> is null.</exception>
  10928. public static IQbservable<TResult> Return<TResult>(this IQbservableProvider provider, TResult value, IScheduler scheduler)
  10929. {
  10930. if (provider == null)
  10931. throw new ArgumentNullException("provider");
  10932. if (scheduler == null)
  10933. throw new ArgumentNullException("scheduler");
  10934. return provider.CreateQuery<TResult>(
  10935. Expression.Call(
  10936. null,
  10937. #if CRIPPLED_REFLECTION
  10938. InfoOf(() => Qbservable.Return<TResult>(default(IQbservableProvider), default(TResult), default(IScheduler))),
  10939. #else
  10940. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10941. #endif
  10942. Expression.Constant(provider, typeof(IQbservableProvider)),
  10943. Expression.Constant(value, typeof(TResult)),
  10944. Expression.Constant(scheduler, typeof(IScheduler))
  10945. )
  10946. );
  10947. }
  10948. /// <summary>
  10949. /// Samples the observable sequence at each interval.
  10950. /// Upon each sampling tick, the latest element (if any) in the source sequence during the last sampling interval is sent to the resulting sequence.
  10951. /// </summary>
  10952. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10953. /// <param name="source">Source sequence to sample.</param>
  10954. /// <param name="interval">Interval at which to sample. If this value is equal to TimeSpan.Zero, the scheduler will continuously sample the stream.</param>
  10955. /// <returns>Sampled observable sequence.</returns>
  10956. /// <exception cref="T:System.ArgumentNullException">
  10957. /// <paramref name="source" /> is null.</exception>
  10958. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10959. /// <paramref name="interval" /> is less than TimeSpan.Zero.</exception>
  10960. /// <remarks>
  10961. /// Specifying a TimeSpan.Zero value for <paramref name="interval" /> doesn't guarantee all source sequence elements will be preserved. This is a side-effect
  10962. /// of the asynchrony introduced by the scheduler, where the sampling action may not execute immediately, despite the TimeSpan.Zero due time.
  10963. /// </remarks>
  10964. public static IQbservable<TSource> Sample<TSource>(this IQbservable<TSource> source, TimeSpan interval)
  10965. {
  10966. if (source == null)
  10967. throw new ArgumentNullException("source");
  10968. return source.Provider.CreateQuery<TSource>(
  10969. Expression.Call(
  10970. null,
  10971. #if CRIPPLED_REFLECTION
  10972. InfoOf(() => Qbservable.Sample<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  10973. #else
  10974. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10975. #endif
  10976. source.Expression,
  10977. Expression.Constant(interval, typeof(TimeSpan))
  10978. )
  10979. );
  10980. }
  10981. /// <summary>
  10982. /// Samples the observable sequence at each interval, using the specified scheduler to run sampling timers.
  10983. /// Upon each sampling tick, the latest element (if any) in the source sequence during the last sampling interval is sent to the resulting sequence.
  10984. /// </summary>
  10985. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10986. /// <param name="source">Source sequence to sample.</param>
  10987. /// <param name="interval">Interval at which to sample. If this value is equal to TimeSpan.Zero, the scheduler will continuously sample the stream.</param>
  10988. /// <param name="scheduler">Scheduler to run the sampling timer on.</param>
  10989. /// <returns>Sampled observable sequence.</returns>
  10990. /// <exception cref="T:System.ArgumentNullException">
  10991. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  10992. /// <exception cref="T:System.ArgumentOutOfRangeException">
  10993. /// <paramref name="interval" /> is less than TimeSpan.Zero.</exception>
  10994. /// <remarks>
  10995. /// Specifying a TimeSpan.Zero value for <paramref name="interval" /> doesn't guarantee all source sequence elements will be preserved. This is a side-effect
  10996. /// of the asynchrony introduced by the scheduler, where the sampling action may not execute immediately, despite the TimeSpan.Zero due time.
  10997. /// </remarks>
  10998. public static IQbservable<TSource> Sample<TSource>(this IQbservable<TSource> source, TimeSpan interval, IScheduler scheduler)
  10999. {
  11000. if (source == null)
  11001. throw new ArgumentNullException("source");
  11002. if (scheduler == null)
  11003. throw new ArgumentNullException("scheduler");
  11004. return source.Provider.CreateQuery<TSource>(
  11005. Expression.Call(
  11006. null,
  11007. #if CRIPPLED_REFLECTION
  11008. InfoOf(() => Qbservable.Sample<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  11009. #else
  11010. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11011. #endif
  11012. source.Expression,
  11013. Expression.Constant(interval, typeof(TimeSpan)),
  11014. Expression.Constant(scheduler, typeof(IScheduler))
  11015. )
  11016. );
  11017. }
  11018. /// <summary>
  11019. /// Samples the source observable sequence using a samper observable sequence producing sampling ticks.
  11020. /// Upon each sampling tick, the latest element (if any) in the source sequence during the last sampling interval is sent to the resulting sequence.
  11021. /// </summary>
  11022. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11023. /// <typeparam name="TSample">The type of the elements in the sampling sequence.</typeparam>
  11024. /// <param name="source">Source sequence to sample.</param>
  11025. /// <param name="sampler">Sampling tick sequence.</param>
  11026. /// <returns>Sampled observable sequence.</returns>
  11027. /// <exception cref="T:System.ArgumentNullException">
  11028. /// <paramref name="source" /> or <paramref name="sampler" /> is null.</exception>
  11029. public static IQbservable<TSource> Sample<TSource, TSample>(this IQbservable<TSource> source, IObservable<TSample> sampler)
  11030. {
  11031. if (source == null)
  11032. throw new ArgumentNullException("source");
  11033. if (sampler == null)
  11034. throw new ArgumentNullException("sampler");
  11035. return source.Provider.CreateQuery<TSource>(
  11036. Expression.Call(
  11037. null,
  11038. #if CRIPPLED_REFLECTION
  11039. InfoOf(() => Qbservable.Sample<TSource, TSample>(default(IQbservable<TSource>), default(IObservable<TSample>))),
  11040. #else
  11041. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TSample)),
  11042. #endif
  11043. source.Expression,
  11044. GetSourceExpression(sampler)
  11045. )
  11046. );
  11047. }
  11048. /// <summary>
  11049. /// Applies an accumulator function over an observable sequence and returns each intermediate result.
  11050. /// 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})" />.
  11051. /// </summary>
  11052. /// <typeparam name="TSource">The type of the elements in the source sequence and the result of the aggregation.</typeparam>
  11053. /// <param name="source">An observable sequence to accumulate over.</param>
  11054. /// <param name="accumulator">An accumulator function to be invoked on each element.</param>
  11055. /// <returns>An observable sequence containing the accumulated values.</returns>
  11056. /// <exception cref="T:System.ArgumentNullException">
  11057. /// <paramref name="source" /> or <paramref name="accumulator" /> is null.</exception>
  11058. public static IQbservable<TSource> Scan<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, TSource, TSource>> accumulator)
  11059. {
  11060. if (source == null)
  11061. throw new ArgumentNullException("source");
  11062. if (accumulator == null)
  11063. throw new ArgumentNullException("accumulator");
  11064. return source.Provider.CreateQuery<TSource>(
  11065. Expression.Call(
  11066. null,
  11067. #if CRIPPLED_REFLECTION
  11068. InfoOf(() => Qbservable.Scan<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, TSource, TSource>>))),
  11069. #else
  11070. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11071. #endif
  11072. source.Expression,
  11073. accumulator
  11074. )
  11075. );
  11076. }
  11077. /// <summary>
  11078. /// Applies an accumulator function over an observable sequence and returns each intermediate result. The specified seed value is used as the initial accumulator value.
  11079. /// 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})" />.
  11080. /// </summary>
  11081. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11082. /// <typeparam name="TAccumulate">The type of the result of the aggregation.</typeparam>
  11083. /// <param name="source">An observable sequence to accumulate over.</param>
  11084. /// <param name="seed">The initial accumulator value.</param>
  11085. /// <param name="accumulator">An accumulator function to be invoked on each element.</param>
  11086. /// <returns>An observable sequence containing the accumulated values.</returns>
  11087. /// <exception cref="T:System.ArgumentNullException">
  11088. /// <paramref name="source" /> or <paramref name="accumulator" /> is null.</exception>
  11089. public static IQbservable<TAccumulate> Scan<TSource, TAccumulate>(this IQbservable<TSource> source, TAccumulate seed, Expression<Func<TAccumulate, TSource, TAccumulate>> accumulator)
  11090. {
  11091. if (source == null)
  11092. throw new ArgumentNullException("source");
  11093. if (accumulator == null)
  11094. throw new ArgumentNullException("accumulator");
  11095. return source.Provider.CreateQuery<TAccumulate>(
  11096. Expression.Call(
  11097. null,
  11098. #if CRIPPLED_REFLECTION
  11099. InfoOf(() => Qbservable.Scan<TSource, TAccumulate>(default(IQbservable<TSource>), default(TAccumulate), default(Expression<Func<TAccumulate, TSource, TAccumulate>>))),
  11100. #else
  11101. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)),
  11102. #endif
  11103. source.Expression,
  11104. Expression.Constant(seed, typeof(TAccumulate)),
  11105. accumulator
  11106. )
  11107. );
  11108. }
  11109. /// <summary>
  11110. /// Projects each element of an observable sequence into a new form.
  11111. /// </summary>
  11112. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11113. /// <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>
  11114. /// <param name="source">A sequence of elements to invoke a transform function on.</param>
  11115. /// <param name="selector">A transform function to apply to each source element.</param>
  11116. /// <returns>An observable sequence whose elements are the result of invoking the transform function on each element of source.</returns>
  11117. /// <exception cref="T:System.ArgumentNullException">
  11118. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11119. public static IQbservable<TResult> Select<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector)
  11120. {
  11121. if (source == null)
  11122. throw new ArgumentNullException("source");
  11123. if (selector == null)
  11124. throw new ArgumentNullException("selector");
  11125. return source.Provider.CreateQuery<TResult>(
  11126. Expression.Call(
  11127. null,
  11128. #if CRIPPLED_REFLECTION
  11129. InfoOf(() => Qbservable.Select<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>))),
  11130. #else
  11131. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11132. #endif
  11133. source.Expression,
  11134. selector
  11135. )
  11136. );
  11137. }
  11138. /// <summary>
  11139. /// Projects each element of an observable sequence into a new form by incorporating the element's index.
  11140. /// </summary>
  11141. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11142. /// <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>
  11143. /// <param name="source">A sequence of elements to invoke a transform function on.</param>
  11144. /// <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>
  11145. /// <returns>An observable sequence whose elements are the result of invoking the transform function on each element of source.</returns>
  11146. /// <exception cref="T:System.ArgumentNullException">
  11147. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11148. public static IQbservable<TResult> Select<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, TResult>> selector)
  11149. {
  11150. if (source == null)
  11151. throw new ArgumentNullException("source");
  11152. if (selector == null)
  11153. throw new ArgumentNullException("selector");
  11154. return source.Provider.CreateQuery<TResult>(
  11155. Expression.Call(
  11156. null,
  11157. #if CRIPPLED_REFLECTION
  11158. InfoOf(() => Qbservable.Select<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, TResult>>))),
  11159. #else
  11160. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11161. #endif
  11162. source.Expression,
  11163. selector
  11164. )
  11165. );
  11166. }
  11167. /// <summary>
  11168. /// 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.
  11169. /// </summary>
  11170. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11171. /// <typeparam name="TCollection">The type of the elements in the projected intermediate enumerable sequences.</typeparam>
  11172. /// <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>
  11173. /// <param name="source">An observable sequence of elements to project.</param>
  11174. /// <param name="collectionSelector">A transform function to apply to each element.</param>
  11175. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
  11176. /// <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>
  11177. /// <exception cref="T:System.ArgumentNullException">
  11178. /// <paramref name="source" /> or <paramref name="collectionSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11179. /// <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>
  11180. public static IQbservable<TResult> SelectMany<TSource, TCollection, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, IEnumerable<TCollection>>> collectionSelector, Expression<Func<TSource, TCollection, TResult>> resultSelector)
  11181. {
  11182. if (source == null)
  11183. throw new ArgumentNullException("source");
  11184. if (collectionSelector == null)
  11185. throw new ArgumentNullException("collectionSelector");
  11186. if (resultSelector == null)
  11187. throw new ArgumentNullException("resultSelector");
  11188. return source.Provider.CreateQuery<TResult>(
  11189. Expression.Call(
  11190. null,
  11191. #if CRIPPLED_REFLECTION
  11192. InfoOf(() => Qbservable.SelectMany<TSource, TCollection, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, IEnumerable<TCollection>>>), default(Expression<Func<TSource, TCollection, TResult>>))),
  11193. #else
  11194. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)),
  11195. #endif
  11196. source.Expression,
  11197. collectionSelector,
  11198. resultSelector
  11199. )
  11200. );
  11201. }
  11202. /// <summary>
  11203. /// 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.
  11204. /// </summary>
  11205. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11206. /// <typeparam name="TCollection">The type of the elements in the projected intermediate enumerable sequences.</typeparam>
  11207. /// <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>
  11208. /// <param name="source">An observable sequence of elements to project.</param>
  11209. /// <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>
  11210. /// <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>
  11211. /// <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>
  11212. /// <exception cref="T:System.ArgumentNullException">
  11213. /// <paramref name="source" /> or <paramref name="collectionSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11214. /// <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>
  11215. 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)
  11216. {
  11217. if (source == null)
  11218. throw new ArgumentNullException("source");
  11219. if (collectionSelector == null)
  11220. throw new ArgumentNullException("collectionSelector");
  11221. if (resultSelector == null)
  11222. throw new ArgumentNullException("resultSelector");
  11223. return source.Provider.CreateQuery<TResult>(
  11224. Expression.Call(
  11225. null,
  11226. #if CRIPPLED_REFLECTION
  11227. InfoOf(() => Qbservable.SelectMany<TSource, TCollection, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, IEnumerable<TCollection>>>), default(Expression<Func<TSource, int, TCollection, int, TResult>>))),
  11228. #else
  11229. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)),
  11230. #endif
  11231. source.Expression,
  11232. collectionSelector,
  11233. resultSelector
  11234. )
  11235. );
  11236. }
  11237. /// <summary>
  11238. /// 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.
  11239. /// </summary>
  11240. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11241. /// <typeparam name="TCollection">The type of the elements in the projected intermediate sequences.</typeparam>
  11242. /// <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>
  11243. /// <param name="source">An observable sequence of elements to project.</param>
  11244. /// <param name="collectionSelector">A transform function to apply to each element.</param>
  11245. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
  11246. /// <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>
  11247. /// <exception cref="T:System.ArgumentNullException">
  11248. /// <paramref name="source" /> or <paramref name="collectionSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11249. public static IQbservable<TResult> SelectMany<TSource, TCollection, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TCollection>>> collectionSelector, Expression<Func<TSource, TCollection, TResult>> resultSelector)
  11250. {
  11251. if (source == null)
  11252. throw new ArgumentNullException("source");
  11253. if (collectionSelector == null)
  11254. throw new ArgumentNullException("collectionSelector");
  11255. if (resultSelector == null)
  11256. throw new ArgumentNullException("resultSelector");
  11257. return source.Provider.CreateQuery<TResult>(
  11258. Expression.Call(
  11259. null,
  11260. #if CRIPPLED_REFLECTION
  11261. InfoOf(() => Qbservable.SelectMany<TSource, TCollection, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TCollection>>>), default(Expression<Func<TSource, TCollection, TResult>>))),
  11262. #else
  11263. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)),
  11264. #endif
  11265. source.Expression,
  11266. collectionSelector,
  11267. resultSelector
  11268. )
  11269. );
  11270. }
  11271. /// <summary>
  11272. /// 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.
  11273. /// </summary>
  11274. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11275. /// <typeparam name="TCollection">The type of the elements in the projected intermediate sequences.</typeparam>
  11276. /// <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>
  11277. /// <param name="source">An observable sequence of elements to project.</param>
  11278. /// <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>
  11279. /// <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>
  11280. /// <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>
  11281. /// <exception cref="T:System.ArgumentNullException">
  11282. /// <paramref name="source" /> or <paramref name="collectionSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11283. 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)
  11284. {
  11285. if (source == null)
  11286. throw new ArgumentNullException("source");
  11287. if (collectionSelector == null)
  11288. throw new ArgumentNullException("collectionSelector");
  11289. if (resultSelector == null)
  11290. throw new ArgumentNullException("resultSelector");
  11291. return source.Provider.CreateQuery<TResult>(
  11292. Expression.Call(
  11293. null,
  11294. #if CRIPPLED_REFLECTION
  11295. InfoOf(() => Qbservable.SelectMany<TSource, TCollection, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, IObservable<TCollection>>>), default(Expression<Func<TSource, int, TCollection, int, TResult>>))),
  11296. #else
  11297. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)),
  11298. #endif
  11299. source.Expression,
  11300. collectionSelector,
  11301. resultSelector
  11302. )
  11303. );
  11304. }
  11305. /// <summary>
  11306. /// Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
  11307. /// </summary>
  11308. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11309. /// <typeparam name="TOther">The type of the elements in the other sequence and the elements in the result sequence.</typeparam>
  11310. /// <param name="source">An observable sequence of elements to project.</param>
  11311. /// <param name="other">An observable sequence to project each element from the source sequence onto.</param>
  11312. /// <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>
  11313. /// <exception cref="T:System.ArgumentNullException">
  11314. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  11315. public static IQbservable<TOther> SelectMany<TSource, TOther>(this IQbservable<TSource> source, IObservable<TOther> other)
  11316. {
  11317. if (source == null)
  11318. throw new ArgumentNullException("source");
  11319. if (other == null)
  11320. throw new ArgumentNullException("other");
  11321. return source.Provider.CreateQuery<TOther>(
  11322. Expression.Call(
  11323. null,
  11324. #if CRIPPLED_REFLECTION
  11325. InfoOf(() => Qbservable.SelectMany<TSource, TOther>(default(IQbservable<TSource>), default(IObservable<TOther>))),
  11326. #else
  11327. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)),
  11328. #endif
  11329. source.Expression,
  11330. GetSourceExpression(other)
  11331. )
  11332. );
  11333. }
  11334. /// <summary>
  11335. /// Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  11336. /// </summary>
  11337. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11338. /// <typeparam name="TResult">The type of the elements in the projected inner sequences and the elements in the merged result sequence.</typeparam>
  11339. /// <param name="source">An observable sequence of notifications to project.</param>
  11340. /// <param name="onNext">A transform function to apply to each element.</param>
  11341. /// <param name="onError">A transform function to apply when an error occurs in the source sequence.</param>
  11342. /// <param name="onCompleted">A transform function to apply when the end of the source sequence is reached.</param>
  11343. /// <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>
  11344. /// <exception cref="T:System.ArgumentNullException">
  11345. /// <paramref name="source" /> or <paramref name="onNext" /> or <paramref name="onError" /> or <paramref name="onCompleted" /> is null.</exception>
  11346. 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)
  11347. {
  11348. if (source == null)
  11349. throw new ArgumentNullException("source");
  11350. if (onNext == null)
  11351. throw new ArgumentNullException("onNext");
  11352. if (onError == null)
  11353. throw new ArgumentNullException("onError");
  11354. if (onCompleted == null)
  11355. throw new ArgumentNullException("onCompleted");
  11356. return source.Provider.CreateQuery<TResult>(
  11357. Expression.Call(
  11358. null,
  11359. #if CRIPPLED_REFLECTION
  11360. 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>>>))),
  11361. #else
  11362. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11363. #endif
  11364. source.Expression,
  11365. onNext,
  11366. onError,
  11367. onCompleted
  11368. )
  11369. );
  11370. }
  11371. /// <summary>
  11372. /// 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.
  11373. /// </summary>
  11374. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11375. /// <typeparam name="TResult">The type of the elements in the projected inner sequences and the elements in the merged result sequence.</typeparam>
  11376. /// <param name="source">An observable sequence of notifications to project.</param>
  11377. /// <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>
  11378. /// <param name="onError">A transform function to apply when an error occurs in the source sequence.</param>
  11379. /// <param name="onCompleted">A transform function to apply when the end of the source sequence is reached.</param>
  11380. /// <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>
  11381. /// <exception cref="T:System.ArgumentNullException">
  11382. /// <paramref name="source" /> or <paramref name="onNext" /> or <paramref name="onError" /> or <paramref name="onCompleted" /> is null.</exception>
  11383. 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)
  11384. {
  11385. if (source == null)
  11386. throw new ArgumentNullException("source");
  11387. if (onNext == null)
  11388. throw new ArgumentNullException("onNext");
  11389. if (onError == null)
  11390. throw new ArgumentNullException("onError");
  11391. if (onCompleted == null)
  11392. throw new ArgumentNullException("onCompleted");
  11393. return source.Provider.CreateQuery<TResult>(
  11394. Expression.Call(
  11395. null,
  11396. #if CRIPPLED_REFLECTION
  11397. 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>>>))),
  11398. #else
  11399. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11400. #endif
  11401. source.Expression,
  11402. onNext,
  11403. onError,
  11404. onCompleted
  11405. )
  11406. );
  11407. }
  11408. /// <summary>
  11409. /// Projects each element of an observable sequence to an enumerable sequence and concatenates the resulting enumerable sequences into one observable sequence.
  11410. /// </summary>
  11411. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11412. /// <typeparam name="TResult">The type of the elements in the projected inner enumerable sequences and the elements in the merged result sequence.</typeparam>
  11413. /// <param name="source">An observable sequence of elements to project.</param>
  11414. /// <param name="selector">A transform function to apply to each element.</param>
  11415. /// <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>
  11416. /// <exception cref="T:System.ArgumentNullException">
  11417. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11418. /// <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>
  11419. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, IEnumerable<TResult>>> selector)
  11420. {
  11421. if (source == null)
  11422. throw new ArgumentNullException("source");
  11423. if (selector == null)
  11424. throw new ArgumentNullException("selector");
  11425. return source.Provider.CreateQuery<TResult>(
  11426. Expression.Call(
  11427. null,
  11428. #if CRIPPLED_REFLECTION
  11429. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, IEnumerable<TResult>>>))),
  11430. #else
  11431. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11432. #endif
  11433. source.Expression,
  11434. selector
  11435. )
  11436. );
  11437. }
  11438. /// <summary>
  11439. /// 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.
  11440. /// </summary>
  11441. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11442. /// <typeparam name="TResult">The type of the elements in the projected inner enumerable sequences and the elements in the merged result sequence.</typeparam>
  11443. /// <param name="source">An observable sequence of elements to project.</param>
  11444. /// <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>
  11445. /// <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>
  11446. /// <exception cref="T:System.ArgumentNullException">
  11447. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11448. /// <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>
  11449. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, IEnumerable<TResult>>> selector)
  11450. {
  11451. if (source == null)
  11452. throw new ArgumentNullException("source");
  11453. if (selector == null)
  11454. throw new ArgumentNullException("selector");
  11455. return source.Provider.CreateQuery<TResult>(
  11456. Expression.Call(
  11457. null,
  11458. #if CRIPPLED_REFLECTION
  11459. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, IEnumerable<TResult>>>))),
  11460. #else
  11461. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11462. #endif
  11463. source.Expression,
  11464. selector
  11465. )
  11466. );
  11467. }
  11468. /// <summary>
  11469. /// Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  11470. /// </summary>
  11471. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11472. /// <typeparam name="TResult">The type of the elements in the projected inner sequences and the elements in the merged result sequence.</typeparam>
  11473. /// <param name="source">An observable sequence of elements to project.</param>
  11474. /// <param name="selector">A transform function to apply to each element.</param>
  11475. /// <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>
  11476. /// <exception cref="T:System.ArgumentNullException">
  11477. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11478. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TResult>>> selector)
  11479. {
  11480. if (source == null)
  11481. throw new ArgumentNullException("source");
  11482. if (selector == null)
  11483. throw new ArgumentNullException("selector");
  11484. return source.Provider.CreateQuery<TResult>(
  11485. Expression.Call(
  11486. null,
  11487. #if CRIPPLED_REFLECTION
  11488. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TResult>>>))),
  11489. #else
  11490. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11491. #endif
  11492. source.Expression,
  11493. selector
  11494. )
  11495. );
  11496. }
  11497. /// <summary>
  11498. /// 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.
  11499. /// </summary>
  11500. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11501. /// <typeparam name="TResult">The type of the elements in the projected inner sequences and the elements in the merged result sequence.</typeparam>
  11502. /// <param name="source">An observable sequence of elements to project.</param>
  11503. /// <param name="selector">A transform function to apply to each element; the second parameter of the function represents the index of the source element.</param>
  11504. /// <returns>An observable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence.</returns>
  11505. /// <exception cref="T:System.ArgumentNullException">
  11506. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11507. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, IObservable<TResult>>> selector)
  11508. {
  11509. if (source == null)
  11510. throw new ArgumentNullException("source");
  11511. if (selector == null)
  11512. throw new ArgumentNullException("selector");
  11513. return source.Provider.CreateQuery<TResult>(
  11514. Expression.Call(
  11515. null,
  11516. #if CRIPPLED_REFLECTION
  11517. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, IObservable<TResult>>>))),
  11518. #else
  11519. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11520. #endif
  11521. source.Expression,
  11522. selector
  11523. )
  11524. );
  11525. }
  11526. #if !NO_TPL
  11527. /// <summary>
  11528. /// Projects each element of an observable sequence to a task and merges all of the task results into one observable sequence.
  11529. /// </summary>
  11530. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11531. /// <typeparam name="TResult">The type of the result produced by the projected tasks and the elements in the merged result sequence.</typeparam>
  11532. /// <param name="source">An observable sequence of elements to project.</param>
  11533. /// <param name="selector">A transform function to apply to each element.</param>
  11534. /// <returns>An observable sequence whose elements are the result of the tasks executed for each element of the input sequence.</returns>
  11535. /// <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>
  11536. /// <exception cref="T:System.ArgumentNullException">
  11537. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11538. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, Task<TResult>>> selector)
  11539. {
  11540. if (source == null)
  11541. throw new ArgumentNullException("source");
  11542. if (selector == null)
  11543. throw new ArgumentNullException("selector");
  11544. return source.Provider.CreateQuery<TResult>(
  11545. Expression.Call(
  11546. null,
  11547. #if CRIPPLED_REFLECTION
  11548. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, Task<TResult>>>))),
  11549. #else
  11550. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11551. #endif
  11552. source.Expression,
  11553. selector
  11554. )
  11555. );
  11556. }
  11557. #endif
  11558. #if !NO_TPL
  11559. /// <summary>
  11560. /// 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.
  11561. /// </summary>
  11562. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11563. /// <typeparam name="TResult">The type of the result produced by the projected tasks and the elements in the merged result sequence.</typeparam>
  11564. /// <param name="source">An observable sequence of elements to project.</param>
  11565. /// <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>
  11566. /// <returns>An observable sequence whose elements are the result of the tasks executed for each element of the input sequence.</returns>
  11567. /// <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>
  11568. /// <exception cref="T:System.ArgumentNullException">
  11569. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11570. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, Task<TResult>>> selector)
  11571. {
  11572. if (source == null)
  11573. throw new ArgumentNullException("source");
  11574. if (selector == null)
  11575. throw new ArgumentNullException("selector");
  11576. return source.Provider.CreateQuery<TResult>(
  11577. Expression.Call(
  11578. null,
  11579. #if CRIPPLED_REFLECTION
  11580. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, Task<TResult>>>))),
  11581. #else
  11582. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11583. #endif
  11584. source.Expression,
  11585. selector
  11586. )
  11587. );
  11588. }
  11589. #endif
  11590. #if !NO_TPL
  11591. /// <summary>
  11592. /// Projects each element of an observable sequence to a task with cancellation support and merges all of the task results into one observable sequence.
  11593. /// </summary>
  11594. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11595. /// <typeparam name="TResult">The type of the result produced by the projected tasks and the elements in the merged result sequence.</typeparam>
  11596. /// <param name="source">An observable sequence of elements to project.</param>
  11597. /// <param name="selector">A transform function to apply to each element.</param>
  11598. /// <returns>An observable sequence whose elements are the result of the tasks executed for each element of the input sequence.</returns>
  11599. /// <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>
  11600. /// <exception cref="T:System.ArgumentNullException">
  11601. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11602. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, CancellationToken, Task<TResult>>> selector)
  11603. {
  11604. if (source == null)
  11605. throw new ArgumentNullException("source");
  11606. if (selector == null)
  11607. throw new ArgumentNullException("selector");
  11608. return source.Provider.CreateQuery<TResult>(
  11609. Expression.Call(
  11610. null,
  11611. #if CRIPPLED_REFLECTION
  11612. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, CancellationToken, Task<TResult>>>))),
  11613. #else
  11614. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11615. #endif
  11616. source.Expression,
  11617. selector
  11618. )
  11619. );
  11620. }
  11621. #endif
  11622. #if !NO_TPL
  11623. /// <summary>
  11624. /// 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.
  11625. /// </summary>
  11626. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11627. /// <typeparam name="TResult">The type of the result produced by the projected tasks and the elements in the merged result sequence.</typeparam>
  11628. /// <param name="source">An observable sequence of elements to project.</param>
  11629. /// <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>
  11630. /// <returns>An observable sequence whose elements are the result of the tasks executed for each element of the input sequence.</returns>
  11631. /// <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>
  11632. /// <exception cref="T:System.ArgumentNullException">
  11633. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11634. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, CancellationToken, Task<TResult>>> selector)
  11635. {
  11636. if (source == null)
  11637. throw new ArgumentNullException("source");
  11638. if (selector == null)
  11639. throw new ArgumentNullException("selector");
  11640. return source.Provider.CreateQuery<TResult>(
  11641. Expression.Call(
  11642. null,
  11643. #if CRIPPLED_REFLECTION
  11644. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, CancellationToken, Task<TResult>>>))),
  11645. #else
  11646. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11647. #endif
  11648. source.Expression,
  11649. selector
  11650. )
  11651. );
  11652. }
  11653. #endif
  11654. #if !NO_TPL
  11655. /// <summary>
  11656. /// 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.
  11657. /// </summary>
  11658. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11659. /// <typeparam name="TTaskResult">The type of the results produced by the projected intermediate tasks.</typeparam>
  11660. /// <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>
  11661. /// <param name="source">An observable sequence of elements to project.</param>
  11662. /// <param name="taskSelector">A transform function to apply to each element.</param>
  11663. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
  11664. /// <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>
  11665. /// <exception cref="T:System.ArgumentNullException">
  11666. /// <paramref name="source" /> or <paramref name="taskSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11667. /// <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>
  11668. 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)
  11669. {
  11670. if (source == null)
  11671. throw new ArgumentNullException("source");
  11672. if (taskSelector == null)
  11673. throw new ArgumentNullException("taskSelector");
  11674. if (resultSelector == null)
  11675. throw new ArgumentNullException("resultSelector");
  11676. return source.Provider.CreateQuery<TResult>(
  11677. Expression.Call(
  11678. null,
  11679. #if CRIPPLED_REFLECTION
  11680. InfoOf(() => Qbservable.SelectMany<TSource, TTaskResult, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, CancellationToken, Task<TTaskResult>>>), default(Expression<Func<TSource, TTaskResult, TResult>>))),
  11681. #else
  11682. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTaskResult), typeof(TResult)),
  11683. #endif
  11684. source.Expression,
  11685. taskSelector,
  11686. resultSelector
  11687. )
  11688. );
  11689. }
  11690. #endif
  11691. #if !NO_TPL
  11692. /// <summary>
  11693. /// 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.
  11694. /// </summary>
  11695. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11696. /// <typeparam name="TTaskResult">The type of the results produced by the projected intermediate tasks.</typeparam>
  11697. /// <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>
  11698. /// <param name="source">An observable sequence of elements to project.</param>
  11699. /// <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>
  11700. /// <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>
  11701. /// <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>
  11702. /// <exception cref="T:System.ArgumentNullException">
  11703. /// <paramref name="source" /> or <paramref name="taskSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11704. /// <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>
  11705. 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)
  11706. {
  11707. if (source == null)
  11708. throw new ArgumentNullException("source");
  11709. if (taskSelector == null)
  11710. throw new ArgumentNullException("taskSelector");
  11711. if (resultSelector == null)
  11712. throw new ArgumentNullException("resultSelector");
  11713. return source.Provider.CreateQuery<TResult>(
  11714. Expression.Call(
  11715. null,
  11716. #if CRIPPLED_REFLECTION
  11717. InfoOf(() => Qbservable.SelectMany<TSource, TTaskResult, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, CancellationToken, Task<TTaskResult>>>), default(Expression<Func<TSource, int, TTaskResult, TResult>>))),
  11718. #else
  11719. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTaskResult), typeof(TResult)),
  11720. #endif
  11721. source.Expression,
  11722. taskSelector,
  11723. resultSelector
  11724. )
  11725. );
  11726. }
  11727. #endif
  11728. #if !NO_TPL
  11729. /// <summary>
  11730. /// 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.
  11731. /// </summary>
  11732. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11733. /// <typeparam name="TTaskResult">The type of the results produced by the projected intermediate tasks.</typeparam>
  11734. /// <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>
  11735. /// <param name="source">An observable sequence of elements to project.</param>
  11736. /// <param name="taskSelector">A transform function to apply to each element.</param>
  11737. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
  11738. /// <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>
  11739. /// <exception cref="T:System.ArgumentNullException">
  11740. /// <paramref name="source" /> or <paramref name="taskSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11741. /// <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>
  11742. public static IQbservable<TResult> SelectMany<TSource, TTaskResult, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, Task<TTaskResult>>> taskSelector, Expression<Func<TSource, TTaskResult, TResult>> resultSelector)
  11743. {
  11744. if (source == null)
  11745. throw new ArgumentNullException("source");
  11746. if (taskSelector == null)
  11747. throw new ArgumentNullException("taskSelector");
  11748. if (resultSelector == null)
  11749. throw new ArgumentNullException("resultSelector");
  11750. return source.Provider.CreateQuery<TResult>(
  11751. Expression.Call(
  11752. null,
  11753. #if CRIPPLED_REFLECTION
  11754. InfoOf(() => Qbservable.SelectMany<TSource, TTaskResult, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, Task<TTaskResult>>>), default(Expression<Func<TSource, TTaskResult, TResult>>))),
  11755. #else
  11756. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTaskResult), typeof(TResult)),
  11757. #endif
  11758. source.Expression,
  11759. taskSelector,
  11760. resultSelector
  11761. )
  11762. );
  11763. }
  11764. #endif
  11765. #if !NO_TPL
  11766. /// <summary>
  11767. /// 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.
  11768. /// </summary>
  11769. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11770. /// <typeparam name="TTaskResult">The type of the results produced by the projected intermediate tasks.</typeparam>
  11771. /// <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>
  11772. /// <param name="source">An observable sequence of elements to project.</param>
  11773. /// <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>
  11774. /// <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>
  11775. /// <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>
  11776. /// <exception cref="T:System.ArgumentNullException">
  11777. /// <paramref name="source" /> or <paramref name="taskSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11778. /// <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>
  11779. 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)
  11780. {
  11781. if (source == null)
  11782. throw new ArgumentNullException("source");
  11783. if (taskSelector == null)
  11784. throw new ArgumentNullException("taskSelector");
  11785. if (resultSelector == null)
  11786. throw new ArgumentNullException("resultSelector");
  11787. return source.Provider.CreateQuery<TResult>(
  11788. Expression.Call(
  11789. null,
  11790. #if CRIPPLED_REFLECTION
  11791. InfoOf(() => Qbservable.SelectMany<TSource, TTaskResult, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, Task<TTaskResult>>>), default(Expression<Func<TSource, int, TTaskResult, TResult>>))),
  11792. #else
  11793. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTaskResult), typeof(TResult)),
  11794. #endif
  11795. source.Expression,
  11796. taskSelector,
  11797. resultSelector
  11798. )
  11799. );
  11800. }
  11801. #endif
  11802. /// <summary>
  11803. /// Determines whether two sequences are equal by comparing the elements pairwise.
  11804. /// </summary>
  11805. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11806. /// <param name="first">First observable sequence to compare.</param>
  11807. /// <param name="second">Second observable sequence to compare.</param>
  11808. /// <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>
  11809. /// <exception cref="T:System.ArgumentNullException">
  11810. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  11811. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  11812. public static IQbservable<bool> SequenceEqual<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  11813. {
  11814. if (first == null)
  11815. throw new ArgumentNullException("first");
  11816. if (second == null)
  11817. throw new ArgumentNullException("second");
  11818. return first.Provider.CreateQuery<bool>(
  11819. Expression.Call(
  11820. null,
  11821. #if CRIPPLED_REFLECTION
  11822. InfoOf(() => Qbservable.SequenceEqual<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  11823. #else
  11824. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11825. #endif
  11826. first.Expression,
  11827. GetSourceExpression(second)
  11828. )
  11829. );
  11830. }
  11831. /// <summary>
  11832. /// Determines whether an observable and enumerable sequence are equal by comparing the elements pairwise.
  11833. /// </summary>
  11834. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11835. /// <param name="first">First observable sequence to compare.</param>
  11836. /// <param name="second">Second observable sequence to compare.</param>
  11837. /// <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>
  11838. /// <exception cref="T:System.ArgumentNullException">
  11839. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  11840. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  11841. public static IQbservable<bool> SequenceEqual<TSource>(this IQbservable<TSource> first, IEnumerable<TSource> second)
  11842. {
  11843. if (first == null)
  11844. throw new ArgumentNullException("first");
  11845. if (second == null)
  11846. throw new ArgumentNullException("second");
  11847. return first.Provider.CreateQuery<bool>(
  11848. Expression.Call(
  11849. null,
  11850. #if CRIPPLED_REFLECTION
  11851. InfoOf(() => Qbservable.SequenceEqual<TSource>(default(IQbservable<TSource>), default(IEnumerable<TSource>))),
  11852. #else
  11853. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11854. #endif
  11855. first.Expression,
  11856. GetSourceExpression(second)
  11857. )
  11858. );
  11859. }
  11860. /// <summary>
  11861. /// Determines whether two sequences are equal by comparing the elements pairwise using a specified equality comparer.
  11862. /// </summary>
  11863. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11864. /// <param name="first">First observable sequence to compare.</param>
  11865. /// <param name="second">Second observable sequence to compare.</param>
  11866. /// <param name="comparer">Comparer used to compare elements of both sequences.</param>
  11867. /// <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>
  11868. /// <exception cref="T:System.ArgumentNullException">
  11869. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="comparer" /> is null.</exception>
  11870. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  11871. public static IQbservable<bool> SequenceEqual<TSource>(this IQbservable<TSource> first, IObservable<TSource> second, IEqualityComparer<TSource> comparer)
  11872. {
  11873. if (first == null)
  11874. throw new ArgumentNullException("first");
  11875. if (second == null)
  11876. throw new ArgumentNullException("second");
  11877. if (comparer == null)
  11878. throw new ArgumentNullException("comparer");
  11879. return first.Provider.CreateQuery<bool>(
  11880. Expression.Call(
  11881. null,
  11882. #if CRIPPLED_REFLECTION
  11883. InfoOf(() => Qbservable.SequenceEqual<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>), default(IEqualityComparer<TSource>))),
  11884. #else
  11885. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11886. #endif
  11887. first.Expression,
  11888. GetSourceExpression(second),
  11889. Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))
  11890. )
  11891. );
  11892. }
  11893. /// <summary>
  11894. /// Determines whether an observable and enumerable sequence are equal by comparing the elements pairwise using a specified equality comparer.
  11895. /// </summary>
  11896. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11897. /// <param name="first">First observable sequence to compare.</param>
  11898. /// <param name="second">Second observable sequence to compare.</param>
  11899. /// <param name="comparer">Comparer used to compare elements of both sequences.</param>
  11900. /// <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>
  11901. /// <exception cref="T:System.ArgumentNullException">
  11902. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="comparer" /> is null.</exception>
  11903. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  11904. public static IQbservable<bool> SequenceEqual<TSource>(this IQbservable<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
  11905. {
  11906. if (first == null)
  11907. throw new ArgumentNullException("first");
  11908. if (second == null)
  11909. throw new ArgumentNullException("second");
  11910. if (comparer == null)
  11911. throw new ArgumentNullException("comparer");
  11912. return first.Provider.CreateQuery<bool>(
  11913. Expression.Call(
  11914. null,
  11915. #if CRIPPLED_REFLECTION
  11916. InfoOf(() => Qbservable.SequenceEqual<TSource>(default(IQbservable<TSource>), default(IEnumerable<TSource>), default(IEqualityComparer<TSource>))),
  11917. #else
  11918. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11919. #endif
  11920. first.Expression,
  11921. GetSourceExpression(second),
  11922. Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))
  11923. )
  11924. );
  11925. }
  11926. /// <summary>
  11927. /// Returns the only element of an observable sequence, and reports an exception if there is not exactly one element in the observable sequence.
  11928. /// </summary>
  11929. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11930. /// <param name="source">Source observable sequence.</param>
  11931. /// <returns>Sequence containing the single element in the observable sequence.</returns>
  11932. /// <exception cref="T:System.ArgumentNullException">
  11933. /// <paramref name="source" /> is null.</exception>
  11934. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence contains more than one element. -or- The source sequence is empty.</exception>
  11935. public static IQbservable<TSource> SingleAsync<TSource>(this IQbservable<TSource> source)
  11936. {
  11937. if (source == null)
  11938. throw new ArgumentNullException("source");
  11939. return source.Provider.CreateQuery<TSource>(
  11940. Expression.Call(
  11941. null,
  11942. #if CRIPPLED_REFLECTION
  11943. InfoOf(() => Qbservable.SingleAsync<TSource>(default(IQbservable<TSource>))),
  11944. #else
  11945. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11946. #endif
  11947. source.Expression
  11948. )
  11949. );
  11950. }
  11951. /// <summary>
  11952. /// 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.
  11953. /// </summary>
  11954. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11955. /// <param name="source">Source observable sequence.</param>
  11956. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  11957. /// <returns>Sequence containing the single element in the observable sequence that satisfies the condition in the predicate.</returns>
  11958. /// <exception cref="T:System.ArgumentNullException">
  11959. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  11960. /// <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>
  11961. public static IQbservable<TSource> SingleAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  11962. {
  11963. if (source == null)
  11964. throw new ArgumentNullException("source");
  11965. if (predicate == null)
  11966. throw new ArgumentNullException("predicate");
  11967. return source.Provider.CreateQuery<TSource>(
  11968. Expression.Call(
  11969. null,
  11970. #if CRIPPLED_REFLECTION
  11971. InfoOf(() => Qbservable.SingleAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  11972. #else
  11973. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11974. #endif
  11975. source.Expression,
  11976. predicate
  11977. )
  11978. );
  11979. }
  11980. /// <summary>
  11981. /// 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.
  11982. /// </summary>
  11983. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11984. /// <param name="source">Source observable sequence.</param>
  11985. /// <returns>Sequence containing the single element in the observable sequence, or a default value if no such element exists.</returns>
  11986. /// <exception cref="T:System.ArgumentNullException">
  11987. /// <paramref name="source" /> is null.</exception>
  11988. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The source sequence contains more than one element.</exception>
  11989. public static IQbservable<TSource> SingleOrDefaultAsync<TSource>(this IQbservable<TSource> source)
  11990. {
  11991. if (source == null)
  11992. throw new ArgumentNullException("source");
  11993. return source.Provider.CreateQuery<TSource>(
  11994. Expression.Call(
  11995. null,
  11996. #if CRIPPLED_REFLECTION
  11997. InfoOf(() => Qbservable.SingleOrDefaultAsync<TSource>(default(IQbservable<TSource>))),
  11998. #else
  11999. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12000. #endif
  12001. source.Expression
  12002. )
  12003. );
  12004. }
  12005. /// <summary>
  12006. /// 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.
  12007. /// </summary>
  12008. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12009. /// <param name="source">Source observable sequence.</param>
  12010. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  12011. /// <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>
  12012. /// <exception cref="T:System.ArgumentNullException">
  12013. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  12014. /// <exception cref="T:System.InvalidOperationException">(Asynchronous) The sequence contains more than one element that satisfies the condition in the predicate.</exception>
  12015. public static IQbservable<TSource> SingleOrDefaultAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  12016. {
  12017. if (source == null)
  12018. throw new ArgumentNullException("source");
  12019. if (predicate == null)
  12020. throw new ArgumentNullException("predicate");
  12021. return source.Provider.CreateQuery<TSource>(
  12022. Expression.Call(
  12023. null,
  12024. #if CRIPPLED_REFLECTION
  12025. InfoOf(() => Qbservable.SingleOrDefaultAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  12026. #else
  12027. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12028. #endif
  12029. source.Expression,
  12030. predicate
  12031. )
  12032. );
  12033. }
  12034. /// <summary>
  12035. /// Bypasses a specified number of elements in an observable sequence and then returns the remaining elements.
  12036. /// </summary>
  12037. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12038. /// <param name="source">The sequence to take elements from.</param>
  12039. /// <param name="count">The number of elements to skip before returning the remaining elements.</param>
  12040. /// <returns>An observable sequence that contains the elements that occur after the specified index in the input sequence.</returns>
  12041. /// <exception cref="T:System.ArgumentNullException">
  12042. /// <paramref name="source" /> is null.</exception>
  12043. /// <exception cref="T:System.ArgumentOutOfRangeException">
  12044. /// <paramref name="count" /> is less than zero.</exception>
  12045. public static IQbservable<TSource> Skip<TSource>(this IQbservable<TSource> source, int count)
  12046. {
  12047. if (source == null)
  12048. throw new ArgumentNullException("source");
  12049. return source.Provider.CreateQuery<TSource>(
  12050. Expression.Call(
  12051. null,
  12052. #if CRIPPLED_REFLECTION
  12053. InfoOf(() => Qbservable.Skip<TSource>(default(IQbservable<TSource>), default(int))),
  12054. #else
  12055. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12056. #endif
  12057. source.Expression,
  12058. Expression.Constant(count, typeof(int))
  12059. )
  12060. );
  12061. }
  12062. /// <summary>
  12063. /// Skips elements for the specified duration from the start of the observable source sequence.
  12064. /// </summary>
  12065. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12066. /// <param name="source">Source sequence to skip elements for.</param>
  12067. /// <param name="duration">Duration for skipping elements from the start of the sequence.</param>
  12068. /// <returns>An observable sequence with the elements skipped during the specified duration from the start of the source sequence.</returns>
  12069. /// <exception cref="T:System.ArgumentNullException">
  12070. /// <paramref name="source" /> is null.</exception>
  12071. /// <exception cref="T:System.ArgumentOutOfRangeException">
  12072. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  12073. /// <remarks>
  12074. /// <para>
  12075. /// Specifying a TimeSpan.Zero value for <paramref name="duration" /> doesn't guarantee no elements will be dropped from the start of the source sequence.
  12076. /// 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
  12077. /// may not execute immediately, despite the TimeSpan.Zero due time.
  12078. /// </para>
  12079. /// <para>
  12080. /// Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the <paramref name="duration" />.
  12081. /// </para>
  12082. /// </remarks>
  12083. public static IQbservable<TSource> Skip<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  12084. {
  12085. if (source == null)
  12086. throw new ArgumentNullException("source");
  12087. return source.Provider.CreateQuery<TSource>(
  12088. Expression.Call(
  12089. null,
  12090. #if CRIPPLED_REFLECTION
  12091. InfoOf(() => Qbservable.Skip<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  12092. #else
  12093. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12094. #endif
  12095. source.Expression,
  12096. Expression.Constant(duration, typeof(TimeSpan))
  12097. )
  12098. );
  12099. }
  12100. /// <summary>
  12101. /// Skips elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers.
  12102. /// </summary>
  12103. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12104. /// <param name="source">Source sequence to skip elements for.</param>
  12105. /// <param name="duration">Duration for skipping elements from the start of the sequence.</param>
  12106. /// <param name="scheduler">Scheduler to run the timer on.</param>
  12107. /// <returns>An observable sequence with the elements skipped during the specified duration from the start of the source sequence.</returns>
  12108. /// <exception cref="T:System.ArgumentNullException">
  12109. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  12110. /// <exception cref="T:System.ArgumentOutOfRangeException">
  12111. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  12112. /// <remarks>
  12113. /// <para>
  12114. /// Specifying a TimeSpan.Zero value for <paramref name="duration" /> doesn't guarantee no elements will be dropped from the start of the source sequence.
  12115. /// 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
  12116. /// may not execute immediately, despite the TimeSpan.Zero due time.
  12117. /// </para>
  12118. /// <para>
  12119. /// Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the <paramref name="duration" />.
  12120. /// </para>
  12121. /// </remarks>
  12122. public static IQbservable<TSource> Skip<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  12123. {
  12124. if (source == null)
  12125. throw new ArgumentNullException("source");
  12126. if (scheduler == null)
  12127. throw new ArgumentNullException("scheduler");
  12128. return source.Provider.CreateQuery<TSource>(
  12129. Expression.Call(
  12130. null,
  12131. #if CRIPPLED_REFLECTION
  12132. InfoOf(() => Qbservable.Skip<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  12133. #else
  12134. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12135. #endif
  12136. source.Expression,
  12137. Expression.Constant(duration, typeof(TimeSpan)),
  12138. Expression.Constant(scheduler, typeof(IScheduler))
  12139. )
  12140. );
  12141. }
  12142. /// <summary>
  12143. /// Bypasses a specified number of elements at the end of an observable sequence.
  12144. /// </summary>
  12145. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12146. /// <param name="source">Source sequence.</param>
  12147. /// <param name="count">Number of elements to bypass at the end of the source sequence.</param>
  12148. /// <returns>An observable sequence containing the source sequence elements except for the bypassed ones at the end.</returns>
  12149. /// <exception cref="T:System.ArgumentNullException">
  12150. /// <paramref name="source" /> is null.</exception>
  12151. /// <exception cref="T:System.ArgumentOutOfRangeException">
  12152. /// <paramref name="count" /> is less than zero.</exception>
  12153. /// <remarks>
  12154. /// This operator accumulates a queue with a length enough to store the first <paramref name="count" /> elements. As more elements are
  12155. /// received, elements are taken from the front of the queue and produced on the result sequence. This causes elements to be delayed.
  12156. /// </remarks>
  12157. public static IQbservable<TSource> SkipLast<TSource>(this IQbservable<TSource> source, int count)
  12158. {
  12159. if (source == null)
  12160. throw new ArgumentNullException("source");
  12161. return source.Provider.CreateQuery<TSource>(
  12162. Expression.Call(
  12163. null,
  12164. #if CRIPPLED_REFLECTION
  12165. InfoOf(() => Qbservable.SkipLast<TSource>(default(IQbservable<TSource>), default(int))),
  12166. #else
  12167. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12168. #endif
  12169. source.Expression,
  12170. Expression.Constant(count, typeof(int))
  12171. )
  12172. );
  12173. }
  12174. /// <summary>
  12175. /// Skips elements for the specified duration from the end of the observable source sequence.
  12176. /// </summary>
  12177. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12178. /// <param name="source">Source sequence to skip elements for.</param>
  12179. /// <param name="duration">Duration for skipping elements from the end of the sequence.</param>
  12180. /// <returns>An observable sequence with the elements skipped during the specified duration from the end of the source sequence.</returns>
  12181. /// <exception cref="T:System.ArgumentNullException">
  12182. /// <paramref name="source" /> is null.</exception>
  12183. /// <exception cref="T:System.ArgumentOutOfRangeException">
  12184. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  12185. /// <remarks>
  12186. /// This operator accumulates a queue with a length enough to store elements received during the initial <paramref name="duration" /> window.
  12187. /// As more elements are received, elements older than the specified <paramref name="duration" /> are taken from the queue and produced on the
  12188. /// result sequence. This causes elements to be delayed with <paramref name="duration" />.
  12189. /// </remarks>
  12190. public static IQbservable<TSource> SkipLast<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  12191. {
  12192. if (source == null)
  12193. throw new ArgumentNullException("source");
  12194. return source.Provider.CreateQuery<TSource>(
  12195. Expression.Call(
  12196. null,
  12197. #if CRIPPLED_REFLECTION
  12198. InfoOf(() => Qbservable.SkipLast<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  12199. #else
  12200. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12201. #endif
  12202. source.Expression,
  12203. Expression.Constant(duration, typeof(TimeSpan))
  12204. )
  12205. );
  12206. }
  12207. /// <summary>
  12208. /// Skips elements for the specified duration from the end of the observable source sequence, using the specified scheduler to run timers.
  12209. /// </summary>
  12210. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12211. /// <param name="source">Source sequence to skip elements for.</param>
  12212. /// <param name="duration">Duration for skipping elements from the end of the sequence.</param>
  12213. /// <param name="scheduler">Scheduler to run the timer on.</param>
  12214. /// <returns>An observable sequence with the elements skipped during the specified duration from the end of the source sequence.</returns>
  12215. /// <exception cref="T:System.ArgumentNullException">
  12216. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  12217. /// <exception cref="T:System.ArgumentOutOfRangeException">
  12218. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  12219. /// <remarks>
  12220. /// This operator accumulates a queue with a length enough to store elements received during the initial <paramref name="duration" /> window.
  12221. /// As more elements are received, elements older than the specified <paramref name="duration" /> are taken from the queue and produced on the
  12222. /// result sequence. This causes elements to be delayed with <paramref name="duration" />.
  12223. /// </remarks>
  12224. public static IQbservable<TSource> SkipLast<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  12225. {
  12226. if (source == null)
  12227. throw new ArgumentNullException("source");
  12228. if (scheduler == null)
  12229. throw new ArgumentNullException("scheduler");
  12230. return source.Provider.CreateQuery<TSource>(
  12231. Expression.Call(
  12232. null,
  12233. #if CRIPPLED_REFLECTION
  12234. InfoOf(() => Qbservable.SkipLast<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  12235. #else
  12236. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12237. #endif
  12238. source.Expression,
  12239. Expression.Constant(duration, typeof(TimeSpan)),
  12240. Expression.Constant(scheduler, typeof(IScheduler))
  12241. )
  12242. );
  12243. }
  12244. /// <summary>
  12245. /// Skips elements from the observable source sequence until the specified start time.
  12246. /// </summary>
  12247. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12248. /// <param name="source">Source sequence to skip elements for.</param>
  12249. /// <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>
  12250. /// <returns>An observable sequence with the elements skipped until the specified start time.</returns>
  12251. /// <exception cref="T:System.ArgumentNullException">
  12252. /// <paramref name="source" /> is null.</exception>
  12253. /// <remarks>
  12254. /// Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the <paramref name="startTime" />.
  12255. /// </remarks>
  12256. public static IQbservable<TSource> SkipUntil<TSource>(this IQbservable<TSource> source, DateTimeOffset startTime)
  12257. {
  12258. if (source == null)
  12259. throw new ArgumentNullException("source");
  12260. return source.Provider.CreateQuery<TSource>(
  12261. Expression.Call(
  12262. null,
  12263. #if CRIPPLED_REFLECTION
  12264. InfoOf(() => Qbservable.SkipUntil<TSource>(default(IQbservable<TSource>), default(DateTimeOffset))),
  12265. #else
  12266. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12267. #endif
  12268. source.Expression,
  12269. Expression.Constant(startTime, typeof(DateTimeOffset))
  12270. )
  12271. );
  12272. }
  12273. /// <summary>
  12274. /// Skips elements from the observable source sequence until the specified start time, using the specified scheduler to run timers.
  12275. /// </summary>
  12276. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12277. /// <param name="source">Source sequence to skip elements for.</param>
  12278. /// <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>
  12279. /// <param name="scheduler">Scheduler to run the timer on.</param>
  12280. /// <returns>An observable sequence with the elements skipped until the specified start time.</returns>
  12281. /// <exception cref="T:System.ArgumentNullException">
  12282. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  12283. /// <remarks>
  12284. /// Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the <paramref name="startTime" />.
  12285. /// </remarks>
  12286. public static IQbservable<TSource> SkipUntil<TSource>(this IQbservable<TSource> source, DateTimeOffset startTime, IScheduler scheduler)
  12287. {
  12288. if (source == null)
  12289. throw new ArgumentNullException("source");
  12290. if (scheduler == null)
  12291. throw new ArgumentNullException("scheduler");
  12292. return source.Provider.CreateQuery<TSource>(
  12293. Expression.Call(
  12294. null,
  12295. #if CRIPPLED_REFLECTION
  12296. InfoOf(() => Qbservable.SkipUntil<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IScheduler))),
  12297. #else
  12298. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12299. #endif
  12300. source.Expression,
  12301. Expression.Constant(startTime, typeof(DateTimeOffset)),
  12302. Expression.Constant(scheduler, typeof(IScheduler))
  12303. )
  12304. );
  12305. }
  12306. /// <summary>
  12307. /// Returns the elements from the source observable sequence only after the other observable sequence produces an element.
  12308. /// </summary>
  12309. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12310. /// <typeparam name="TOther">The type of the elements in the other sequence that indicates the end of skip behavior.</typeparam>
  12311. /// <param name="source">Source sequence to propagate elements for.</param>
  12312. /// <param name="other">Observable sequence that triggers propagation of elements of the source sequence.</param>
  12313. /// <returns>An observable sequence containing the elements of the source sequence starting from the point the other sequence triggered propagation.</returns>
  12314. /// <exception cref="T:System.ArgumentNullException">
  12315. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  12316. public static IQbservable<TSource> SkipUntil<TSource, TOther>(this IQbservable<TSource> source, IObservable<TOther> other)
  12317. {
  12318. if (source == null)
  12319. throw new ArgumentNullException("source");
  12320. if (other == null)
  12321. throw new ArgumentNullException("other");
  12322. return source.Provider.CreateQuery<TSource>(
  12323. Expression.Call(
  12324. null,
  12325. #if CRIPPLED_REFLECTION
  12326. InfoOf(() => Qbservable.SkipUntil<TSource, TOther>(default(IQbservable<TSource>), default(IObservable<TOther>))),
  12327. #else
  12328. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)),
  12329. #endif
  12330. source.Expression,
  12331. GetSourceExpression(other)
  12332. )
  12333. );
  12334. }
  12335. /// <summary>
  12336. /// Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements.
  12337. /// </summary>
  12338. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12339. /// <param name="source">An observable sequence to return elements from.</param>
  12340. /// <param name="predicate">A function to test each element for a condition.</param>
  12341. /// <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>
  12342. /// <exception cref="T:System.ArgumentNullException">
  12343. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  12344. public static IQbservable<TSource> SkipWhile<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  12345. {
  12346. if (source == null)
  12347. throw new ArgumentNullException("source");
  12348. if (predicate == null)
  12349. throw new ArgumentNullException("predicate");
  12350. return source.Provider.CreateQuery<TSource>(
  12351. Expression.Call(
  12352. null,
  12353. #if CRIPPLED_REFLECTION
  12354. InfoOf(() => Qbservable.SkipWhile<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  12355. #else
  12356. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12357. #endif
  12358. source.Expression,
  12359. predicate
  12360. )
  12361. );
  12362. }
  12363. /// <summary>
  12364. /// Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements.
  12365. /// The element's index is used in the logic of the predicate function.
  12366. /// </summary>
  12367. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12368. /// <param name="source">An observable sequence to return elements from.</param>
  12369. /// <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>
  12370. /// <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>
  12371. /// <exception cref="T:System.ArgumentNullException">
  12372. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  12373. public static IQbservable<TSource> SkipWhile<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int, bool>> predicate)
  12374. {
  12375. if (source == null)
  12376. throw new ArgumentNullException("source");
  12377. if (predicate == null)
  12378. throw new ArgumentNullException("predicate");
  12379. return source.Provider.CreateQuery<TSource>(
  12380. Expression.Call(
  12381. null,
  12382. #if CRIPPLED_REFLECTION
  12383. InfoOf(() => Qbservable.SkipWhile<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, bool>>))),
  12384. #else
  12385. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12386. #endif
  12387. source.Expression,
  12388. predicate
  12389. )
  12390. );
  12391. }
  12392. /// <summary>
  12393. /// Invokes the action asynchronously, surfacing the result through an observable sequence.
  12394. /// </summary>
  12395. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  12396. /// <param name="action">Action to run asynchronously.</param>
  12397. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12398. /// <exception cref="T:System.ArgumentNullException">
  12399. /// <paramref name="action" /> is null.</exception>
  12400. /// <remarks>
  12401. /// <list type="bullet">
  12402. /// <item>
  12403. /// <description>The action is called immediately, not during the subscription of the resulting sequence.</description>
  12404. /// </item>
  12405. /// <item>
  12406. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12407. /// </item>
  12408. /// </list>
  12409. /// </remarks>
  12410. public static IQbservable<Unit> Start(this IQbservableProvider provider, Expression<Action> action)
  12411. {
  12412. if (provider == null)
  12413. throw new ArgumentNullException("provider");
  12414. if (action == null)
  12415. throw new ArgumentNullException("action");
  12416. return provider.CreateQuery<Unit>(
  12417. Expression.Call(
  12418. null,
  12419. #if CRIPPLED_REFLECTION
  12420. InfoOf(() => Qbservable.Start(default(IQbservableProvider), default(Expression<Action>))),
  12421. #else
  12422. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12423. #endif
  12424. Expression.Constant(provider, typeof(IQbservableProvider)),
  12425. action
  12426. )
  12427. );
  12428. }
  12429. /// <summary>
  12430. /// Invokes the action asynchronously on the specified scheduler, surfacing the result through an observable sequence.
  12431. /// </summary>
  12432. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  12433. /// <param name="action">Action to run asynchronously.</param>
  12434. /// <param name="scheduler">Scheduler to run the action on.</param>
  12435. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12436. /// <exception cref="T:System.ArgumentNullException">
  12437. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  12438. /// <remarks>
  12439. /// <list type="bullet">
  12440. /// <item>
  12441. /// <description>The action is called immediately, not during the subscription of the resulting sequence.</description>
  12442. /// </item>
  12443. /// <item>
  12444. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12445. /// </item>
  12446. /// </list>
  12447. /// </remarks>
  12448. public static IQbservable<Unit> Start(this IQbservableProvider provider, Expression<Action> action, IScheduler scheduler)
  12449. {
  12450. if (provider == null)
  12451. throw new ArgumentNullException("provider");
  12452. if (action == null)
  12453. throw new ArgumentNullException("action");
  12454. if (scheduler == null)
  12455. throw new ArgumentNullException("scheduler");
  12456. return provider.CreateQuery<Unit>(
  12457. Expression.Call(
  12458. null,
  12459. #if CRIPPLED_REFLECTION
  12460. InfoOf(() => Qbservable.Start(default(IQbservableProvider), default(Expression<Action>), default(IScheduler))),
  12461. #else
  12462. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12463. #endif
  12464. Expression.Constant(provider, typeof(IQbservableProvider)),
  12465. action,
  12466. Expression.Constant(scheduler, typeof(IScheduler))
  12467. )
  12468. );
  12469. }
  12470. /// <summary>
  12471. /// Invokes the specified function asynchronously, surfacing the result through an observable sequence.
  12472. /// </summary>
  12473. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  12474. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  12475. /// <param name="function">Function to run asynchronously.</param>
  12476. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12477. /// <exception cref="T:System.ArgumentNullException">
  12478. /// <paramref name="function" /> is null.</exception>
  12479. /// <remarks>
  12480. /// <list type="bullet">
  12481. /// <item>
  12482. /// <description>The function is called immediately, not during the subscription of the resulting sequence.</description>
  12483. /// </item>
  12484. /// <item>
  12485. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12486. /// </item>
  12487. /// </list>
  12488. /// </remarks>
  12489. public static IQbservable<TResult> Start<TResult>(this IQbservableProvider provider, Expression<Func<TResult>> function)
  12490. {
  12491. if (provider == null)
  12492. throw new ArgumentNullException("provider");
  12493. if (function == null)
  12494. throw new ArgumentNullException("function");
  12495. return provider.CreateQuery<TResult>(
  12496. Expression.Call(
  12497. null,
  12498. #if CRIPPLED_REFLECTION
  12499. InfoOf(() => Qbservable.Start<TResult>(default(IQbservableProvider), default(Expression<Func<TResult>>))),
  12500. #else
  12501. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12502. #endif
  12503. Expression.Constant(provider, typeof(IQbservableProvider)),
  12504. function
  12505. )
  12506. );
  12507. }
  12508. /// <summary>
  12509. /// Invokes the specified function asynchronously on the specified scheduler, surfacing the result through an observable sequence
  12510. /// </summary>
  12511. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  12512. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  12513. /// <param name="function">Function to run asynchronously.</param>
  12514. /// <param name="scheduler">Scheduler to run the function on.</param>
  12515. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12516. /// <exception cref="T:System.ArgumentNullException">
  12517. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  12518. /// <remarks>
  12519. /// <list type="bullet">
  12520. /// <item>
  12521. /// <description>The function is called immediately, not during the subscription of the resulting sequence.</description>
  12522. /// </item>
  12523. /// <item>
  12524. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12525. /// </item>
  12526. /// </list>
  12527. /// </remarks>
  12528. public static IQbservable<TResult> Start<TResult>(this IQbservableProvider provider, Expression<Func<TResult>> function, IScheduler scheduler)
  12529. {
  12530. if (provider == null)
  12531. throw new ArgumentNullException("provider");
  12532. if (function == null)
  12533. throw new ArgumentNullException("function");
  12534. if (scheduler == null)
  12535. throw new ArgumentNullException("scheduler");
  12536. return provider.CreateQuery<TResult>(
  12537. Expression.Call(
  12538. null,
  12539. #if CRIPPLED_REFLECTION
  12540. InfoOf(() => Qbservable.Start<TResult>(default(IQbservableProvider), default(Expression<Func<TResult>>), default(IScheduler))),
  12541. #else
  12542. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12543. #endif
  12544. Expression.Constant(provider, typeof(IQbservableProvider)),
  12545. function,
  12546. Expression.Constant(scheduler, typeof(IScheduler))
  12547. )
  12548. );
  12549. }
  12550. #if !NO_TPL
  12551. /// <summary>
  12552. /// Invokes the asynchronous action, surfacing the result through an observable sequence.
  12553. /// </summary>
  12554. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  12555. /// <param name="actionAsync">Asynchronous action to run.</param>
  12556. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12557. /// <exception cref="T:System.ArgumentNullException">
  12558. /// <paramref name="actionAsync" /> is null.</exception>
  12559. /// <remarks>
  12560. /// <list type="bullet">
  12561. /// <item>
  12562. /// <description>The action is started immediately, not during the subscription of the resulting sequence.</description>
  12563. /// </item>
  12564. /// <item>
  12565. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12566. /// </item>
  12567. /// </list>
  12568. /// </remarks>
  12569. public static IQbservable<Unit> StartAsync(this IQbservableProvider provider, Expression<Func<Task>> actionAsync)
  12570. {
  12571. if (provider == null)
  12572. throw new ArgumentNullException("provider");
  12573. if (actionAsync == null)
  12574. throw new ArgumentNullException("actionAsync");
  12575. return provider.CreateQuery<Unit>(
  12576. Expression.Call(
  12577. null,
  12578. #if CRIPPLED_REFLECTION
  12579. InfoOf(() => Qbservable.StartAsync(default(IQbservableProvider), default(Expression<Func<Task>>))),
  12580. #else
  12581. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12582. #endif
  12583. Expression.Constant(provider, typeof(IQbservableProvider)),
  12584. actionAsync
  12585. )
  12586. );
  12587. }
  12588. #endif
  12589. #if !NO_TPL
  12590. /// <summary>
  12591. /// Invokes the asynchronous action, surfacing the result through an observable sequence.
  12592. /// The CancellationToken is shared by all subscriptions on the resulting observable sequence. See the remarks section for more information.
  12593. /// </summary>
  12594. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  12595. /// <param name="actionAsync">Asynchronous action to run.</param>
  12596. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12597. /// <exception cref="T:System.ArgumentNullException">
  12598. /// <paramref name="actionAsync" /> is null.</exception>
  12599. /// <remarks>
  12600. /// <list type="bullet">
  12601. /// <item>
  12602. /// <description>The action is started immediately, not during the subscription of the resulting sequence.</description>
  12603. /// </item>
  12604. /// <item>
  12605. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12606. /// </item>
  12607. /// <item>
  12608. /// <description>
  12609. /// If any subscription to the resulting sequence is disposed, the CancellationToken is set. The observer associated to the disposed
  12610. /// subscription won't see the TaskCanceledException, but other observers will. You can protect against this using the Catch operator.
  12611. /// Be careful when handing out the resulting sequence because of this behavior. The most common use is to have a single subscription
  12612. /// to the resulting sequence, which controls the CancellationToken state. Alternatively, you can control subscription behavior using
  12613. /// multicast operators.
  12614. /// </description>
  12615. /// </item>
  12616. /// </list>
  12617. /// </remarks>
  12618. public static IQbservable<Unit> StartAsync(this IQbservableProvider provider, Expression<Func<CancellationToken, Task>> actionAsync)
  12619. {
  12620. if (provider == null)
  12621. throw new ArgumentNullException("provider");
  12622. if (actionAsync == null)
  12623. throw new ArgumentNullException("actionAsync");
  12624. return provider.CreateQuery<Unit>(
  12625. Expression.Call(
  12626. null,
  12627. #if CRIPPLED_REFLECTION
  12628. InfoOf(() => Qbservable.StartAsync(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task>>))),
  12629. #else
  12630. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12631. #endif
  12632. Expression.Constant(provider, typeof(IQbservableProvider)),
  12633. actionAsync
  12634. )
  12635. );
  12636. }
  12637. #endif
  12638. #if !NO_TPL
  12639. /// <summary>
  12640. /// Invokes the asynchronous function, surfacing the result through an observable sequence.
  12641. /// </summary>
  12642. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  12643. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  12644. /// <param name="functionAsync">Asynchronous function to run.</param>
  12645. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12646. /// <exception cref="T:System.ArgumentNullException">
  12647. /// <paramref name="functionAsync" /> is null.</exception>
  12648. /// <remarks>
  12649. /// <list type="bullet">
  12650. /// <item>
  12651. /// <description>The function is started immediately, not during the subscription of the resulting sequence.</description>
  12652. /// </item>
  12653. /// <item>
  12654. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12655. /// </item>
  12656. /// </list>
  12657. /// </remarks>
  12658. public static IQbservable<TResult> StartAsync<TResult>(this IQbservableProvider provider, Expression<Func<Task<TResult>>> functionAsync)
  12659. {
  12660. if (provider == null)
  12661. throw new ArgumentNullException("provider");
  12662. if (functionAsync == null)
  12663. throw new ArgumentNullException("functionAsync");
  12664. return provider.CreateQuery<TResult>(
  12665. Expression.Call(
  12666. null,
  12667. #if CRIPPLED_REFLECTION
  12668. InfoOf(() => Qbservable.StartAsync<TResult>(default(IQbservableProvider), default(Expression<Func<Task<TResult>>>))),
  12669. #else
  12670. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12671. #endif
  12672. Expression.Constant(provider, typeof(IQbservableProvider)),
  12673. functionAsync
  12674. )
  12675. );
  12676. }
  12677. #endif
  12678. #if !NO_TPL
  12679. /// <summary>
  12680. /// Invokes the asynchronous function, surfacing the result through an observable sequence.
  12681. /// The CancellationToken is shared by all subscriptions on the resulting observable sequence. See the remarks section for more information.
  12682. /// </summary>
  12683. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  12684. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  12685. /// <param name="functionAsync">Asynchronous function to run.</param>
  12686. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12687. /// <exception cref="T:System.ArgumentNullException">
  12688. /// <paramref name="functionAsync" /> is null.</exception>
  12689. /// <remarks>
  12690. /// <list type="bullet">
  12691. /// <item>
  12692. /// <description>The function is started immediately, not during the subscription of the resulting sequence.</description>
  12693. /// </item>
  12694. /// <item>
  12695. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12696. /// </item>
  12697. /// <item>
  12698. /// <description>
  12699. /// If any subscription to the resulting sequence is disposed, the CancellationToken is set. The observer associated to the disposed
  12700. /// subscription won't see the TaskCanceledException, but other observers will. You can protect against this using the Catch operator.
  12701. /// Be careful when handing out the resulting sequence because of this behavior. The most common use is to have a single subscription
  12702. /// to the resulting sequence, which controls the CancellationToken state. Alternatively, you can control subscription behavior using
  12703. /// multicast operators.
  12704. /// </description>
  12705. /// </item>
  12706. /// </list>
  12707. /// </remarks>
  12708. public static IQbservable<TResult> StartAsync<TResult>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<TResult>>> functionAsync)
  12709. {
  12710. if (provider == null)
  12711. throw new ArgumentNullException("provider");
  12712. if (functionAsync == null)
  12713. throw new ArgumentNullException("functionAsync");
  12714. return provider.CreateQuery<TResult>(
  12715. Expression.Call(
  12716. null,
  12717. #if CRIPPLED_REFLECTION
  12718. InfoOf(() => Qbservable.StartAsync<TResult>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<TResult>>>))),
  12719. #else
  12720. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12721. #endif
  12722. Expression.Constant(provider, typeof(IQbservableProvider)),
  12723. functionAsync
  12724. )
  12725. );
  12726. }
  12727. #endif
  12728. /// <summary>
  12729. /// Prepends a sequence of values to an observable sequence.
  12730. /// </summary>
  12731. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12732. /// <param name="source">Source sequence to prepend values to.</param>
  12733. /// <param name="scheduler">Scheduler to emit the prepended values on.</param>
  12734. /// <param name="values">Values to prepend to the specified sequence.</param>
  12735. /// <returns>The source sequence prepended with the specified values.</returns>
  12736. /// <exception cref="T:System.ArgumentNullException">
  12737. /// <paramref name="source" /> or <paramref name="scheduler" /> or <paramref name="values" /> is null.</exception>
  12738. public static IQbservable<TSource> StartWith<TSource>(this IQbservable<TSource> source, IScheduler scheduler, params TSource[] values)
  12739. {
  12740. if (source == null)
  12741. throw new ArgumentNullException("source");
  12742. if (scheduler == null)
  12743. throw new ArgumentNullException("scheduler");
  12744. if (values == null)
  12745. throw new ArgumentNullException("values");
  12746. return source.Provider.CreateQuery<TSource>(
  12747. Expression.Call(
  12748. null,
  12749. #if CRIPPLED_REFLECTION
  12750. InfoOf(() => Qbservable.StartWith<TSource>(default(IQbservable<TSource>), default(IScheduler), default(TSource[]))),
  12751. #else
  12752. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12753. #endif
  12754. source.Expression,
  12755. Expression.Constant(scheduler, typeof(IScheduler)),
  12756. Expression.Constant(values, typeof(TSource[]))
  12757. )
  12758. );
  12759. }
  12760. /// <summary>
  12761. /// Prepends a sequence of values to an observable sequence.
  12762. /// </summary>
  12763. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12764. /// <param name="source">Source sequence to prepend values to.</param>
  12765. /// <param name="scheduler">Scheduler to emit the prepended values on.</param>
  12766. /// <param name="values">Values to prepend to the specified sequence.</param>
  12767. /// <returns>The source sequence prepended with the specified values.</returns>
  12768. /// <exception cref="T:System.ArgumentNullException">
  12769. /// <paramref name="source" /> or <paramref name="scheduler" /> or <paramref name="values" /> is null.</exception>
  12770. public static IQbservable<TSource> StartWith<TSource>(this IQbservable<TSource> source, IScheduler scheduler, IEnumerable<TSource> values)
  12771. {
  12772. if (source == null)
  12773. throw new ArgumentNullException("source");
  12774. if (scheduler == null)
  12775. throw new ArgumentNullException("scheduler");
  12776. if (values == null)
  12777. throw new ArgumentNullException("values");
  12778. return source.Provider.CreateQuery<TSource>(
  12779. Expression.Call(
  12780. null,
  12781. #if CRIPPLED_REFLECTION
  12782. InfoOf(() => Qbservable.StartWith<TSource>(default(IQbservable<TSource>), default(IScheduler), default(IEnumerable<TSource>))),
  12783. #else
  12784. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12785. #endif
  12786. source.Expression,
  12787. Expression.Constant(scheduler, typeof(IScheduler)),
  12788. GetSourceExpression(values)
  12789. )
  12790. );
  12791. }
  12792. /// <summary>
  12793. /// Prepends a sequence of values to an observable sequence.
  12794. /// </summary>
  12795. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12796. /// <param name="source">Source sequence to prepend values to.</param>
  12797. /// <param name="values">Values to prepend to the specified sequence.</param>
  12798. /// <returns>The source sequence prepended with the specified values.</returns>
  12799. /// <exception cref="T:System.ArgumentNullException">
  12800. /// <paramref name="source" /> or <paramref name="values" /> is null.</exception>
  12801. public static IQbservable<TSource> StartWith<TSource>(this IQbservable<TSource> source, params TSource[] values)
  12802. {
  12803. if (source == null)
  12804. throw new ArgumentNullException("source");
  12805. if (values == null)
  12806. throw new ArgumentNullException("values");
  12807. return source.Provider.CreateQuery<TSource>(
  12808. Expression.Call(
  12809. null,
  12810. #if CRIPPLED_REFLECTION
  12811. InfoOf(() => Qbservable.StartWith<TSource>(default(IQbservable<TSource>), default(TSource[]))),
  12812. #else
  12813. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12814. #endif
  12815. source.Expression,
  12816. Expression.Constant(values, typeof(TSource[]))
  12817. )
  12818. );
  12819. }
  12820. /// <summary>
  12821. /// Prepends a sequence of values to an observable sequence.
  12822. /// </summary>
  12823. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12824. /// <param name="source">Source sequence to prepend values to.</param>
  12825. /// <param name="values">Values to prepend to the specified sequence.</param>
  12826. /// <returns>The source sequence prepended with the specified values.</returns>
  12827. /// <exception cref="T:System.ArgumentNullException">
  12828. /// <paramref name="source" /> or <paramref name="values" /> is null.</exception>
  12829. public static IQbservable<TSource> StartWith<TSource>(this IQbservable<TSource> source, IEnumerable<TSource> values)
  12830. {
  12831. if (source == null)
  12832. throw new ArgumentNullException("source");
  12833. if (values == null)
  12834. throw new ArgumentNullException("values");
  12835. return source.Provider.CreateQuery<TSource>(
  12836. Expression.Call(
  12837. null,
  12838. #if CRIPPLED_REFLECTION
  12839. InfoOf(() => Qbservable.StartWith<TSource>(default(IQbservable<TSource>), default(IEnumerable<TSource>))),
  12840. #else
  12841. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12842. #endif
  12843. source.Expression,
  12844. GetSourceExpression(values)
  12845. )
  12846. );
  12847. }
  12848. /// <summary>
  12849. /// Wraps the source sequence in order to run its subscription and unsubscription logic on the specified synchronization context. This operation is not commonly used;
  12850. /// see the remarks section for more information on the distinction between SubscribeOn and ObserveOn.
  12851. /// </summary>
  12852. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12853. /// <param name="source">Source sequence.</param>
  12854. /// <param name="context">Synchronization context to perform subscription and unsubscription actions on.</param>
  12855. /// <returns>The source sequence whose subscriptions and unsubscriptions happen on the specified synchronization context.</returns>
  12856. /// <exception cref="T:System.ArgumentNullException">
  12857. /// <paramref name="source" /> or <paramref name="context" /> is null.</exception>
  12858. /// <remarks>
  12859. /// This only performs the side-effects of subscription and unsubscription on the specified synchronization context. In order to invoke observer
  12860. /// callbacks on a synchronization context, use <see cref="M:System.Reactive.Linq.Observable.ObserveOn``1(System.IObservable{``0},System.Threading.SynchronizationContext)" />.
  12861. /// </remarks>
  12862. public static IQbservable<TSource> SubscribeOn<TSource>(this IQbservable<TSource> source, SynchronizationContext context)
  12863. {
  12864. if (source == null)
  12865. throw new ArgumentNullException("source");
  12866. if (context == null)
  12867. throw new ArgumentNullException("context");
  12868. return source.Provider.CreateQuery<TSource>(
  12869. Expression.Call(
  12870. null,
  12871. #if CRIPPLED_REFLECTION
  12872. InfoOf(() => Qbservable.SubscribeOn<TSource>(default(IQbservable<TSource>), default(SynchronizationContext))),
  12873. #else
  12874. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12875. #endif
  12876. source.Expression,
  12877. Expression.Constant(context, typeof(SynchronizationContext))
  12878. )
  12879. );
  12880. }
  12881. /// <summary>
  12882. /// Wraps the source sequence in order to run its subscription and unsubscription logic on the specified scheduler. This operation is not commonly used;
  12883. /// see the remarks section for more information on the distinction between SubscribeOn and ObserveOn.
  12884. /// </summary>
  12885. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12886. /// <param name="source">Source sequence.</param>
  12887. /// <param name="scheduler">Scheduler to perform subscription and unsubscription actions on.</param>
  12888. /// <returns>The source sequence whose subscriptions and unsubscriptions happen on the specified scheduler.</returns>
  12889. /// <exception cref="T:System.ArgumentNullException">
  12890. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  12891. /// <remarks>
  12892. /// This only performs the side-effects of subscription and unsubscription on the specified scheduler. In order to invoke observer
  12893. /// callbacks on a scheduler, use <see cref="M:System.Reactive.Linq.Observable.ObserveOn``1(System.IObservable{``0},System.Reactive.Concurrency.IScheduler)" />.
  12894. /// </remarks>
  12895. public static IQbservable<TSource> SubscribeOn<TSource>(this IQbservable<TSource> source, IScheduler scheduler)
  12896. {
  12897. if (source == null)
  12898. throw new ArgumentNullException("source");
  12899. if (scheduler == null)
  12900. throw new ArgumentNullException("scheduler");
  12901. return source.Provider.CreateQuery<TSource>(
  12902. Expression.Call(
  12903. null,
  12904. #if CRIPPLED_REFLECTION
  12905. InfoOf(() => Qbservable.SubscribeOn<TSource>(default(IQbservable<TSource>), default(IScheduler))),
  12906. #else
  12907. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12908. #endif
  12909. source.Expression,
  12910. Expression.Constant(scheduler, typeof(IScheduler))
  12911. )
  12912. );
  12913. }
  12914. /// <summary>
  12915. /// Computes the sum of a sequence of <see cref="T:System.Decimal" /> values.
  12916. /// </summary>
  12917. /// <param name="source">A sequence of <see cref="T:System.Decimal" /> values to calculate the sum of.</param>
  12918. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  12919. /// <exception cref="T:System.ArgumentNullException">
  12920. /// <paramref name="source" /> is null.</exception>
  12921. /// <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>
  12922. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12923. public static IQbservable<decimal> Sum(this IQbservable<decimal> source)
  12924. {
  12925. if (source == null)
  12926. throw new ArgumentNullException("source");
  12927. return source.Provider.CreateQuery<decimal>(
  12928. Expression.Call(
  12929. null,
  12930. #if CRIPPLED_REFLECTION
  12931. InfoOf(() => Qbservable.Sum(default(IQbservable<decimal>))),
  12932. #else
  12933. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12934. #endif
  12935. source.Expression
  12936. )
  12937. );
  12938. }
  12939. /// <summary>
  12940. /// Computes the sum of a sequence of <see cref="T:System.Double" /> values.
  12941. /// </summary>
  12942. /// <param name="source">A sequence of <see cref="T:System.Double" /> values to calculate the sum of.</param>
  12943. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  12944. /// <exception cref="T:System.ArgumentNullException">
  12945. /// <paramref name="source" /> is null.</exception>
  12946. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12947. public static IQbservable<double> Sum(this IQbservable<double> source)
  12948. {
  12949. if (source == null)
  12950. throw new ArgumentNullException("source");
  12951. return source.Provider.CreateQuery<double>(
  12952. Expression.Call(
  12953. null,
  12954. #if CRIPPLED_REFLECTION
  12955. InfoOf(() => Qbservable.Sum(default(IQbservable<double>))),
  12956. #else
  12957. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12958. #endif
  12959. source.Expression
  12960. )
  12961. );
  12962. }
  12963. /// <summary>
  12964. /// Computes the sum of a sequence of <see cref="T:System.Int32" /> values.
  12965. /// </summary>
  12966. /// <param name="source">A sequence of <see cref="T:System.Int32" /> values to calculate the sum of.</param>
  12967. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  12968. /// <exception cref="T:System.ArgumentNullException">
  12969. /// <paramref name="source" /> is null.</exception>
  12970. /// <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>
  12971. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12972. public static IQbservable<int> Sum(this IQbservable<int> source)
  12973. {
  12974. if (source == null)
  12975. throw new ArgumentNullException("source");
  12976. return source.Provider.CreateQuery<int>(
  12977. Expression.Call(
  12978. null,
  12979. #if CRIPPLED_REFLECTION
  12980. InfoOf(() => Qbservable.Sum(default(IQbservable<int>))),
  12981. #else
  12982. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12983. #endif
  12984. source.Expression
  12985. )
  12986. );
  12987. }
  12988. /// <summary>
  12989. /// Computes the sum of a sequence of <see cref="T:System.Int64" /> values.
  12990. /// </summary>
  12991. /// <param name="source">A sequence of <see cref="T:System.Int64" /> values to calculate the sum of.</param>
  12992. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  12993. /// <exception cref="T:System.ArgumentNullException">
  12994. /// <paramref name="source" /> is null.</exception>
  12995. /// <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>
  12996. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12997. public static IQbservable<long> Sum(this IQbservable<long> source)
  12998. {
  12999. if (source == null)
  13000. throw new ArgumentNullException("source");
  13001. return source.Provider.CreateQuery<long>(
  13002. Expression.Call(
  13003. null,
  13004. #if CRIPPLED_REFLECTION
  13005. InfoOf(() => Qbservable.Sum(default(IQbservable<long>))),
  13006. #else
  13007. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13008. #endif
  13009. source.Expression
  13010. )
  13011. );
  13012. }
  13013. /// <summary>
  13014. /// Computes the sum of a sequence of nullable <see cref="T:System.Decimal" /> values.
  13015. /// </summary>
  13016. /// <param name="source">A sequence of nullable <see cref="T:System.Decimal" /> values to calculate the sum of.</param>
  13017. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13018. /// <exception cref="T:System.ArgumentNullException">
  13019. /// <paramref name="source" /> is null.</exception>
  13020. /// <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>
  13021. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13022. public static IQbservable<decimal?> Sum(this IQbservable<decimal?> source)
  13023. {
  13024. if (source == null)
  13025. throw new ArgumentNullException("source");
  13026. return source.Provider.CreateQuery<decimal?>(
  13027. Expression.Call(
  13028. null,
  13029. #if CRIPPLED_REFLECTION
  13030. InfoOf(() => Qbservable.Sum(default(IQbservable<decimal?>))),
  13031. #else
  13032. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13033. #endif
  13034. source.Expression
  13035. )
  13036. );
  13037. }
  13038. /// <summary>
  13039. /// Computes the sum of a sequence of nullable <see cref="T:System.Double" /> values.
  13040. /// </summary>
  13041. /// <param name="source">A sequence of nullable <see cref="T:System.Double" /> values to calculate the sum of.</param>
  13042. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13043. /// <exception cref="T:System.ArgumentNullException">
  13044. /// <paramref name="source" /> is null.</exception>
  13045. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13046. public static IQbservable<double?> Sum(this IQbservable<double?> source)
  13047. {
  13048. if (source == null)
  13049. throw new ArgumentNullException("source");
  13050. return source.Provider.CreateQuery<double?>(
  13051. Expression.Call(
  13052. null,
  13053. #if CRIPPLED_REFLECTION
  13054. InfoOf(() => Qbservable.Sum(default(IQbservable<double?>))),
  13055. #else
  13056. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13057. #endif
  13058. source.Expression
  13059. )
  13060. );
  13061. }
  13062. /// <summary>
  13063. /// Computes the sum of a sequence of nullable <see cref="T:System.Int32" /> values.
  13064. /// </summary>
  13065. /// <param name="source">A sequence of nullable <see cref="T:System.Int32" /> values to calculate the sum of.</param>
  13066. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13067. /// <exception cref="T:System.ArgumentNullException">
  13068. /// <paramref name="source" /> is null.</exception>
  13069. /// <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>
  13070. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13071. public static IQbservable<int?> Sum(this IQbservable<int?> source)
  13072. {
  13073. if (source == null)
  13074. throw new ArgumentNullException("source");
  13075. return source.Provider.CreateQuery<int?>(
  13076. Expression.Call(
  13077. null,
  13078. #if CRIPPLED_REFLECTION
  13079. InfoOf(() => Qbservable.Sum(default(IQbservable<int?>))),
  13080. #else
  13081. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13082. #endif
  13083. source.Expression
  13084. )
  13085. );
  13086. }
  13087. /// <summary>
  13088. /// Computes the sum of a sequence of nullable <see cref="T:System.Int64" /> values.
  13089. /// </summary>
  13090. /// <param name="source">A sequence of nullable <see cref="T:System.Int64" /> values to calculate the sum of.</param>
  13091. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13092. /// <exception cref="T:System.ArgumentNullException">
  13093. /// <paramref name="source" /> is null.</exception>
  13094. /// <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>
  13095. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13096. public static IQbservable<long?> Sum(this IQbservable<long?> source)
  13097. {
  13098. if (source == null)
  13099. throw new ArgumentNullException("source");
  13100. return source.Provider.CreateQuery<long?>(
  13101. Expression.Call(
  13102. null,
  13103. #if CRIPPLED_REFLECTION
  13104. InfoOf(() => Qbservable.Sum(default(IQbservable<long?>))),
  13105. #else
  13106. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13107. #endif
  13108. source.Expression
  13109. )
  13110. );
  13111. }
  13112. /// <summary>
  13113. /// Computes the sum of a sequence of nullable <see cref="T:System.Single" /> values.
  13114. /// </summary>
  13115. /// <param name="source">A sequence of nullable <see cref="T:System.Single" /> values to calculate the sum of.</param>
  13116. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13117. /// <exception cref="T:System.ArgumentNullException">
  13118. /// <paramref name="source" /> is null.</exception>
  13119. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13120. public static IQbservable<float?> Sum(this IQbservable<float?> source)
  13121. {
  13122. if (source == null)
  13123. throw new ArgumentNullException("source");
  13124. return source.Provider.CreateQuery<float?>(
  13125. Expression.Call(
  13126. null,
  13127. #if CRIPPLED_REFLECTION
  13128. InfoOf(() => Qbservable.Sum(default(IQbservable<float?>))),
  13129. #else
  13130. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13131. #endif
  13132. source.Expression
  13133. )
  13134. );
  13135. }
  13136. /// <summary>
  13137. /// Computes the sum of a sequence of <see cref="T:System.Single" /> values.
  13138. /// </summary>
  13139. /// <param name="source">A sequence of <see cref="T:System.Single" /> values to calculate the sum of.</param>
  13140. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13141. /// <exception cref="T:System.ArgumentNullException">
  13142. /// <paramref name="source" /> is null.</exception>
  13143. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13144. public static IQbservable<float> Sum(this IQbservable<float> source)
  13145. {
  13146. if (source == null)
  13147. throw new ArgumentNullException("source");
  13148. return source.Provider.CreateQuery<float>(
  13149. Expression.Call(
  13150. null,
  13151. #if CRIPPLED_REFLECTION
  13152. InfoOf(() => Qbservable.Sum(default(IQbservable<float>))),
  13153. #else
  13154. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13155. #endif
  13156. source.Expression
  13157. )
  13158. );
  13159. }
  13160. /// <summary>
  13161. /// 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.
  13162. /// </summary>
  13163. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13164. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13165. /// <param name="selector">A transform function to apply to each element.</param>
  13166. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13167. /// <exception cref="T:System.ArgumentNullException">
  13168. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13169. /// <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>
  13170. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13171. public static IQbservable<int?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int?>> selector)
  13172. {
  13173. if (source == null)
  13174. throw new ArgumentNullException("source");
  13175. if (selector == null)
  13176. throw new ArgumentNullException("selector");
  13177. return source.Provider.CreateQuery<int?>(
  13178. Expression.Call(
  13179. null,
  13180. #if CRIPPLED_REFLECTION
  13181. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int?>>))),
  13182. #else
  13183. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13184. #endif
  13185. source.Expression,
  13186. selector
  13187. )
  13188. );
  13189. }
  13190. /// <summary>
  13191. /// 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.
  13192. /// </summary>
  13193. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13194. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13195. /// <param name="selector">A transform function to apply to each element.</param>
  13196. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13197. /// <exception cref="T:System.ArgumentNullException">
  13198. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13199. /// <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>
  13200. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13201. public static IQbservable<long?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long?>> selector)
  13202. {
  13203. if (source == null)
  13204. throw new ArgumentNullException("source");
  13205. if (selector == null)
  13206. throw new ArgumentNullException("selector");
  13207. return source.Provider.CreateQuery<long?>(
  13208. Expression.Call(
  13209. null,
  13210. #if CRIPPLED_REFLECTION
  13211. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long?>>))),
  13212. #else
  13213. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13214. #endif
  13215. source.Expression,
  13216. selector
  13217. )
  13218. );
  13219. }
  13220. /// <summary>
  13221. /// 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.
  13222. /// </summary>
  13223. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13224. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13225. /// <param name="selector">A transform function to apply to each element.</param>
  13226. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13227. /// <exception cref="T:System.ArgumentNullException">
  13228. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13229. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13230. public static IQbservable<double> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double>> selector)
  13231. {
  13232. if (source == null)
  13233. throw new ArgumentNullException("source");
  13234. if (selector == null)
  13235. throw new ArgumentNullException("selector");
  13236. return source.Provider.CreateQuery<double>(
  13237. Expression.Call(
  13238. null,
  13239. #if CRIPPLED_REFLECTION
  13240. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double>>))),
  13241. #else
  13242. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13243. #endif
  13244. source.Expression,
  13245. selector
  13246. )
  13247. );
  13248. }
  13249. /// <summary>
  13250. /// 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.
  13251. /// </summary>
  13252. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13253. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13254. /// <param name="selector">A transform function to apply to each element.</param>
  13255. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13256. /// <exception cref="T:System.ArgumentNullException">
  13257. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13258. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13259. public static IQbservable<float> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float>> selector)
  13260. {
  13261. if (source == null)
  13262. throw new ArgumentNullException("source");
  13263. if (selector == null)
  13264. throw new ArgumentNullException("selector");
  13265. return source.Provider.CreateQuery<float>(
  13266. Expression.Call(
  13267. null,
  13268. #if CRIPPLED_REFLECTION
  13269. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float>>))),
  13270. #else
  13271. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13272. #endif
  13273. source.Expression,
  13274. selector
  13275. )
  13276. );
  13277. }
  13278. /// <summary>
  13279. /// 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.
  13280. /// </summary>
  13281. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13282. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13283. /// <param name="selector">A transform function to apply to each element.</param>
  13284. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13285. /// <exception cref="T:System.ArgumentNullException">
  13286. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13287. /// <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>
  13288. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13289. public static IQbservable<decimal> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal>> selector)
  13290. {
  13291. if (source == null)
  13292. throw new ArgumentNullException("source");
  13293. if (selector == null)
  13294. throw new ArgumentNullException("selector");
  13295. return source.Provider.CreateQuery<decimal>(
  13296. Expression.Call(
  13297. null,
  13298. #if CRIPPLED_REFLECTION
  13299. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal>>))),
  13300. #else
  13301. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13302. #endif
  13303. source.Expression,
  13304. selector
  13305. )
  13306. );
  13307. }
  13308. /// <summary>
  13309. /// 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.
  13310. /// </summary>
  13311. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13312. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13313. /// <param name="selector">A transform function to apply to each element.</param>
  13314. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13315. /// <exception cref="T:System.ArgumentNullException">
  13316. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13317. /// <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>
  13318. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13319. public static IQbservable<int> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int>> selector)
  13320. {
  13321. if (source == null)
  13322. throw new ArgumentNullException("source");
  13323. if (selector == null)
  13324. throw new ArgumentNullException("selector");
  13325. return source.Provider.CreateQuery<int>(
  13326. Expression.Call(
  13327. null,
  13328. #if CRIPPLED_REFLECTION
  13329. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int>>))),
  13330. #else
  13331. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13332. #endif
  13333. source.Expression,
  13334. selector
  13335. )
  13336. );
  13337. }
  13338. /// <summary>
  13339. /// 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.
  13340. /// </summary>
  13341. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13342. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13343. /// <param name="selector">A transform function to apply to each element.</param>
  13344. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13345. /// <exception cref="T:System.ArgumentNullException">
  13346. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13347. /// <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>
  13348. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13349. public static IQbservable<long> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long>> selector)
  13350. {
  13351. if (source == null)
  13352. throw new ArgumentNullException("source");
  13353. if (selector == null)
  13354. throw new ArgumentNullException("selector");
  13355. return source.Provider.CreateQuery<long>(
  13356. Expression.Call(
  13357. null,
  13358. #if CRIPPLED_REFLECTION
  13359. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long>>))),
  13360. #else
  13361. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13362. #endif
  13363. source.Expression,
  13364. selector
  13365. )
  13366. );
  13367. }
  13368. /// <summary>
  13369. /// 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.
  13370. /// </summary>
  13371. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13372. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13373. /// <param name="selector">A transform function to apply to each element.</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" /> or <paramref name="selector" /> 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<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double?>> selector)
  13379. {
  13380. if (source == null)
  13381. throw new ArgumentNullException("source");
  13382. if (selector == null)
  13383. throw new ArgumentNullException("selector");
  13384. return source.Provider.CreateQuery<double?>(
  13385. Expression.Call(
  13386. null,
  13387. #if CRIPPLED_REFLECTION
  13388. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double?>>))),
  13389. #else
  13390. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13391. #endif
  13392. source.Expression,
  13393. selector
  13394. )
  13395. );
  13396. }
  13397. /// <summary>
  13398. /// 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.
  13399. /// </summary>
  13400. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13401. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13402. /// <param name="selector">A transform function to apply to each element.</param>
  13403. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13404. /// <exception cref="T:System.ArgumentNullException">
  13405. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13406. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13407. public static IQbservable<float?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float?>> selector)
  13408. {
  13409. if (source == null)
  13410. throw new ArgumentNullException("source");
  13411. if (selector == null)
  13412. throw new ArgumentNullException("selector");
  13413. return source.Provider.CreateQuery<float?>(
  13414. Expression.Call(
  13415. null,
  13416. #if CRIPPLED_REFLECTION
  13417. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float?>>))),
  13418. #else
  13419. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13420. #endif
  13421. source.Expression,
  13422. selector
  13423. )
  13424. );
  13425. }
  13426. /// <summary>
  13427. /// 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.
  13428. /// </summary>
  13429. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13430. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13431. /// <param name="selector">A transform function to apply to each element.</param>
  13432. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13433. /// <exception cref="T:System.ArgumentNullException">
  13434. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13435. /// <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>
  13436. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13437. public static IQbservable<decimal?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal?>> selector)
  13438. {
  13439. if (source == null)
  13440. throw new ArgumentNullException("source");
  13441. if (selector == null)
  13442. throw new ArgumentNullException("selector");
  13443. return source.Provider.CreateQuery<decimal?>(
  13444. Expression.Call(
  13445. null,
  13446. #if CRIPPLED_REFLECTION
  13447. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal?>>))),
  13448. #else
  13449. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13450. #endif
  13451. source.Expression,
  13452. selector
  13453. )
  13454. );
  13455. }
  13456. /// <summary>
  13457. /// Transforms an observable sequence of observable sequences into an observable sequence
  13458. /// producing values only from the most recent observable sequence.
  13459. /// Each time a new inner observable sequence is received, unsubscribe from the
  13460. /// previous inner observable sequence.
  13461. /// </summary>
  13462. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  13463. /// <param name="sources">Observable sequence of inner observable sequences.</param>
  13464. /// <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>
  13465. /// <exception cref="T:System.ArgumentNullException">
  13466. /// <paramref name="sources" /> is null.</exception>
  13467. public static IQbservable<TSource> Switch<TSource>(this IQbservable<IObservable<TSource>> sources)
  13468. {
  13469. if (sources == null)
  13470. throw new ArgumentNullException("sources");
  13471. return sources.Provider.CreateQuery<TSource>(
  13472. Expression.Call(
  13473. null,
  13474. #if CRIPPLED_REFLECTION
  13475. InfoOf(() => Qbservable.Switch<TSource>(default(IQbservable<IObservable<TSource>>))),
  13476. #else
  13477. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13478. #endif
  13479. sources.Expression
  13480. )
  13481. );
  13482. }
  13483. #if !NO_TPL
  13484. /// <summary>
  13485. /// Transforms an observable sequence of tasks into an observable sequence
  13486. /// producing values only from the most recent observable sequence.
  13487. /// Each time a new task is received, the previous task's result is ignored.
  13488. /// </summary>
  13489. /// <typeparam name="TSource">The type of the results produced by the source tasks.</typeparam>
  13490. /// <param name="sources">Observable sequence of tasks.</param>
  13491. /// <returns>The observable sequence that at any point in time produces the result of the most recent task that has been received.</returns>
  13492. /// <exception cref="T:System.ArgumentNullException">
  13493. /// <paramref name="sources" /> is null.</exception>
  13494. /// <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>
  13495. public static IQbservable<TSource> Switch<TSource>(this IQbservable<Task<TSource>> sources)
  13496. {
  13497. if (sources == null)
  13498. throw new ArgumentNullException("sources");
  13499. return sources.Provider.CreateQuery<TSource>(
  13500. Expression.Call(
  13501. null,
  13502. #if CRIPPLED_REFLECTION
  13503. InfoOf(() => Qbservable.Switch<TSource>(default(IQbservable<Task<TSource>>))),
  13504. #else
  13505. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13506. #endif
  13507. sources.Expression
  13508. )
  13509. );
  13510. }
  13511. #endif
  13512. /// <summary>
  13513. /// Synchronizes the observable sequence such that observer notifications cannot be delivered concurrently.
  13514. /// This overload is useful to "fix" an observable sequence that exhibits concurrent callbacks on individual observers, which is invalid behavior for the query processor.
  13515. /// </summary>
  13516. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13517. /// <param name="source">Source sequence.</param>
  13518. /// <returns>The source sequence whose outgoing calls to observers are synchronized.</returns>
  13519. /// <exception cref="T:System.ArgumentNullException">
  13520. /// <paramref name="source" /> is null.</exception>
  13521. /// <remarks>
  13522. /// It's invalid behavior - according to the observer grammar - for a sequence to exhibit concurrent callbacks on a given observer.
  13523. /// This operator can be used to "fix" a source that doesn't conform to this rule.
  13524. /// </remarks>
  13525. public static IQbservable<TSource> Synchronize<TSource>(this IQbservable<TSource> source)
  13526. {
  13527. if (source == null)
  13528. throw new ArgumentNullException("source");
  13529. return source.Provider.CreateQuery<TSource>(
  13530. Expression.Call(
  13531. null,
  13532. #if CRIPPLED_REFLECTION
  13533. InfoOf(() => Qbservable.Synchronize<TSource>(default(IQbservable<TSource>))),
  13534. #else
  13535. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13536. #endif
  13537. source.Expression
  13538. )
  13539. );
  13540. }
  13541. /// <summary>
  13542. /// Synchronizes the observable sequence such that observer notifications cannot be delivered concurrently, using the specified gate object.
  13543. /// 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.
  13544. /// </summary>
  13545. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13546. /// <param name="source">Source sequence.</param>
  13547. /// <param name="gate">Gate object to synchronize each observer call on.</param>
  13548. /// <returns>The source sequence whose outgoing calls to observers are synchronized on the given gate object.</returns>
  13549. /// <exception cref="T:System.ArgumentNullException">
  13550. /// <paramref name="source" /> or <paramref name="gate" /> is null.</exception>
  13551. public static IQbservable<TSource> Synchronize<TSource>(this IQbservable<TSource> source, object gate)
  13552. {
  13553. if (source == null)
  13554. throw new ArgumentNullException("source");
  13555. if (gate == null)
  13556. throw new ArgumentNullException("gate");
  13557. return source.Provider.CreateQuery<TSource>(
  13558. Expression.Call(
  13559. null,
  13560. #if CRIPPLED_REFLECTION
  13561. InfoOf(() => Qbservable.Synchronize<TSource>(default(IQbservable<TSource>), default(object))),
  13562. #else
  13563. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13564. #endif
  13565. source.Expression,
  13566. Expression.Constant(gate, typeof(object))
  13567. )
  13568. );
  13569. }
  13570. /// <summary>
  13571. /// Returns a specified number of contiguous elements from the start of an observable sequence.
  13572. /// </summary>
  13573. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13574. /// <param name="source">The sequence to take elements from.</param>
  13575. /// <param name="count">The number of elements to return.</param>
  13576. /// <returns>An observable sequence that contains the specified number of elements from the start of the input sequence.</returns>
  13577. /// <exception cref="T:System.ArgumentNullException">
  13578. /// <paramref name="source" /> is null.</exception>
  13579. /// <exception cref="T:System.ArgumentOutOfRangeException">
  13580. /// <paramref name="count" /> is less than zero.</exception>
  13581. public static IQbservable<TSource> Take<TSource>(this IQbservable<TSource> source, int count)
  13582. {
  13583. if (source == null)
  13584. throw new ArgumentNullException("source");
  13585. return source.Provider.CreateQuery<TSource>(
  13586. Expression.Call(
  13587. null,
  13588. #if CRIPPLED_REFLECTION
  13589. InfoOf(() => Qbservable.Take<TSource>(default(IQbservable<TSource>), default(int))),
  13590. #else
  13591. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13592. #endif
  13593. source.Expression,
  13594. Expression.Constant(count, typeof(int))
  13595. )
  13596. );
  13597. }
  13598. /// <summary>
  13599. /// 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).
  13600. /// </summary>
  13601. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13602. /// <param name="source">The sequence to take elements from.</param>
  13603. /// <param name="count">The number of elements to return.</param>
  13604. /// <param name="scheduler">Scheduler used to produce an OnCompleted message in case <paramref name="count">count</paramref> is set to 0.</param>
  13605. /// <returns>An observable sequence that contains the specified number of elements from the start of the input sequence.</returns>
  13606. /// <exception cref="T:System.ArgumentNullException">
  13607. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13608. /// <exception cref="T:System.ArgumentOutOfRangeException">
  13609. /// <paramref name="count" /> is less than zero.</exception>
  13610. public static IQbservable<TSource> Take<TSource>(this IQbservable<TSource> source, int count, IScheduler scheduler)
  13611. {
  13612. if (source == null)
  13613. throw new ArgumentNullException("source");
  13614. if (scheduler == null)
  13615. throw new ArgumentNullException("scheduler");
  13616. return source.Provider.CreateQuery<TSource>(
  13617. Expression.Call(
  13618. null,
  13619. #if CRIPPLED_REFLECTION
  13620. InfoOf(() => Qbservable.Take<TSource>(default(IQbservable<TSource>), default(int), default(IScheduler))),
  13621. #else
  13622. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13623. #endif
  13624. source.Expression,
  13625. Expression.Constant(count, typeof(int)),
  13626. Expression.Constant(scheduler, typeof(IScheduler))
  13627. )
  13628. );
  13629. }
  13630. /// <summary>
  13631. /// Takes elements for the specified duration from the start of the observable source sequence.
  13632. /// </summary>
  13633. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13634. /// <param name="source">Source sequence to take elements from.</param>
  13635. /// <param name="duration">Duration for taking elements from the start of the sequence.</param>
  13636. /// <returns>An observable sequence with the elements taken during the specified duration from the start of the source sequence.</returns>
  13637. /// <exception cref="T:System.ArgumentNullException">
  13638. /// <paramref name="source" /> is null.</exception>
  13639. /// <exception cref="T:System.ArgumentOutOfRangeException">
  13640. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  13641. /// <remarks>
  13642. /// Specifying a TimeSpan.Zero value for <paramref name="duration" /> doesn't guarantee an empty sequence will be returned. This is a side-effect
  13643. /// of the asynchrony introduced by the scheduler, where the action that stops forwarding callbacks from the source sequence may not execute
  13644. /// immediately, despite the TimeSpan.Zero due time.
  13645. /// </remarks>
  13646. public static IQbservable<TSource> Take<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  13647. {
  13648. if (source == null)
  13649. throw new ArgumentNullException("source");
  13650. return source.Provider.CreateQuery<TSource>(
  13651. Expression.Call(
  13652. null,
  13653. #if CRIPPLED_REFLECTION
  13654. InfoOf(() => Qbservable.Take<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  13655. #else
  13656. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13657. #endif
  13658. source.Expression,
  13659. Expression.Constant(duration, typeof(TimeSpan))
  13660. )
  13661. );
  13662. }
  13663. /// <summary>
  13664. /// Takes elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers.
  13665. /// </summary>
  13666. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13667. /// <param name="source">Source sequence to take elements from.</param>
  13668. /// <param name="duration">Duration for taking elements from the start of the sequence.</param>
  13669. /// <param name="scheduler">Scheduler to run the timer on.</param>
  13670. /// <returns>An observable sequence with the elements taken during the specified duration from the start of the source sequence.</returns>
  13671. /// <exception cref="T:System.ArgumentNullException">
  13672. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13673. /// <exception cref="T:System.ArgumentOutOfRangeException">
  13674. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  13675. /// <remarks>
  13676. /// Specifying a TimeSpan.Zero value for <paramref name="duration" /> doesn't guarantee an empty sequence will be returned. This is a side-effect
  13677. /// of the asynchrony introduced by the scheduler, where the action that stops forwarding callbacks from the source sequence may not execute
  13678. /// immediately, despite the TimeSpan.Zero due time.
  13679. /// </remarks>
  13680. public static IQbservable<TSource> Take<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  13681. {
  13682. if (source == null)
  13683. throw new ArgumentNullException("source");
  13684. if (scheduler == null)
  13685. throw new ArgumentNullException("scheduler");
  13686. return source.Provider.CreateQuery<TSource>(
  13687. Expression.Call(
  13688. null,
  13689. #if CRIPPLED_REFLECTION
  13690. InfoOf(() => Qbservable.Take<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  13691. #else
  13692. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13693. #endif
  13694. source.Expression,
  13695. Expression.Constant(duration, typeof(TimeSpan)),
  13696. Expression.Constant(scheduler, typeof(IScheduler))
  13697. )
  13698. );
  13699. }
  13700. /// <summary>
  13701. /// Returns a specified number of contiguous elements from the end of an observable sequence.
  13702. /// </summary>
  13703. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13704. /// <param name="source">Source sequence.</param>
  13705. /// <param name="count">Number of elements to take from the end of the source sequence.</param>
  13706. /// <returns>An observable sequence containing the specified number of elements from the end of the source sequence.</returns>
  13707. /// <exception cref="T:System.ArgumentNullException">
  13708. /// <paramref name="source" /> is null.</exception>
  13709. /// <exception cref="T:System.ArgumentOutOfRangeException">
  13710. /// <paramref name="count" /> is less than zero.</exception>
  13711. /// <remarks>
  13712. /// This operator accumulates a buffer with a length enough to store elements <paramref name="count" /> elements. Upon completion of
  13713. /// the source sequence, this buffer is drained on the result sequence. This causes the elements to be delayed.
  13714. /// </remarks>
  13715. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, int count)
  13716. {
  13717. if (source == null)
  13718. throw new ArgumentNullException("source");
  13719. return source.Provider.CreateQuery<TSource>(
  13720. Expression.Call(
  13721. null,
  13722. #if CRIPPLED_REFLECTION
  13723. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(int))),
  13724. #else
  13725. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13726. #endif
  13727. source.Expression,
  13728. Expression.Constant(count, typeof(int))
  13729. )
  13730. );
  13731. }
  13732. /// <summary>
  13733. /// Returns a specified number of contiguous elements from the end of an observable sequence, using the specified scheduler to drain the queue.
  13734. /// </summary>
  13735. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13736. /// <param name="source">Source sequence.</param>
  13737. /// <param name="count">Number of elements to take from the end of the source sequence.</param>
  13738. /// <param name="scheduler">Scheduler used to drain the queue upon completion of the source sequence.</param>
  13739. /// <returns>An observable sequence containing the specified number of elements from the end of the source sequence.</returns>
  13740. /// <exception cref="T:System.ArgumentNullException">
  13741. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13742. /// <exception cref="T:System.ArgumentOutOfRangeException">
  13743. /// <paramref name="count" /> is less than zero.</exception>
  13744. /// <remarks>
  13745. /// This operator accumulates a buffer with a length enough to store elements <paramref name="count" /> elements. Upon completion of
  13746. /// the source sequence, this buffer is drained on the result sequence. This causes the elements to be delayed.
  13747. /// </remarks>
  13748. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, int count, IScheduler scheduler)
  13749. {
  13750. if (source == null)
  13751. throw new ArgumentNullException("source");
  13752. if (scheduler == null)
  13753. throw new ArgumentNullException("scheduler");
  13754. return source.Provider.CreateQuery<TSource>(
  13755. Expression.Call(
  13756. null,
  13757. #if CRIPPLED_REFLECTION
  13758. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(int), default(IScheduler))),
  13759. #else
  13760. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13761. #endif
  13762. source.Expression,
  13763. Expression.Constant(count, typeof(int)),
  13764. Expression.Constant(scheduler, typeof(IScheduler))
  13765. )
  13766. );
  13767. }
  13768. /// <summary>
  13769. /// Returns elements within the specified duration from the end of the observable source sequence.
  13770. /// </summary>
  13771. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13772. /// <param name="source">Source sequence to take elements from.</param>
  13773. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  13774. /// <returns>An observable sequence with the elements taken during the specified duration from the end of the source sequence.</returns>
  13775. /// <exception cref="T:System.ArgumentNullException">
  13776. /// <paramref name="source" /> is null.</exception>
  13777. /// <exception cref="T:System.ArgumentOutOfRangeException">
  13778. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  13779. /// <remarks>
  13780. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  13781. /// the source sequence. Upon completion of the source sequence, this buffer is drained on the result sequence. This causes the result elements
  13782. /// to be delayed with <paramref name="duration" />.
  13783. /// </remarks>
  13784. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  13785. {
  13786. if (source == null)
  13787. throw new ArgumentNullException("source");
  13788. return source.Provider.CreateQuery<TSource>(
  13789. Expression.Call(
  13790. null,
  13791. #if CRIPPLED_REFLECTION
  13792. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  13793. #else
  13794. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13795. #endif
  13796. source.Expression,
  13797. Expression.Constant(duration, typeof(TimeSpan))
  13798. )
  13799. );
  13800. }
  13801. /// <summary>
  13802. /// Returns elements within the specified duration from the end of the observable source sequence, using the specified scheduler to run timers.
  13803. /// </summary>
  13804. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13805. /// <param name="source">Source sequence to take elements from.</param>
  13806. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  13807. /// <param name="scheduler">Scheduler to run the timer on.</param>
  13808. /// <returns>An observable sequence with the elements taken during the specified duration from the end of the source sequence.</returns>
  13809. /// <exception cref="T:System.ArgumentNullException">
  13810. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13811. /// <exception cref="T:System.ArgumentOutOfRangeException">
  13812. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  13813. /// <remarks>
  13814. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  13815. /// the source sequence. Upon completion of the source sequence, this buffer is drained on the result sequence. This causes the result elements
  13816. /// to be delayed with <paramref name="duration" />.
  13817. /// </remarks>
  13818. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  13819. {
  13820. if (source == null)
  13821. throw new ArgumentNullException("source");
  13822. if (scheduler == null)
  13823. throw new ArgumentNullException("scheduler");
  13824. return source.Provider.CreateQuery<TSource>(
  13825. Expression.Call(
  13826. null,
  13827. #if CRIPPLED_REFLECTION
  13828. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  13829. #else
  13830. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13831. #endif
  13832. source.Expression,
  13833. Expression.Constant(duration, typeof(TimeSpan)),
  13834. Expression.Constant(scheduler, typeof(IScheduler))
  13835. )
  13836. );
  13837. }
  13838. /// <summary>
  13839. /// 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.
  13840. /// </summary>
  13841. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13842. /// <param name="source">Source sequence to take elements from.</param>
  13843. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  13844. /// <param name="timerScheduler">Scheduler to run the timer on.</param>
  13845. /// <param name="loopScheduler">Scheduler to drain the collected elements.</param>
  13846. /// <returns>An observable sequence with the elements taken during the specified duration from the end of the source sequence.</returns>
  13847. /// <exception cref="T:System.ArgumentNullException">
  13848. /// <paramref name="source" /> or <paramref name="timerScheduler" /> or <paramref name="loopScheduler" /> is null.</exception>
  13849. /// <exception cref="T:System.ArgumentOutOfRangeException">
  13850. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  13851. /// <remarks>
  13852. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  13853. /// the source sequence. Upon completion of the source sequence, this buffer is drained on the result sequence. This causes the result elements
  13854. /// to be delayed with <paramref name="duration" />.
  13855. /// </remarks>
  13856. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler timerScheduler, IScheduler loopScheduler)
  13857. {
  13858. if (source == null)
  13859. throw new ArgumentNullException("source");
  13860. if (timerScheduler == null)
  13861. throw new ArgumentNullException("timerScheduler");
  13862. if (loopScheduler == null)
  13863. throw new ArgumentNullException("loopScheduler");
  13864. return source.Provider.CreateQuery<TSource>(
  13865. Expression.Call(
  13866. null,
  13867. #if CRIPPLED_REFLECTION
  13868. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler), default(IScheduler))),
  13869. #else
  13870. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13871. #endif
  13872. source.Expression,
  13873. Expression.Constant(duration, typeof(TimeSpan)),
  13874. Expression.Constant(timerScheduler, typeof(IScheduler)),
  13875. Expression.Constant(loopScheduler, typeof(IScheduler))
  13876. )
  13877. );
  13878. }
  13879. /// <summary>
  13880. /// Returns a list with the specified number of contiguous elements from the end of an observable sequence.
  13881. /// </summary>
  13882. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13883. /// <param name="source">Source sequence.</param>
  13884. /// <param name="count">Number of elements to take from the end of the source sequence.</param>
  13885. /// <returns>An observable sequence containing a single list with the specified number of elements from the end of the source sequence.</returns>
  13886. /// <exception cref="T:System.ArgumentNullException">
  13887. /// <paramref name="source" /> is null.</exception>
  13888. /// <exception cref="T:System.ArgumentOutOfRangeException">
  13889. /// <paramref name="count" /> is less than zero.</exception>
  13890. /// <remarks>
  13891. /// This operator accumulates a buffer with a length enough to store <paramref name="count" /> elements. Upon completion of the
  13892. /// source sequence, this buffer is produced on the result sequence.
  13893. /// </remarks>
  13894. public static IQbservable<IList<TSource>> TakeLastBuffer<TSource>(this IQbservable<TSource> source, int count)
  13895. {
  13896. if (source == null)
  13897. throw new ArgumentNullException("source");
  13898. return source.Provider.CreateQuery<IList<TSource>>(
  13899. Expression.Call(
  13900. null,
  13901. #if CRIPPLED_REFLECTION
  13902. InfoOf(() => Qbservable.TakeLastBuffer<TSource>(default(IQbservable<TSource>), default(int))),
  13903. #else
  13904. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13905. #endif
  13906. source.Expression,
  13907. Expression.Constant(count, typeof(int))
  13908. )
  13909. );
  13910. }
  13911. /// <summary>
  13912. /// Returns a list with the elements within the specified duration from the end of the observable source sequence.
  13913. /// </summary>
  13914. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13915. /// <param name="source">Source sequence to take elements from.</param>
  13916. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  13917. /// <returns>An observable sequence containing a single list with the elements taken during the specified duration from the end of the source sequence.</returns>
  13918. /// <exception cref="T:System.ArgumentNullException">
  13919. /// <paramref name="source" /> is null.</exception>
  13920. /// <exception cref="T:System.ArgumentOutOfRangeException">
  13921. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  13922. /// <remarks>
  13923. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  13924. /// the source sequence. Upon completion of the source sequence, this buffer is produced on the result sequence.
  13925. /// </remarks>
  13926. public static IQbservable<IList<TSource>> TakeLastBuffer<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  13927. {
  13928. if (source == null)
  13929. throw new ArgumentNullException("source");
  13930. return source.Provider.CreateQuery<IList<TSource>>(
  13931. Expression.Call(
  13932. null,
  13933. #if CRIPPLED_REFLECTION
  13934. InfoOf(() => Qbservable.TakeLastBuffer<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  13935. #else
  13936. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13937. #endif
  13938. source.Expression,
  13939. Expression.Constant(duration, typeof(TimeSpan))
  13940. )
  13941. );
  13942. }
  13943. /// <summary>
  13944. /// 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.
  13945. /// </summary>
  13946. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13947. /// <param name="source">Source sequence to take elements from.</param>
  13948. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  13949. /// <param name="scheduler">Scheduler to run the timer on.</param>
  13950. /// <returns>An observable sequence containing a single list with the elements taken during the specified duration from the end of the source sequence.</returns>
  13951. /// <exception cref="T:System.ArgumentNullException">
  13952. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13953. /// <exception cref="T:System.ArgumentOutOfRangeException">
  13954. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  13955. /// <remarks>
  13956. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  13957. /// the source sequence. Upon completion of the source sequence, this buffer is produced on the result sequence.
  13958. /// </remarks>
  13959. public static IQbservable<IList<TSource>> TakeLastBuffer<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  13960. {
  13961. if (source == null)
  13962. throw new ArgumentNullException("source");
  13963. if (scheduler == null)
  13964. throw new ArgumentNullException("scheduler");
  13965. return source.Provider.CreateQuery<IList<TSource>>(
  13966. Expression.Call(
  13967. null,
  13968. #if CRIPPLED_REFLECTION
  13969. InfoOf(() => Qbservable.TakeLastBuffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  13970. #else
  13971. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13972. #endif
  13973. source.Expression,
  13974. Expression.Constant(duration, typeof(TimeSpan)),
  13975. Expression.Constant(scheduler, typeof(IScheduler))
  13976. )
  13977. );
  13978. }
  13979. /// <summary>
  13980. /// Takes elements for the specified duration until the specified end time.
  13981. /// </summary>
  13982. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13983. /// <param name="source">Source sequence to take elements from.</param>
  13984. /// <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>
  13985. /// <returns>An observable sequence with the elements taken until the specified end time.</returns>
  13986. /// <exception cref="T:System.ArgumentNullException">
  13987. /// <paramref name="source" /> is null.</exception>
  13988. public static IQbservable<TSource> TakeUntil<TSource>(this IQbservable<TSource> source, DateTimeOffset endTime)
  13989. {
  13990. if (source == null)
  13991. throw new ArgumentNullException("source");
  13992. return source.Provider.CreateQuery<TSource>(
  13993. Expression.Call(
  13994. null,
  13995. #if CRIPPLED_REFLECTION
  13996. InfoOf(() => Qbservable.TakeUntil<TSource>(default(IQbservable<TSource>), default(DateTimeOffset))),
  13997. #else
  13998. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13999. #endif
  14000. source.Expression,
  14001. Expression.Constant(endTime, typeof(DateTimeOffset))
  14002. )
  14003. );
  14004. }
  14005. /// <summary>
  14006. /// Takes elements for the specified duration until the specified end time, using the specified scheduler to run timers.
  14007. /// </summary>
  14008. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14009. /// <param name="source">Source sequence to take elements from.</param>
  14010. /// <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>
  14011. /// <param name="scheduler">Scheduler to run the timer on.</param>
  14012. /// <returns>An observable sequence with the elements taken until the specified end time.</returns>
  14013. /// <exception cref="T:System.ArgumentNullException">
  14014. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14015. public static IQbservable<TSource> TakeUntil<TSource>(this IQbservable<TSource> source, DateTimeOffset endTime, IScheduler scheduler)
  14016. {
  14017. if (source == null)
  14018. throw new ArgumentNullException("source");
  14019. if (scheduler == null)
  14020. throw new ArgumentNullException("scheduler");
  14021. return source.Provider.CreateQuery<TSource>(
  14022. Expression.Call(
  14023. null,
  14024. #if CRIPPLED_REFLECTION
  14025. InfoOf(() => Qbservable.TakeUntil<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IScheduler))),
  14026. #else
  14027. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14028. #endif
  14029. source.Expression,
  14030. Expression.Constant(endTime, typeof(DateTimeOffset)),
  14031. Expression.Constant(scheduler, typeof(IScheduler))
  14032. )
  14033. );
  14034. }
  14035. /// <summary>
  14036. /// Returns the elements from the source observable sequence until the other observable sequence produces an element.
  14037. /// </summary>
  14038. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14039. /// <typeparam name="TOther">The type of the elements in the other sequence that indicates the end of take behavior.</typeparam>
  14040. /// <param name="source">Source sequence to propagate elements for.</param>
  14041. /// <param name="other">Observable sequence that terminates propagation of elements of the source sequence.</param>
  14042. /// <returns>An observable sequence containing the elements of the source sequence up to the point the other sequence interrupted further propagation.</returns>
  14043. /// <exception cref="T:System.ArgumentNullException">
  14044. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  14045. public static IQbservable<TSource> TakeUntil<TSource, TOther>(this IQbservable<TSource> source, IObservable<TOther> other)
  14046. {
  14047. if (source == null)
  14048. throw new ArgumentNullException("source");
  14049. if (other == null)
  14050. throw new ArgumentNullException("other");
  14051. return source.Provider.CreateQuery<TSource>(
  14052. Expression.Call(
  14053. null,
  14054. #if CRIPPLED_REFLECTION
  14055. InfoOf(() => Qbservable.TakeUntil<TSource, TOther>(default(IQbservable<TSource>), default(IObservable<TOther>))),
  14056. #else
  14057. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)),
  14058. #endif
  14059. source.Expression,
  14060. GetSourceExpression(other)
  14061. )
  14062. );
  14063. }
  14064. /// <summary>
  14065. /// Returns elements from an observable sequence as long as a specified condition is true.
  14066. /// </summary>
  14067. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14068. /// <param name="source">A sequence to return elements from.</param>
  14069. /// <param name="predicate">A function to test each element for a condition.</param>
  14070. /// <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>
  14071. /// <exception cref="T:System.ArgumentNullException">
  14072. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  14073. public static IQbservable<TSource> TakeWhile<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  14074. {
  14075. if (source == null)
  14076. throw new ArgumentNullException("source");
  14077. if (predicate == null)
  14078. throw new ArgumentNullException("predicate");
  14079. return source.Provider.CreateQuery<TSource>(
  14080. Expression.Call(
  14081. null,
  14082. #if CRIPPLED_REFLECTION
  14083. InfoOf(() => Qbservable.TakeWhile<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  14084. #else
  14085. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14086. #endif
  14087. source.Expression,
  14088. predicate
  14089. )
  14090. );
  14091. }
  14092. /// <summary>
  14093. /// Returns elements from an observable sequence as long as a specified condition is true.
  14094. /// The element's index is used in the logic of the predicate function.
  14095. /// </summary>
  14096. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14097. /// <param name="source">A sequence to return elements from.</param>
  14098. /// <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>
  14099. /// <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>
  14100. /// <exception cref="T:System.ArgumentNullException">
  14101. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  14102. public static IQbservable<TSource> TakeWhile<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int, bool>> predicate)
  14103. {
  14104. if (source == null)
  14105. throw new ArgumentNullException("source");
  14106. if (predicate == null)
  14107. throw new ArgumentNullException("predicate");
  14108. return source.Provider.CreateQuery<TSource>(
  14109. Expression.Call(
  14110. null,
  14111. #if CRIPPLED_REFLECTION
  14112. InfoOf(() => Qbservable.TakeWhile<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, bool>>))),
  14113. #else
  14114. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14115. #endif
  14116. source.Expression,
  14117. predicate
  14118. )
  14119. );
  14120. }
  14121. /// <summary>
  14122. /// Ignores elements from an observable sequence which are followed by another element within a specified relative time duration.
  14123. /// </summary>
  14124. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14125. /// <param name="source">Source sequence to throttle.</param>
  14126. /// <param name="dueTime">Throttling duration for each element.</param>
  14127. /// <returns>The throttled sequence.</returns>
  14128. /// <exception cref="T:System.ArgumentNullException">
  14129. /// <paramref name="source" /> is null.</exception>
  14130. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14131. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14132. /// <remarks>
  14133. /// <para>
  14134. /// This operator throttles the source sequence by holding on to each element for the duration specified in <paramref name="dueTime" />. If another
  14135. /// element is produced within this time window, the element is dropped and a new timer is started for the current element, repeating this whole
  14136. /// process. For streams that never have gaps larger than or equal to <paramref name="dueTime" /> between elements, the resulting stream won't
  14137. /// produce any elements. In order to reduce the volume of a stream whilst guaranteeing the periodic production of elements, consider using the
  14138. /// Observable.Sample set of operators.
  14139. /// </para>
  14140. /// <para>
  14141. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing throttling timers to be scheduled
  14142. /// 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
  14143. /// asynchrony introduced by the scheduler, where the action to forward the current element may not execute immediately, despite the TimeSpan.Zero
  14144. /// due time. In such cases, the next element may arrive before the scheduler gets a chance to run the throttling action.
  14145. /// </para>
  14146. /// </remarks>
  14147. public static IQbservable<TSource> Throttle<TSource>(this IQbservable<TSource> source, TimeSpan dueTime)
  14148. {
  14149. if (source == null)
  14150. throw new ArgumentNullException("source");
  14151. return source.Provider.CreateQuery<TSource>(
  14152. Expression.Call(
  14153. null,
  14154. #if CRIPPLED_REFLECTION
  14155. InfoOf(() => Qbservable.Throttle<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  14156. #else
  14157. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14158. #endif
  14159. source.Expression,
  14160. Expression.Constant(dueTime, typeof(TimeSpan))
  14161. )
  14162. );
  14163. }
  14164. /// <summary>
  14165. /// 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.
  14166. /// </summary>
  14167. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14168. /// <param name="source">Source sequence to throttle.</param>
  14169. /// <param name="dueTime">Throttling duration for each element.</param>
  14170. /// <param name="scheduler">Scheduler to run the throttle timers on.</param>
  14171. /// <returns>The throttled sequence.</returns>
  14172. /// <exception cref="T:System.ArgumentNullException">
  14173. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14174. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14175. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14176. /// <remarks>
  14177. /// <para>
  14178. /// This operator throttles the source sequence by holding on to each element for the duration specified in <paramref name="dueTime" />. If another
  14179. /// element is produced within this time window, the element is dropped and a new timer is started for the current element, repeating this whole
  14180. /// process. For streams that never have gaps larger than or equal to <paramref name="dueTime" /> between elements, the resulting stream won't
  14181. /// produce any elements. In order to reduce the volume of a stream whilst guaranteeing the periodic production of elements, consider using the
  14182. /// Observable.Sample set of operators.
  14183. /// </para>
  14184. /// <para>
  14185. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing throttling timers to be scheduled
  14186. /// 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
  14187. /// asynchrony introduced by the scheduler, where the action to forward the current element may not execute immediately, despite the TimeSpan.Zero
  14188. /// due time. In such cases, the next element may arrive before the scheduler gets a chance to run the throttling action.
  14189. /// </para>
  14190. /// </remarks>
  14191. public static IQbservable<TSource> Throttle<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IScheduler scheduler)
  14192. {
  14193. if (source == null)
  14194. throw new ArgumentNullException("source");
  14195. if (scheduler == null)
  14196. throw new ArgumentNullException("scheduler");
  14197. return source.Provider.CreateQuery<TSource>(
  14198. Expression.Call(
  14199. null,
  14200. #if CRIPPLED_REFLECTION
  14201. InfoOf(() => Qbservable.Throttle<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  14202. #else
  14203. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14204. #endif
  14205. source.Expression,
  14206. Expression.Constant(dueTime, typeof(TimeSpan)),
  14207. Expression.Constant(scheduler, typeof(IScheduler))
  14208. )
  14209. );
  14210. }
  14211. /// <summary>
  14212. /// Ignores elements from an observable sequence which are followed by another value within a computed throttle duration.
  14213. /// </summary>
  14214. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14215. /// <typeparam name="TThrottle">The type of the elements in the throttle sequences selected for each element in the source sequence.</typeparam>
  14216. /// <param name="source">Source sequence to throttle.</param>
  14217. /// <param name="throttleDurationSelector">Selector function to retrieve a sequence indicating the throttle duration for each given element.</param>
  14218. /// <returns>The throttled sequence.</returns>
  14219. /// <exception cref="T:System.ArgumentNullException">
  14220. /// <paramref name="source" /> or <paramref name="throttleDurationSelector" /> is null.</exception>
  14221. /// <remarks>
  14222. /// This operator throttles the source sequence by holding on to each element for the duration denoted by <paramref name="throttleDurationSelector" />.
  14223. /// 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
  14224. /// whole process. For streams where the duration computed by applying the <paramref name="throttleDurationSelector" /> to each element overlaps with
  14225. /// the occurrence of the successor element, the resulting stream won't produce any elements. In order to reduce the volume of a stream whilst
  14226. /// guaranteeing the periodic production of elements, consider using the Observable.Sample set of operators.
  14227. /// </remarks>
  14228. public static IQbservable<TSource> Throttle<TSource, TThrottle>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TThrottle>>> throttleDurationSelector)
  14229. {
  14230. if (source == null)
  14231. throw new ArgumentNullException("source");
  14232. if (throttleDurationSelector == null)
  14233. throw new ArgumentNullException("throttleDurationSelector");
  14234. return source.Provider.CreateQuery<TSource>(
  14235. Expression.Call(
  14236. null,
  14237. #if CRIPPLED_REFLECTION
  14238. InfoOf(() => Qbservable.Throttle<TSource, TThrottle>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TThrottle>>>))),
  14239. #else
  14240. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TThrottle)),
  14241. #endif
  14242. source.Expression,
  14243. throttleDurationSelector
  14244. )
  14245. );
  14246. }
  14247. /// <summary>
  14248. /// Returns an observable sequence that terminates with an exception.
  14249. /// </summary>
  14250. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  14251. /// <typeparam name="TResult">The type used for the IObservable&lt;T&gt; type parameter of the resulting sequence.</typeparam>
  14252. /// <param name="exception">Exception object used for the sequence's termination.</param>
  14253. /// <returns>The observable sequence that terminates exceptionally with the specified exception object.</returns>
  14254. /// <exception cref="T:System.ArgumentNullException">
  14255. /// <paramref name="exception" /> is null.</exception>
  14256. public static IQbservable<TResult> Throw<TResult>(this IQbservableProvider provider, Exception exception)
  14257. {
  14258. if (provider == null)
  14259. throw new ArgumentNullException("provider");
  14260. if (exception == null)
  14261. throw new ArgumentNullException("exception");
  14262. return provider.CreateQuery<TResult>(
  14263. Expression.Call(
  14264. null,
  14265. #if CRIPPLED_REFLECTION
  14266. InfoOf(() => Qbservable.Throw<TResult>(default(IQbservableProvider), default(Exception))),
  14267. #else
  14268. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  14269. #endif
  14270. Expression.Constant(provider, typeof(IQbservableProvider)),
  14271. Expression.Constant(exception, typeof(Exception))
  14272. )
  14273. );
  14274. }
  14275. /// <summary>
  14276. /// Returns an observable sequence that terminates with an exception, using the specified scheduler to send out the single OnError message.
  14277. /// </summary>
  14278. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  14279. /// <typeparam name="TResult">The type used for the IObservable&lt;T&gt; type parameter of the resulting sequence.</typeparam>
  14280. /// <param name="exception">Exception object used for the sequence's termination.</param>
  14281. /// <param name="scheduler">Scheduler to send the exceptional termination call on.</param>
  14282. /// <returns>The observable sequence that terminates exceptionally with the specified exception object.</returns>
  14283. /// <exception cref="T:System.ArgumentNullException">
  14284. /// <paramref name="exception" /> or <paramref name="scheduler" /> is null.</exception>
  14285. public static IQbservable<TResult> Throw<TResult>(this IQbservableProvider provider, Exception exception, IScheduler scheduler)
  14286. {
  14287. if (provider == null)
  14288. throw new ArgumentNullException("provider");
  14289. if (exception == null)
  14290. throw new ArgumentNullException("exception");
  14291. if (scheduler == null)
  14292. throw new ArgumentNullException("scheduler");
  14293. return provider.CreateQuery<TResult>(
  14294. Expression.Call(
  14295. null,
  14296. #if CRIPPLED_REFLECTION
  14297. InfoOf(() => Qbservable.Throw<TResult>(default(IQbservableProvider), default(Exception), default(IScheduler))),
  14298. #else
  14299. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  14300. #endif
  14301. Expression.Constant(provider, typeof(IQbservableProvider)),
  14302. Expression.Constant(exception, typeof(Exception)),
  14303. Expression.Constant(scheduler, typeof(IScheduler))
  14304. )
  14305. );
  14306. }
  14307. /// <summary>
  14308. /// Returns an observable sequence that terminates with an exception, using the specified scheduler to send out the single OnError message.
  14309. /// </summary>
  14310. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  14311. /// <typeparam name="TResult">The type used for the IObservable&lt;T&gt; type parameter of the resulting sequence.</typeparam>
  14312. /// <param name="exception">Exception object used for the sequence's termination.</param>
  14313. /// <param name="scheduler">Scheduler to send the exceptional termination call on.</param>
  14314. /// <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>
  14315. /// <returns>The observable sequence that terminates exceptionally with the specified exception object.</returns>
  14316. /// <exception cref="T:System.ArgumentNullException">
  14317. /// <paramref name="exception" /> or <paramref name="scheduler" /> is null.</exception>
  14318. public static IQbservable<TResult> Throw<TResult>(this IQbservableProvider provider, Exception exception, IScheduler scheduler, TResult witness)
  14319. {
  14320. if (provider == null)
  14321. throw new ArgumentNullException("provider");
  14322. if (exception == null)
  14323. throw new ArgumentNullException("exception");
  14324. if (scheduler == null)
  14325. throw new ArgumentNullException("scheduler");
  14326. return provider.CreateQuery<TResult>(
  14327. Expression.Call(
  14328. null,
  14329. #if CRIPPLED_REFLECTION
  14330. InfoOf(() => Qbservable.Throw<TResult>(default(IQbservableProvider), default(Exception), default(IScheduler), default(TResult))),
  14331. #else
  14332. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  14333. #endif
  14334. Expression.Constant(provider, typeof(IQbservableProvider)),
  14335. Expression.Constant(exception, typeof(Exception)),
  14336. Expression.Constant(scheduler, typeof(IScheduler)),
  14337. Expression.Constant(witness, typeof(TResult))
  14338. )
  14339. );
  14340. }
  14341. /// <summary>
  14342. /// Returns an observable sequence that terminates with an exception.
  14343. /// </summary>
  14344. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  14345. /// <typeparam name="TResult">The type used for the IObservable&lt;T&gt; type parameter of the resulting sequence.</typeparam>
  14346. /// <param name="exception">Exception object used for the sequence's termination.</param>
  14347. /// <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>
  14348. /// <returns>The observable sequence that terminates exceptionally with the specified exception object.</returns>
  14349. /// <exception cref="T:System.ArgumentNullException">
  14350. /// <paramref name="exception" /> is null.</exception>
  14351. public static IQbservable<TResult> Throw<TResult>(this IQbservableProvider provider, Exception exception, TResult witness)
  14352. {
  14353. if (provider == null)
  14354. throw new ArgumentNullException("provider");
  14355. if (exception == null)
  14356. throw new ArgumentNullException("exception");
  14357. return provider.CreateQuery<TResult>(
  14358. Expression.Call(
  14359. null,
  14360. #if CRIPPLED_REFLECTION
  14361. InfoOf(() => Qbservable.Throw<TResult>(default(IQbservableProvider), default(Exception), default(TResult))),
  14362. #else
  14363. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  14364. #endif
  14365. Expression.Constant(provider, typeof(IQbservableProvider)),
  14366. Expression.Constant(exception, typeof(Exception)),
  14367. Expression.Constant(witness, typeof(TResult))
  14368. )
  14369. );
  14370. }
  14371. /// <summary>
  14372. /// Records the time interval between consecutive elements in an observable sequence.
  14373. /// </summary>
  14374. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14375. /// <param name="source">Source sequence to record time intervals for.</param>
  14376. /// <returns>An observable sequence with time interval information on elements.</returns>
  14377. /// <exception cref="T:System.ArgumentNullException">
  14378. /// <paramref name="source" /> is null.</exception>
  14379. public static IQbservable<TimeInterval<TSource>> TimeInterval<TSource>(this IQbservable<TSource> source)
  14380. {
  14381. if (source == null)
  14382. throw new ArgumentNullException("source");
  14383. return source.Provider.CreateQuery<TimeInterval<TSource>>(
  14384. Expression.Call(
  14385. null,
  14386. #if CRIPPLED_REFLECTION
  14387. InfoOf(() => Qbservable.TimeInterval<TSource>(default(IQbservable<TSource>))),
  14388. #else
  14389. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14390. #endif
  14391. source.Expression
  14392. )
  14393. );
  14394. }
  14395. /// <summary>
  14396. /// Records the time interval between consecutive elements in an observable sequence, using the specified scheduler to compute time intervals.
  14397. /// </summary>
  14398. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14399. /// <param name="source">Source sequence to record time intervals for.</param>
  14400. /// <param name="scheduler">Scheduler used to compute time intervals.</param>
  14401. /// <returns>An observable sequence with time interval information on elements.</returns>
  14402. /// <exception cref="T:System.ArgumentNullException">
  14403. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14404. public static IQbservable<TimeInterval<TSource>> TimeInterval<TSource>(this IQbservable<TSource> source, IScheduler scheduler)
  14405. {
  14406. if (source == null)
  14407. throw new ArgumentNullException("source");
  14408. if (scheduler == null)
  14409. throw new ArgumentNullException("scheduler");
  14410. return source.Provider.CreateQuery<TimeInterval<TSource>>(
  14411. Expression.Call(
  14412. null,
  14413. #if CRIPPLED_REFLECTION
  14414. InfoOf(() => Qbservable.TimeInterval<TSource>(default(IQbservable<TSource>), default(IScheduler))),
  14415. #else
  14416. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14417. #endif
  14418. source.Expression,
  14419. Expression.Constant(scheduler, typeof(IScheduler))
  14420. )
  14421. );
  14422. }
  14423. /// <summary>
  14424. /// Applies a timeout policy to the observable sequence based on an absolute time.
  14425. /// If the sequence doesn't terminate before the specified absolute due time, a TimeoutException is propagated to the observer.
  14426. /// </summary>
  14427. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14428. /// <param name="source">Source sequence to perform a timeout for.</param>
  14429. /// <param name="dueTime">Time when a timeout occurs. If this value is less than or equal to DateTimeOffset.UtcNow, the timeout occurs immediately.</param>
  14430. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  14431. /// <exception cref="T:System.ArgumentNullException">
  14432. /// <paramref name="source" /> is null.</exception>
  14433. /// <exception cref="T:System.TimeoutException">(Asynchronous) If the sequence hasn't terminated before <paramref name="dueTime" />.</exception>
  14434. /// <remarks>
  14435. /// 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})" />
  14436. /// 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
  14437. /// 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.
  14438. /// </remarks>
  14439. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime)
  14440. {
  14441. if (source == null)
  14442. throw new ArgumentNullException("source");
  14443. return source.Provider.CreateQuery<TSource>(
  14444. Expression.Call(
  14445. null,
  14446. #if CRIPPLED_REFLECTION
  14447. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(DateTimeOffset))),
  14448. #else
  14449. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14450. #endif
  14451. source.Expression,
  14452. Expression.Constant(dueTime, typeof(DateTimeOffset))
  14453. )
  14454. );
  14455. }
  14456. /// <summary>
  14457. /// Applies a timeout policy to the observable sequence based on an absolute time.
  14458. /// 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.
  14459. /// </summary>
  14460. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  14461. /// <param name="source">Source sequence to perform a timeout for.</param>
  14462. /// <param name="dueTime">Time when a timeout occurs. If this value is less than or equal to DateTimeOffset.UtcNow, the timeout occurs immediately.</param>
  14463. /// <param name="other">Sequence to return in case of a timeout.</param>
  14464. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  14465. /// <exception cref="T:System.ArgumentNullException">
  14466. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  14467. /// <remarks>
  14468. /// 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})" />
  14469. /// 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
  14470. /// 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.
  14471. /// </remarks>
  14472. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime, IObservable<TSource> other)
  14473. {
  14474. if (source == null)
  14475. throw new ArgumentNullException("source");
  14476. if (other == null)
  14477. throw new ArgumentNullException("other");
  14478. return source.Provider.CreateQuery<TSource>(
  14479. Expression.Call(
  14480. null,
  14481. #if CRIPPLED_REFLECTION
  14482. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IObservable<TSource>))),
  14483. #else
  14484. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14485. #endif
  14486. source.Expression,
  14487. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  14488. GetSourceExpression(other)
  14489. )
  14490. );
  14491. }
  14492. /// <summary>
  14493. /// Applies a timeout policy to the observable sequence based on an absolute time, using the specified scheduler to run timeout timers.
  14494. /// 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.
  14495. /// </summary>
  14496. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  14497. /// <param name="source">Source sequence to perform a timeout for.</param>
  14498. /// <param name="dueTime">Time when a timeout occurs. If this value is less than or equal to DateTimeOffset.UtcNow, the timeout occurs immediately.</param>
  14499. /// <param name="other">Sequence to return in case of a timeout.</param>
  14500. /// <param name="scheduler">Scheduler to run the timeout timers on.</param>
  14501. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  14502. /// <exception cref="T:System.ArgumentNullException">
  14503. /// <paramref name="source" /> or <paramref name="other" /> or <paramref name="scheduler" /> is null.</exception>
  14504. /// <remarks>
  14505. /// 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})" />
  14506. /// 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
  14507. /// 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.
  14508. /// </remarks>
  14509. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime, IObservable<TSource> other, IScheduler scheduler)
  14510. {
  14511. if (source == null)
  14512. throw new ArgumentNullException("source");
  14513. if (other == null)
  14514. throw new ArgumentNullException("other");
  14515. if (scheduler == null)
  14516. throw new ArgumentNullException("scheduler");
  14517. return source.Provider.CreateQuery<TSource>(
  14518. Expression.Call(
  14519. null,
  14520. #if CRIPPLED_REFLECTION
  14521. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IObservable<TSource>), default(IScheduler))),
  14522. #else
  14523. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14524. #endif
  14525. source.Expression,
  14526. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  14527. GetSourceExpression(other),
  14528. Expression.Constant(scheduler, typeof(IScheduler))
  14529. )
  14530. );
  14531. }
  14532. /// <summary>
  14533. /// Applies a timeout policy to the observable sequence based on an absolute time, using the specified scheduler to run timeout timers.
  14534. /// If the sequence doesn't terminate before the specified absolute due time, a TimeoutException is propagated to the observer.
  14535. /// </summary>
  14536. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14537. /// <param name="source">Source sequence to perform a timeout for.</param>
  14538. /// <param name="dueTime">Time when a timeout occurs. If this value is less than or equal to DateTimeOffset.UtcNow, the timeout occurs immediately.</param>
  14539. /// <param name="scheduler">Scheduler to run the timeout timers on.</param>
  14540. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  14541. /// <exception cref="T:System.ArgumentNullException">
  14542. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14543. /// <exception cref="T:System.TimeoutException">(Asynchronous) If the sequence hasn't terminated before <paramref name="dueTime" />.</exception>
  14544. /// <remarks>
  14545. /// 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})" />
  14546. /// 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
  14547. /// 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.
  14548. /// </remarks>
  14549. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime, IScheduler scheduler)
  14550. {
  14551. if (source == null)
  14552. throw new ArgumentNullException("source");
  14553. if (scheduler == null)
  14554. throw new ArgumentNullException("scheduler");
  14555. return source.Provider.CreateQuery<TSource>(
  14556. Expression.Call(
  14557. null,
  14558. #if CRIPPLED_REFLECTION
  14559. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IScheduler))),
  14560. #else
  14561. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14562. #endif
  14563. source.Expression,
  14564. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  14565. Expression.Constant(scheduler, typeof(IScheduler))
  14566. )
  14567. );
  14568. }
  14569. /// <summary>
  14570. /// Applies a timeout policy for each element in the observable sequence.
  14571. /// If the next element isn't received within the specified timeout duration starting from its predecessor, a TimeoutException is propagated to the observer.
  14572. /// </summary>
  14573. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14574. /// <param name="source">Source sequence to perform a timeout for.</param>
  14575. /// <param name="dueTime">Maximum duration between values before a timeout occurs.</param>
  14576. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  14577. /// <exception cref="T:System.ArgumentNullException">
  14578. /// <paramref name="source" /> is null.</exception>
  14579. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14580. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14581. /// <exception cref="T:System.TimeoutException">(Asynchronous) If no element is produced within <paramref name="dueTime" /> from the previous element.</exception>
  14582. /// <remarks>
  14583. /// <para>
  14584. /// 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})" />
  14585. /// 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
  14586. /// 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.
  14587. /// </para>
  14588. /// <para>
  14589. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing timeout timers to be scheduled that are due
  14590. /// 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
  14591. /// 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
  14592. /// arrive before the scheduler gets a chance to run the timeout action.
  14593. /// </para>
  14594. /// </remarks>
  14595. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, TimeSpan dueTime)
  14596. {
  14597. if (source == null)
  14598. throw new ArgumentNullException("source");
  14599. return source.Provider.CreateQuery<TSource>(
  14600. Expression.Call(
  14601. null,
  14602. #if CRIPPLED_REFLECTION
  14603. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  14604. #else
  14605. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14606. #endif
  14607. source.Expression,
  14608. Expression.Constant(dueTime, typeof(TimeSpan))
  14609. )
  14610. );
  14611. }
  14612. /// <summary>
  14613. /// Applies a timeout policy for each element in the observable sequence.
  14614. /// 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.
  14615. /// </summary>
  14616. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  14617. /// <param name="source">Source sequence to perform a timeout for.</param>
  14618. /// <param name="dueTime">Maximum duration between values before a timeout occurs.</param>
  14619. /// <param name="other">Sequence to return in case of a timeout.</param>
  14620. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  14621. /// <exception cref="T:System.ArgumentNullException">
  14622. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  14623. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14624. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14625. /// <remarks>
  14626. /// <para>
  14627. /// 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})" />
  14628. /// 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
  14629. /// 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.
  14630. /// </para>
  14631. /// <para>
  14632. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing timeout timers to be scheduled that are due
  14633. /// 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
  14634. /// 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
  14635. /// arrive before the scheduler gets a chance to run the timeout action.
  14636. /// </para>
  14637. /// </remarks>
  14638. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IObservable<TSource> other)
  14639. {
  14640. if (source == null)
  14641. throw new ArgumentNullException("source");
  14642. if (other == null)
  14643. throw new ArgumentNullException("other");
  14644. return source.Provider.CreateQuery<TSource>(
  14645. Expression.Call(
  14646. null,
  14647. #if CRIPPLED_REFLECTION
  14648. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IObservable<TSource>))),
  14649. #else
  14650. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14651. #endif
  14652. source.Expression,
  14653. Expression.Constant(dueTime, typeof(TimeSpan)),
  14654. GetSourceExpression(other)
  14655. )
  14656. );
  14657. }
  14658. /// <summary>
  14659. /// Applies a timeout policy for each element in the observable sequence, using the specified scheduler to run timeout timers.
  14660. /// 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.
  14661. /// </summary>
  14662. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  14663. /// <param name="source">Source sequence to perform a timeout for.</param>
  14664. /// <param name="dueTime">Maximum duration between values before a timeout occurs.</param>
  14665. /// <param name="other">Sequence to return in case of a timeout.</param>
  14666. /// <param name="scheduler">Scheduler to run the timeout timers on.</param>
  14667. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  14668. /// <exception cref="T:System.ArgumentNullException">
  14669. /// <paramref name="source" /> or <paramref name="other" /> or <paramref name="scheduler" /> is null.</exception>
  14670. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14671. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14672. /// <remarks>
  14673. /// <para>
  14674. /// 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})" />
  14675. /// 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
  14676. /// 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.
  14677. /// </para>
  14678. /// <para>
  14679. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing timeout timers to be scheduled that are due
  14680. /// 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
  14681. /// 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
  14682. /// arrive before the scheduler gets a chance to run the timeout action.
  14683. /// </para>
  14684. /// </remarks>
  14685. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IObservable<TSource> other, IScheduler scheduler)
  14686. {
  14687. if (source == null)
  14688. throw new ArgumentNullException("source");
  14689. if (other == null)
  14690. throw new ArgumentNullException("other");
  14691. if (scheduler == null)
  14692. throw new ArgumentNullException("scheduler");
  14693. return source.Provider.CreateQuery<TSource>(
  14694. Expression.Call(
  14695. null,
  14696. #if CRIPPLED_REFLECTION
  14697. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IObservable<TSource>), default(IScheduler))),
  14698. #else
  14699. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14700. #endif
  14701. source.Expression,
  14702. Expression.Constant(dueTime, typeof(TimeSpan)),
  14703. GetSourceExpression(other),
  14704. Expression.Constant(scheduler, typeof(IScheduler))
  14705. )
  14706. );
  14707. }
  14708. /// <summary>
  14709. /// Applies a timeout policy for each element in the observable sequence, using the specified scheduler to run timeout timers.
  14710. /// If the next element isn't received within the specified timeout duration starting from its predecessor, a TimeoutException is propagated to the observer.
  14711. /// </summary>
  14712. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14713. /// <param name="source">Source sequence to perform a timeout for.</param>
  14714. /// <param name="dueTime">Maximum duration between values before a timeout occurs.</param>
  14715. /// <param name="scheduler">Scheduler to run the timeout timers on.</param>
  14716. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  14717. /// <exception cref="T:System.ArgumentNullException">
  14718. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14719. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14720. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14721. /// <exception cref="T:System.TimeoutException">(Asynchronous) If no element is produced within <paramref name="dueTime" /> from the previous element.</exception>
  14722. /// <remarks>
  14723. /// <para>
  14724. /// In case you only want to timeout on the first element, consider using the <see cref="M:System.Reactive.Linq.Observable.Amb``1(System.IObservable{``0},System.IObservable{``0})" />
  14725. /// operator applied to the source sequence and a delayed <see cref="M:System.Reactive.Linq.Observable.Throw``1(System.Exception)" /> sequence. Alternatively, the general-purpose overload
  14726. /// of Timeout, <see cref="M:System.Reactive.Linq.Observable.Timeout``2(System.IObservable{``0},System.IObservable{``1},System.Func{``0,System.IObservable{``1}})" /> can be used.
  14727. /// </para>
  14728. /// <para>
  14729. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing timeout timers to be scheduled that are due
  14730. /// 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
  14731. /// 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
  14732. /// arrive before the scheduler gets a chance to run the timeout action.
  14733. /// </para>
  14734. /// </remarks>
  14735. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IScheduler scheduler)
  14736. {
  14737. if (source == null)
  14738. throw new ArgumentNullException("source");
  14739. if (scheduler == null)
  14740. throw new ArgumentNullException("scheduler");
  14741. return source.Provider.CreateQuery<TSource>(
  14742. Expression.Call(
  14743. null,
  14744. #if CRIPPLED_REFLECTION
  14745. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  14746. #else
  14747. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14748. #endif
  14749. source.Expression,
  14750. Expression.Constant(dueTime, typeof(TimeSpan)),
  14751. Expression.Constant(scheduler, typeof(IScheduler))
  14752. )
  14753. );
  14754. }
  14755. /// <summary>
  14756. /// 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.
  14757. /// If the next element isn't received within the computed duration starting from its predecessor, a TimeoutException is propagated to the observer.
  14758. /// </summary>
  14759. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14760. /// <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>
  14761. /// <param name="source">Source sequence to perform a timeout for.</param>
  14762. /// <param name="firstTimeout">Observable sequence that represents the timeout for the first element.</param>
  14763. /// <param name="timeoutDurationSelector">Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.</param>
  14764. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  14765. /// <exception cref="T:System.ArgumentNullException">
  14766. /// <paramref name="source" /> or <paramref name="firstTimeout" /> or <paramref name="timeoutDurationSelector" /> is null.</exception>
  14767. public static IQbservable<TSource> Timeout<TSource, TTimeout>(this IQbservable<TSource> source, IObservable<TTimeout> firstTimeout, Expression<Func<TSource, IObservable<TTimeout>>> timeoutDurationSelector)
  14768. {
  14769. if (source == null)
  14770. throw new ArgumentNullException("source");
  14771. if (firstTimeout == null)
  14772. throw new ArgumentNullException("firstTimeout");
  14773. if (timeoutDurationSelector == null)
  14774. throw new ArgumentNullException("timeoutDurationSelector");
  14775. return source.Provider.CreateQuery<TSource>(
  14776. Expression.Call(
  14777. null,
  14778. #if CRIPPLED_REFLECTION
  14779. InfoOf(() => Qbservable.Timeout<TSource, TTimeout>(default(IQbservable<TSource>), default(IObservable<TTimeout>), default(Expression<Func<TSource, IObservable<TTimeout>>>))),
  14780. #else
  14781. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTimeout)),
  14782. #endif
  14783. source.Expression,
  14784. GetSourceExpression(firstTimeout),
  14785. timeoutDurationSelector
  14786. )
  14787. );
  14788. }
  14789. /// <summary>
  14790. /// 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.
  14791. /// 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.
  14792. /// </summary>
  14793. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  14794. /// <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>
  14795. /// <param name="source">Source sequence to perform a timeout for.</param>
  14796. /// <param name="firstTimeout">Observable sequence that represents the timeout for the first element.</param>
  14797. /// <param name="timeoutDurationSelector">Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.</param>
  14798. /// <param name="other">Sequence to return in case of a timeout.</param>
  14799. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  14800. /// <exception cref="T:System.ArgumentNullException">
  14801. /// <paramref name="source" /> or <paramref name="firstTimeout" /> or <paramref name="timeoutDurationSelector" /> or <paramref name="other" /> is null.</exception>
  14802. public static IQbservable<TSource> Timeout<TSource, TTimeout>(this IQbservable<TSource> source, IObservable<TTimeout> firstTimeout, Expression<Func<TSource, IObservable<TTimeout>>> timeoutDurationSelector, IObservable<TSource> other)
  14803. {
  14804. if (source == null)
  14805. throw new ArgumentNullException("source");
  14806. if (firstTimeout == null)
  14807. throw new ArgumentNullException("firstTimeout");
  14808. if (timeoutDurationSelector == null)
  14809. throw new ArgumentNullException("timeoutDurationSelector");
  14810. if (other == null)
  14811. throw new ArgumentNullException("other");
  14812. return source.Provider.CreateQuery<TSource>(
  14813. Expression.Call(
  14814. null,
  14815. #if CRIPPLED_REFLECTION
  14816. InfoOf(() => Qbservable.Timeout<TSource, TTimeout>(default(IQbservable<TSource>), default(IObservable<TTimeout>), default(Expression<Func<TSource, IObservable<TTimeout>>>), default(IObservable<TSource>))),
  14817. #else
  14818. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTimeout)),
  14819. #endif
  14820. source.Expression,
  14821. GetSourceExpression(firstTimeout),
  14822. timeoutDurationSelector,
  14823. GetSourceExpression(other)
  14824. )
  14825. );
  14826. }
  14827. /// <summary>
  14828. /// Applies a timeout policy to the observable sequence based on a timeout duration computed for each element.
  14829. /// If the next element isn't received within the computed duration starting from its predecessor, a TimeoutException is propagated to the observer.
  14830. /// </summary>
  14831. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14832. /// <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>
  14833. /// <param name="source">Source sequence to perform a timeout for.</param>
  14834. /// <param name="timeoutDurationSelector">Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.</param>
  14835. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  14836. /// <exception cref="T:System.ArgumentNullException">
  14837. /// <paramref name="source" /> or <paramref name="timeoutDurationSelector" /> is null.</exception>
  14838. public static IQbservable<TSource> Timeout<TSource, TTimeout>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TTimeout>>> timeoutDurationSelector)
  14839. {
  14840. if (source == null)
  14841. throw new ArgumentNullException("source");
  14842. if (timeoutDurationSelector == null)
  14843. throw new ArgumentNullException("timeoutDurationSelector");
  14844. return source.Provider.CreateQuery<TSource>(
  14845. Expression.Call(
  14846. null,
  14847. #if CRIPPLED_REFLECTION
  14848. InfoOf(() => Qbservable.Timeout<TSource, TTimeout>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TTimeout>>>))),
  14849. #else
  14850. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTimeout)),
  14851. #endif
  14852. source.Expression,
  14853. timeoutDurationSelector
  14854. )
  14855. );
  14856. }
  14857. /// <summary>
  14858. /// Applies a timeout policy to the observable sequence based on a timeout duration computed for each element.
  14859. /// 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.
  14860. /// </summary>
  14861. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  14862. /// <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>
  14863. /// <param name="source">Source sequence to perform a timeout for.</param>
  14864. /// <param name="timeoutDurationSelector">Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.</param>
  14865. /// <param name="other">Sequence to return in case of a timeout.</param>
  14866. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  14867. /// <exception cref="T:System.ArgumentNullException">
  14868. /// <paramref name="source" /> or <paramref name="timeoutDurationSelector" /> or <paramref name="other" /> is null.</exception>
  14869. public static IQbservable<TSource> Timeout<TSource, TTimeout>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TTimeout>>> timeoutDurationSelector, IObservable<TSource> other)
  14870. {
  14871. if (source == null)
  14872. throw new ArgumentNullException("source");
  14873. if (timeoutDurationSelector == null)
  14874. throw new ArgumentNullException("timeoutDurationSelector");
  14875. if (other == null)
  14876. throw new ArgumentNullException("other");
  14877. return source.Provider.CreateQuery<TSource>(
  14878. Expression.Call(
  14879. null,
  14880. #if CRIPPLED_REFLECTION
  14881. InfoOf(() => Qbservable.Timeout<TSource, TTimeout>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TTimeout>>>), default(IObservable<TSource>))),
  14882. #else
  14883. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTimeout)),
  14884. #endif
  14885. source.Expression,
  14886. timeoutDurationSelector,
  14887. GetSourceExpression(other)
  14888. )
  14889. );
  14890. }
  14891. /// <summary>
  14892. /// Returns an observable sequence that produces a single value at the specified absolute due time.
  14893. /// </summary>
  14894. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  14895. /// <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>
  14896. /// <returns>An observable sequence that produces a value at due time.</returns>
  14897. public static IQbservable<long> Timer(this IQbservableProvider provider, DateTimeOffset dueTime)
  14898. {
  14899. if (provider == null)
  14900. throw new ArgumentNullException("provider");
  14901. return provider.CreateQuery<long>(
  14902. Expression.Call(
  14903. null,
  14904. #if CRIPPLED_REFLECTION
  14905. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(DateTimeOffset))),
  14906. #else
  14907. (MethodInfo)MethodInfo.GetCurrentMethod(),
  14908. #endif
  14909. Expression.Constant(provider, typeof(IQbservableProvider)),
  14910. Expression.Constant(dueTime, typeof(DateTimeOffset))
  14911. )
  14912. );
  14913. }
  14914. /// <summary>
  14915. /// Returns an observable sequence that periodically produces a value starting at the specified initial absolute due time.
  14916. /// </summary>
  14917. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  14918. /// <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>
  14919. /// <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>
  14920. /// <returns>An observable sequence that produces a value at due time and then after each period.</returns>
  14921. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14922. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  14923. public static IQbservable<long> Timer(this IQbservableProvider provider, DateTimeOffset dueTime, TimeSpan period)
  14924. {
  14925. if (provider == null)
  14926. throw new ArgumentNullException("provider");
  14927. return provider.CreateQuery<long>(
  14928. Expression.Call(
  14929. null,
  14930. #if CRIPPLED_REFLECTION
  14931. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(DateTimeOffset), default(TimeSpan))),
  14932. #else
  14933. (MethodInfo)MethodInfo.GetCurrentMethod(),
  14934. #endif
  14935. Expression.Constant(provider, typeof(IQbservableProvider)),
  14936. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  14937. Expression.Constant(period, typeof(TimeSpan))
  14938. )
  14939. );
  14940. }
  14941. /// <summary>
  14942. /// Returns an observable sequence that periodically produces a value starting at the specified initial absolute due time, using the specified scheduler to run timers.
  14943. /// </summary>
  14944. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  14945. /// <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>
  14946. /// <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>
  14947. /// <param name="scheduler">Scheduler to run timers on.</param>
  14948. /// <returns>An observable sequence that produces a value at due time and then after each period.</returns>
  14949. /// <exception cref="T:System.ArgumentOutOfRangeException">
  14950. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  14951. /// <exception cref="T:System.ArgumentNullException">
  14952. /// <paramref name="scheduler" /> is null.</exception>
  14953. public static IQbservable<long> Timer(this IQbservableProvider provider, DateTimeOffset dueTime, TimeSpan period, IScheduler scheduler)
  14954. {
  14955. if (provider == null)
  14956. throw new ArgumentNullException("provider");
  14957. if (scheduler == null)
  14958. throw new ArgumentNullException("scheduler");
  14959. return provider.CreateQuery<long>(
  14960. Expression.Call(
  14961. null,
  14962. #if CRIPPLED_REFLECTION
  14963. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(DateTimeOffset), default(TimeSpan), default(IScheduler))),
  14964. #else
  14965. (MethodInfo)MethodInfo.GetCurrentMethod(),
  14966. #endif
  14967. Expression.Constant(provider, typeof(IQbservableProvider)),
  14968. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  14969. Expression.Constant(period, typeof(TimeSpan)),
  14970. Expression.Constant(scheduler, typeof(IScheduler))
  14971. )
  14972. );
  14973. }
  14974. /// <summary>
  14975. /// Returns an observable sequence that produces a single value at the specified absolute due time, using the specified scheduler to run the timer.
  14976. /// </summary>
  14977. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  14978. /// <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>
  14979. /// <param name="scheduler">Scheduler to run the timer on.</param>
  14980. /// <returns>An observable sequence that produces a value at due time.</returns>
  14981. /// <exception cref="T:System.ArgumentNullException">
  14982. /// <paramref name="scheduler" /> is null.</exception>
  14983. public static IQbservable<long> Timer(this IQbservableProvider provider, DateTimeOffset dueTime, IScheduler scheduler)
  14984. {
  14985. if (provider == null)
  14986. throw new ArgumentNullException("provider");
  14987. if (scheduler == null)
  14988. throw new ArgumentNullException("scheduler");
  14989. return provider.CreateQuery<long>(
  14990. Expression.Call(
  14991. null,
  14992. #if CRIPPLED_REFLECTION
  14993. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(DateTimeOffset), default(IScheduler))),
  14994. #else
  14995. (MethodInfo)MethodInfo.GetCurrentMethod(),
  14996. #endif
  14997. Expression.Constant(provider, typeof(IQbservableProvider)),
  14998. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  14999. Expression.Constant(scheduler, typeof(IScheduler))
  15000. )
  15001. );
  15002. }
  15003. /// <summary>
  15004. /// Returns an observable sequence that produces a single value after the specified relative due time has elapsed.
  15005. /// </summary>
  15006. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  15007. /// <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>
  15008. /// <returns>An observable sequence that produces a value after the due time has elapsed.</returns>
  15009. public static IQbservable<long> Timer(this IQbservableProvider provider, TimeSpan dueTime)
  15010. {
  15011. if (provider == null)
  15012. throw new ArgumentNullException("provider");
  15013. return provider.CreateQuery<long>(
  15014. Expression.Call(
  15015. null,
  15016. #if CRIPPLED_REFLECTION
  15017. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(TimeSpan))),
  15018. #else
  15019. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15020. #endif
  15021. Expression.Constant(provider, typeof(IQbservableProvider)),
  15022. Expression.Constant(dueTime, typeof(TimeSpan))
  15023. )
  15024. );
  15025. }
  15026. /// <summary>
  15027. /// Returns an observable sequence that periodically produces a value after the specified initial relative due time has elapsed.
  15028. /// </summary>
  15029. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  15030. /// <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>
  15031. /// <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>
  15032. /// <returns>An observable sequence that produces a value after due time has elapsed and then after each period.</returns>
  15033. /// <exception cref="T:System.ArgumentOutOfRangeException">
  15034. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  15035. public static IQbservable<long> Timer(this IQbservableProvider provider, TimeSpan dueTime, TimeSpan period)
  15036. {
  15037. if (provider == null)
  15038. throw new ArgumentNullException("provider");
  15039. return provider.CreateQuery<long>(
  15040. Expression.Call(
  15041. null,
  15042. #if CRIPPLED_REFLECTION
  15043. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(TimeSpan), default(TimeSpan))),
  15044. #else
  15045. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15046. #endif
  15047. Expression.Constant(provider, typeof(IQbservableProvider)),
  15048. Expression.Constant(dueTime, typeof(TimeSpan)),
  15049. Expression.Constant(period, typeof(TimeSpan))
  15050. )
  15051. );
  15052. }
  15053. /// <summary>
  15054. /// 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.
  15055. /// </summary>
  15056. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  15057. /// <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>
  15058. /// <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>
  15059. /// <param name="scheduler">Scheduler to run timers on.</param>
  15060. /// <returns>An observable sequence that produces a value after due time has elapsed and then each period.</returns>
  15061. /// <exception cref="T:System.ArgumentOutOfRangeException">
  15062. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  15063. /// <exception cref="T:System.ArgumentNullException">
  15064. /// <paramref name="scheduler" /> is null.</exception>
  15065. public static IQbservable<long> Timer(this IQbservableProvider provider, TimeSpan dueTime, TimeSpan period, IScheduler scheduler)
  15066. {
  15067. if (provider == null)
  15068. throw new ArgumentNullException("provider");
  15069. if (scheduler == null)
  15070. throw new ArgumentNullException("scheduler");
  15071. return provider.CreateQuery<long>(
  15072. Expression.Call(
  15073. null,
  15074. #if CRIPPLED_REFLECTION
  15075. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(TimeSpan), default(TimeSpan), default(IScheduler))),
  15076. #else
  15077. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15078. #endif
  15079. Expression.Constant(provider, typeof(IQbservableProvider)),
  15080. Expression.Constant(dueTime, typeof(TimeSpan)),
  15081. Expression.Constant(period, typeof(TimeSpan)),
  15082. Expression.Constant(scheduler, typeof(IScheduler))
  15083. )
  15084. );
  15085. }
  15086. /// <summary>
  15087. /// 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.
  15088. /// </summary>
  15089. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  15090. /// <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>
  15091. /// <param name="scheduler">Scheduler to run the timer on.</param>
  15092. /// <returns>An observable sequence that produces a value after the due time has elapsed.</returns>
  15093. /// <exception cref="T:System.ArgumentNullException">
  15094. /// <paramref name="scheduler" /> is null.</exception>
  15095. public static IQbservable<long> Timer(this IQbservableProvider provider, TimeSpan dueTime, IScheduler scheduler)
  15096. {
  15097. if (provider == null)
  15098. throw new ArgumentNullException("provider");
  15099. if (scheduler == null)
  15100. throw new ArgumentNullException("scheduler");
  15101. return provider.CreateQuery<long>(
  15102. Expression.Call(
  15103. null,
  15104. #if CRIPPLED_REFLECTION
  15105. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(TimeSpan), default(IScheduler))),
  15106. #else
  15107. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15108. #endif
  15109. Expression.Constant(provider, typeof(IQbservableProvider)),
  15110. Expression.Constant(dueTime, typeof(TimeSpan)),
  15111. Expression.Constant(scheduler, typeof(IScheduler))
  15112. )
  15113. );
  15114. }
  15115. /// <summary>
  15116. /// Timestamps each element in an observable sequence using the local system clock.
  15117. /// </summary>
  15118. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15119. /// <param name="source">Source sequence to timestamp elements for.</param>
  15120. /// <returns>An observable sequence with timestamp information on elements.</returns>
  15121. /// <exception cref="T:System.ArgumentNullException">
  15122. /// <paramref name="source" /> is null.</exception>
  15123. public static IQbservable<Timestamped<TSource>> Timestamp<TSource>(this IQbservable<TSource> source)
  15124. {
  15125. if (source == null)
  15126. throw new ArgumentNullException("source");
  15127. return source.Provider.CreateQuery<Timestamped<TSource>>(
  15128. Expression.Call(
  15129. null,
  15130. #if CRIPPLED_REFLECTION
  15131. InfoOf(() => Qbservable.Timestamp<TSource>(default(IQbservable<TSource>))),
  15132. #else
  15133. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15134. #endif
  15135. source.Expression
  15136. )
  15137. );
  15138. }
  15139. /// <summary>
  15140. /// Timestamp each element in an observable sequence using the clock of the specified scheduler.
  15141. /// </summary>
  15142. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15143. /// <param name="source">Source sequence to timestamp elements for.</param>
  15144. /// <param name="scheduler">Scheduler used to compute timestamps.</param>
  15145. /// <returns>An observable sequence with timestamp information on elements.</returns>
  15146. /// <exception cref="T:System.ArgumentNullException">
  15147. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  15148. public static IQbservable<Timestamped<TSource>> Timestamp<TSource>(this IQbservable<TSource> source, IScheduler scheduler)
  15149. {
  15150. if (source == null)
  15151. throw new ArgumentNullException("source");
  15152. if (scheduler == null)
  15153. throw new ArgumentNullException("scheduler");
  15154. return source.Provider.CreateQuery<Timestamped<TSource>>(
  15155. Expression.Call(
  15156. null,
  15157. #if CRIPPLED_REFLECTION
  15158. InfoOf(() => Qbservable.Timestamp<TSource>(default(IQbservable<TSource>), default(IScheduler))),
  15159. #else
  15160. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15161. #endif
  15162. source.Expression,
  15163. Expression.Constant(scheduler, typeof(IScheduler))
  15164. )
  15165. );
  15166. }
  15167. /// <summary>
  15168. /// Creates an array from an observable sequence.
  15169. /// </summary>
  15170. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15171. /// <param name="source">The source observable sequence to get an array of elements for.</param>
  15172. /// <returns>An observable sequence containing a single element with an array containing all the elements of the source sequence.</returns>
  15173. /// <exception cref="T:System.ArgumentNullException">
  15174. /// <paramref name="source" /> is null.</exception>
  15175. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15176. public static IQbservable<TSource[]> ToArray<TSource>(this IQbservable<TSource> source)
  15177. {
  15178. if (source == null)
  15179. throw new ArgumentNullException("source");
  15180. return source.Provider.CreateQuery<TSource[]>(
  15181. Expression.Call(
  15182. null,
  15183. #if CRIPPLED_REFLECTION
  15184. InfoOf(() => Qbservable.ToArray<TSource>(default(IQbservable<TSource>))),
  15185. #else
  15186. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15187. #endif
  15188. source.Expression
  15189. )
  15190. );
  15191. }
  15192. /// <summary>
  15193. /// Creates a dictionary from an observable sequence according to a specified key selector function.
  15194. /// </summary>
  15195. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15196. /// <typeparam name="TKey">The type of the dictionary key computed for each element in the source sequence.</typeparam>
  15197. /// <param name="source">An observable sequence to create a dictionary for.</param>
  15198. /// <param name="keySelector">A function to extract a key from each element.</param>
  15199. /// <returns>An observable sequence containing a single element with a dictionary mapping unique key values onto the corresponding source sequence's element.</returns>
  15200. /// <exception cref="T:System.ArgumentNullException">
  15201. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  15202. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15203. public static IQbservable<IDictionary<TKey, TSource>> ToDictionary<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  15204. {
  15205. if (source == null)
  15206. throw new ArgumentNullException("source");
  15207. if (keySelector == null)
  15208. throw new ArgumentNullException("keySelector");
  15209. return source.Provider.CreateQuery<IDictionary<TKey, TSource>>(
  15210. Expression.Call(
  15211. null,
  15212. #if CRIPPLED_REFLECTION
  15213. InfoOf(() => Qbservable.ToDictionary<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  15214. #else
  15215. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  15216. #endif
  15217. source.Expression,
  15218. keySelector
  15219. )
  15220. );
  15221. }
  15222. /// <summary>
  15223. /// Creates a dictionary from an observable sequence according to a specified key selector function, and a comparer.
  15224. /// </summary>
  15225. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15226. /// <typeparam name="TKey">The type of the dictionary key computed for each element in the source sequence.</typeparam>
  15227. /// <param name="source">An observable sequence to create a dictionary for.</param>
  15228. /// <param name="keySelector">A function to extract a key from each element.</param>
  15229. /// <param name="comparer">An equality comparer to compare keys.</param>
  15230. /// <returns>An observable sequence containing a single element with a dictionary mapping unique key values onto the corresponding source sequence's element.</returns>
  15231. /// <exception cref="T:System.ArgumentNullException">
  15232. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  15233. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15234. public static IQbservable<IDictionary<TKey, TSource>> ToDictionary<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  15235. {
  15236. if (source == null)
  15237. throw new ArgumentNullException("source");
  15238. if (keySelector == null)
  15239. throw new ArgumentNullException("keySelector");
  15240. if (comparer == null)
  15241. throw new ArgumentNullException("comparer");
  15242. return source.Provider.CreateQuery<IDictionary<TKey, TSource>>(
  15243. Expression.Call(
  15244. null,
  15245. #if CRIPPLED_REFLECTION
  15246. InfoOf(() => Qbservable.ToDictionary<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IEqualityComparer<TKey>))),
  15247. #else
  15248. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  15249. #endif
  15250. source.Expression,
  15251. keySelector,
  15252. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  15253. )
  15254. );
  15255. }
  15256. /// <summary>
  15257. /// Creates a dictionary from an observable sequence according to a specified key selector function, and an element selector function.
  15258. /// </summary>
  15259. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15260. /// <typeparam name="TKey">The type of the dictionary key computed for each element in the source sequence.</typeparam>
  15261. /// <typeparam name="TElement">The type of the dictionary value computed for each element in the source sequence.</typeparam>
  15262. /// <param name="source">An observable sequence to create a dictionary for.</param>
  15263. /// <param name="keySelector">A function to extract a key from each element.</param>
  15264. /// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
  15265. /// <returns>An observable sequence containing a single element with a dictionary mapping unique key values onto the corresponding source sequence's element.</returns>
  15266. /// <exception cref="T:System.ArgumentNullException">
  15267. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> is null.</exception>
  15268. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15269. public static IQbservable<IDictionary<TKey, TElement>> ToDictionary<TSource, TKey, TElement>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector)
  15270. {
  15271. if (source == null)
  15272. throw new ArgumentNullException("source");
  15273. if (keySelector == null)
  15274. throw new ArgumentNullException("keySelector");
  15275. if (elementSelector == null)
  15276. throw new ArgumentNullException("elementSelector");
  15277. return source.Provider.CreateQuery<IDictionary<TKey, TElement>>(
  15278. Expression.Call(
  15279. null,
  15280. #if CRIPPLED_REFLECTION
  15281. InfoOf(() => Qbservable.ToDictionary<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>))),
  15282. #else
  15283. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  15284. #endif
  15285. source.Expression,
  15286. keySelector,
  15287. elementSelector
  15288. )
  15289. );
  15290. }
  15291. /// <summary>
  15292. /// Creates a dictionary from an observable sequence according to a specified key selector function, a comparer, and an element selector function.
  15293. /// </summary>
  15294. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15295. /// <typeparam name="TKey">The type of the dictionary key computed for each element in the source sequence.</typeparam>
  15296. /// <typeparam name="TElement">The type of the dictionary value computed for each element in the source sequence.</typeparam>
  15297. /// <param name="source">An observable sequence to create a dictionary for.</param>
  15298. /// <param name="keySelector">A function to extract a key from each element.</param>
  15299. /// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
  15300. /// <param name="comparer">An equality comparer to compare keys.</param>
  15301. /// <returns>An observable sequence containing a single element with a dictionary mapping unique key values onto the corresponding source sequence's element.</returns>
  15302. /// <exception cref="T:System.ArgumentNullException">
  15303. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="comparer" /> is null.</exception>
  15304. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15305. 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)
  15306. {
  15307. if (source == null)
  15308. throw new ArgumentNullException("source");
  15309. if (keySelector == null)
  15310. throw new ArgumentNullException("keySelector");
  15311. if (elementSelector == null)
  15312. throw new ArgumentNullException("elementSelector");
  15313. if (comparer == null)
  15314. throw new ArgumentNullException("comparer");
  15315. return source.Provider.CreateQuery<IDictionary<TKey, TElement>>(
  15316. Expression.Call(
  15317. null,
  15318. #if CRIPPLED_REFLECTION
  15319. InfoOf(() => Qbservable.ToDictionary<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(IEqualityComparer<TKey>))),
  15320. #else
  15321. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  15322. #endif
  15323. source.Expression,
  15324. keySelector,
  15325. elementSelector,
  15326. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  15327. )
  15328. );
  15329. }
  15330. /// <summary>
  15331. /// Converts an observable sequence to an enumerable sequence.
  15332. /// </summary>
  15333. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15334. /// <param name="source">An observable sequence to convert to an enumerable sequence.</param>
  15335. /// <returns>The enumerable sequence containing the elements in the observable sequence.</returns>
  15336. /// <exception cref="T:System.ArgumentNullException">
  15337. /// <paramref name="source" /> is null.</exception>
  15338. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  15339. public static IQueryable<TSource> ToQueryable<TSource>(this IQbservable<TSource> source)
  15340. {
  15341. if (source == null)
  15342. throw new ArgumentNullException("source");
  15343. return ((IQueryProvider)source.Provider).CreateQuery<TSource>(
  15344. Expression.Call(
  15345. null,
  15346. #if CRIPPLED_REFLECTION
  15347. InfoOf(() => Qbservable.ToQueryable<TSource>(default(IQbservable<TSource>))),
  15348. #else
  15349. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15350. #endif
  15351. source.Expression
  15352. )
  15353. );
  15354. }
  15355. /// <summary>
  15356. /// Creates a list from an observable sequence.
  15357. /// </summary>
  15358. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15359. /// <param name="source">The source observable sequence to get a list of elements for.</param>
  15360. /// <returns>An observable sequence containing a single element with a list containing all the elements of the source sequence.</returns>
  15361. /// <exception cref="T:System.ArgumentNullException">
  15362. /// <paramref name="source" /> is null.</exception>
  15363. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15364. public static IQbservable<IList<TSource>> ToList<TSource>(this IQbservable<TSource> source)
  15365. {
  15366. if (source == null)
  15367. throw new ArgumentNullException("source");
  15368. return source.Provider.CreateQuery<IList<TSource>>(
  15369. Expression.Call(
  15370. null,
  15371. #if CRIPPLED_REFLECTION
  15372. InfoOf(() => Qbservable.ToList<TSource>(default(IQbservable<TSource>))),
  15373. #else
  15374. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15375. #endif
  15376. source.Expression
  15377. )
  15378. );
  15379. }
  15380. /// <summary>
  15381. /// Creates a lookup from an observable sequence according to a specified key selector function.
  15382. /// </summary>
  15383. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15384. /// <typeparam name="TKey">The type of the lookup key computed for each element in the source sequence.</typeparam>
  15385. /// <param name="source">An observable sequence to create a lookup for.</param>
  15386. /// <param name="keySelector">A function to extract a key from each element.</param>
  15387. /// <returns>An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.</returns>
  15388. /// <exception cref="T:System.ArgumentNullException">
  15389. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  15390. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15391. public static IQbservable<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  15392. {
  15393. if (source == null)
  15394. throw new ArgumentNullException("source");
  15395. if (keySelector == null)
  15396. throw new ArgumentNullException("keySelector");
  15397. return source.Provider.CreateQuery<ILookup<TKey, TSource>>(
  15398. Expression.Call(
  15399. null,
  15400. #if CRIPPLED_REFLECTION
  15401. InfoOf(() => Qbservable.ToLookup<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  15402. #else
  15403. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  15404. #endif
  15405. source.Expression,
  15406. keySelector
  15407. )
  15408. );
  15409. }
  15410. /// <summary>
  15411. /// Creates a lookup from an observable sequence according to a specified key selector function, and a comparer.
  15412. /// </summary>
  15413. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15414. /// <typeparam name="TKey">The type of the lookup key computed for each element in the source sequence.</typeparam>
  15415. /// <param name="source">An observable sequence to create a lookup for.</param>
  15416. /// <param name="keySelector">A function to extract a key from each element.</param>
  15417. /// <param name="comparer">An equality comparer to compare keys.</param>
  15418. /// <returns>An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.</returns>
  15419. /// <exception cref="T:System.ArgumentNullException">
  15420. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  15421. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15422. public static IQbservable<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  15423. {
  15424. if (source == null)
  15425. throw new ArgumentNullException("source");
  15426. if (keySelector == null)
  15427. throw new ArgumentNullException("keySelector");
  15428. if (comparer == null)
  15429. throw new ArgumentNullException("comparer");
  15430. return source.Provider.CreateQuery<ILookup<TKey, TSource>>(
  15431. Expression.Call(
  15432. null,
  15433. #if CRIPPLED_REFLECTION
  15434. InfoOf(() => Qbservable.ToLookup<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IEqualityComparer<TKey>))),
  15435. #else
  15436. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  15437. #endif
  15438. source.Expression,
  15439. keySelector,
  15440. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  15441. )
  15442. );
  15443. }
  15444. /// <summary>
  15445. /// Creates a lookup from an observable sequence according to a specified key selector function, and an element selector function.
  15446. /// </summary>
  15447. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15448. /// <typeparam name="TKey">The type of the lookup key computed for each element in the source sequence.</typeparam>
  15449. /// <typeparam name="TElement">The type of the lookup value computed for each element in the source sequence.</typeparam>
  15450. /// <param name="source">An observable sequence to create a lookup for.</param>
  15451. /// <param name="keySelector">A function to extract a key from each element.</param>
  15452. /// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
  15453. /// <returns>An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.</returns>
  15454. /// <exception cref="T:System.ArgumentNullException">
  15455. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> is null.</exception>
  15456. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15457. public static IQbservable<ILookup<TKey, TElement>> ToLookup<TSource, TKey, TElement>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector)
  15458. {
  15459. if (source == null)
  15460. throw new ArgumentNullException("source");
  15461. if (keySelector == null)
  15462. throw new ArgumentNullException("keySelector");
  15463. if (elementSelector == null)
  15464. throw new ArgumentNullException("elementSelector");
  15465. return source.Provider.CreateQuery<ILookup<TKey, TElement>>(
  15466. Expression.Call(
  15467. null,
  15468. #if CRIPPLED_REFLECTION
  15469. InfoOf(() => Qbservable.ToLookup<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>))),
  15470. #else
  15471. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  15472. #endif
  15473. source.Expression,
  15474. keySelector,
  15475. elementSelector
  15476. )
  15477. );
  15478. }
  15479. /// <summary>
  15480. /// Creates a lookup from an observable sequence according to a specified key selector function, a comparer, and an element selector function.
  15481. /// </summary>
  15482. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15483. /// <typeparam name="TKey">The type of the lookup key computed for each element in the source sequence.</typeparam>
  15484. /// <typeparam name="TElement">The type of the lookup value computed for each element in the source sequence.</typeparam>
  15485. /// <param name="source">An observable sequence to create a lookup for.</param>
  15486. /// <param name="keySelector">A function to extract a key from each element.</param>
  15487. /// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
  15488. /// <param name="comparer">An equality comparer to compare keys.</param>
  15489. /// <returns>An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.</returns>
  15490. /// <exception cref="T:System.ArgumentNullException">
  15491. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="comparer" /> is null.</exception>
  15492. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15493. 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)
  15494. {
  15495. if (source == null)
  15496. throw new ArgumentNullException("source");
  15497. if (keySelector == null)
  15498. throw new ArgumentNullException("keySelector");
  15499. if (elementSelector == null)
  15500. throw new ArgumentNullException("elementSelector");
  15501. if (comparer == null)
  15502. throw new ArgumentNullException("comparer");
  15503. return source.Provider.CreateQuery<ILookup<TKey, TElement>>(
  15504. Expression.Call(
  15505. null,
  15506. #if CRIPPLED_REFLECTION
  15507. InfoOf(() => Qbservable.ToLookup<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(IEqualityComparer<TKey>))),
  15508. #else
  15509. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  15510. #endif
  15511. source.Expression,
  15512. keySelector,
  15513. elementSelector,
  15514. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  15515. )
  15516. );
  15517. }
  15518. /// <summary>
  15519. /// Converts an enumerable sequence to an observable sequence.
  15520. /// </summary>
  15521. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  15522. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15523. /// <param name="source">Enumerable sequence to convert to an observable sequence.</param>
  15524. /// <returns>The observable sequence whose elements are pulled from the given enumerable sequence.</returns>
  15525. /// <exception cref="T:System.ArgumentNullException">
  15526. /// <paramref name="source" /> is null.</exception>
  15527. public static IQbservable<TSource> ToObservable<TSource>(this IQbservableProvider provider, IEnumerable<TSource> source)
  15528. {
  15529. if (provider == null)
  15530. throw new ArgumentNullException("provider");
  15531. if (source == null)
  15532. throw new ArgumentNullException("source");
  15533. return provider.CreateQuery<TSource>(
  15534. Expression.Call(
  15535. null,
  15536. #if CRIPPLED_REFLECTION
  15537. InfoOf(() => Qbservable.ToObservable<TSource>(default(IQbservableProvider), default(IEnumerable<TSource>))),
  15538. #else
  15539. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15540. #endif
  15541. Expression.Constant(provider, typeof(IQbservableProvider)),
  15542. GetSourceExpression(source)
  15543. )
  15544. );
  15545. }
  15546. /// <summary>
  15547. /// Converts an enumerable sequence to an observable sequence, using the specified scheduler to run the enumeration loop.
  15548. /// </summary>
  15549. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  15550. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15551. /// <param name="source">Enumerable sequence to convert to an observable sequence.</param>
  15552. /// <param name="scheduler">Scheduler to run the enumeration of the input sequence on.</param>
  15553. /// <returns>The observable sequence whose elements are pulled from the given enumerable sequence.</returns>
  15554. /// <exception cref="T:System.ArgumentNullException">
  15555. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  15556. public static IQbservable<TSource> ToObservable<TSource>(this IQbservableProvider provider, IEnumerable<TSource> source, IScheduler scheduler)
  15557. {
  15558. if (provider == null)
  15559. throw new ArgumentNullException("provider");
  15560. if (source == null)
  15561. throw new ArgumentNullException("source");
  15562. if (scheduler == null)
  15563. throw new ArgumentNullException("scheduler");
  15564. return provider.CreateQuery<TSource>(
  15565. Expression.Call(
  15566. null,
  15567. #if CRIPPLED_REFLECTION
  15568. InfoOf(() => Qbservable.ToObservable<TSource>(default(IQbservableProvider), default(IEnumerable<TSource>), default(IScheduler))),
  15569. #else
  15570. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15571. #endif
  15572. Expression.Constant(provider, typeof(IQbservableProvider)),
  15573. GetSourceExpression(source),
  15574. Expression.Constant(scheduler, typeof(IScheduler))
  15575. )
  15576. );
  15577. }
  15578. /// <summary>
  15579. /// Constructs an observable sequence that depends on a resource object, whose lifetime is tied to the resulting observable sequence's lifetime.
  15580. /// </summary>
  15581. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  15582. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  15583. /// <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>
  15584. /// <param name="resourceFactory">Factory function to obtain a resource object.</param>
  15585. /// <param name="observableFactory">Factory function to obtain an observable sequence that depends on the obtained resource.</param>
  15586. /// <returns>An observable sequence whose lifetime controls the lifetime of the dependent resource object.</returns>
  15587. /// <exception cref="T:System.ArgumentNullException">
  15588. /// <paramref name="resourceFactory" /> or <paramref name="observableFactory" /> is null.</exception>
  15589. public static IQbservable<TResult> Using<TResult, TResource>(this IQbservableProvider provider, Expression<Func<TResource>> resourceFactory, Expression<Func<TResource, IObservable<TResult>>> observableFactory)
  15590. where TResource : IDisposable
  15591. {
  15592. if (provider == null)
  15593. throw new ArgumentNullException("provider");
  15594. if (resourceFactory == null)
  15595. throw new ArgumentNullException("resourceFactory");
  15596. if (observableFactory == null)
  15597. throw new ArgumentNullException("observableFactory");
  15598. return provider.CreateQuery<TResult>(
  15599. Expression.Call(
  15600. null,
  15601. #if CRIPPLED_REFLECTION
  15602. InfoOf(() => Qbservable.Using<TResult, TResource>(default(IQbservableProvider), default(Expression<Func<TResource>>), default(Expression<Func<TResource, IObservable<TResult>>>))),
  15603. #else
  15604. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult), typeof(TResource)),
  15605. #endif
  15606. Expression.Constant(provider, typeof(IQbservableProvider)),
  15607. resourceFactory,
  15608. observableFactory
  15609. )
  15610. );
  15611. }
  15612. #if !NO_TPL
  15613. /// <summary>
  15614. /// 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.
  15615. /// 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.
  15616. /// </summary>
  15617. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  15618. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  15619. /// <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>
  15620. /// <param name="resourceFactoryAsync">Asynchronous factory function to obtain a resource object.</param>
  15621. /// <param name="observableFactoryAsync">Asynchronous factory function to obtain an observable sequence that depends on the obtained resource.</param>
  15622. /// <returns>An observable sequence whose lifetime controls the lifetime of the dependent resource object.</returns>
  15623. /// <exception cref="T:System.ArgumentNullException">
  15624. /// <paramref name="resourceFactoryAsync" /> or <paramref name="observableFactoryAsync" /> is null.</exception>
  15625. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  15626. /// <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>
  15627. public static IQbservable<TResult> Using<TResult, TResource>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<TResource>>> resourceFactoryAsync, Expression<Func<TResource, CancellationToken, Task<IObservable<TResult>>>> observableFactoryAsync)
  15628. where TResource : IDisposable
  15629. {
  15630. if (provider == null)
  15631. throw new ArgumentNullException("provider");
  15632. if (resourceFactoryAsync == null)
  15633. throw new ArgumentNullException("resourceFactoryAsync");
  15634. if (observableFactoryAsync == null)
  15635. throw new ArgumentNullException("observableFactoryAsync");
  15636. return provider.CreateQuery<TResult>(
  15637. Expression.Call(
  15638. null,
  15639. #if CRIPPLED_REFLECTION
  15640. InfoOf(() => Qbservable.Using<TResult, TResource>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<TResource>>>), default(Expression<Func<TResource, CancellationToken, Task<IObservable<TResult>>>>))),
  15641. #else
  15642. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult), typeof(TResource)),
  15643. #endif
  15644. Expression.Constant(provider, typeof(IQbservableProvider)),
  15645. resourceFactoryAsync,
  15646. observableFactoryAsync
  15647. )
  15648. );
  15649. }
  15650. #endif
  15651. /// <summary>
  15652. /// Filters the elements of an observable sequence based on a predicate.
  15653. /// </summary>
  15654. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15655. /// <param name="source">An observable sequence whose elements to filter.</param>
  15656. /// <param name="predicate">A function to test each source element for a condition.</param>
  15657. /// <returns>An observable sequence that contains elements from the input sequence that satisfy the condition.</returns>
  15658. /// <exception cref="T:System.ArgumentNullException">
  15659. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  15660. public static IQbservable<TSource> Where<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  15661. {
  15662. if (source == null)
  15663. throw new ArgumentNullException("source");
  15664. if (predicate == null)
  15665. throw new ArgumentNullException("predicate");
  15666. return source.Provider.CreateQuery<TSource>(
  15667. Expression.Call(
  15668. null,
  15669. #if CRIPPLED_REFLECTION
  15670. InfoOf(() => Qbservable.Where<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  15671. #else
  15672. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15673. #endif
  15674. source.Expression,
  15675. predicate
  15676. )
  15677. );
  15678. }
  15679. /// <summary>
  15680. /// Filters the elements of an observable sequence based on a predicate by incorporating the element's index.
  15681. /// </summary>
  15682. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15683. /// <param name="source">An observable sequence whose elements to filter.</param>
  15684. /// <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>
  15685. /// <returns>An observable sequence that contains elements from the input sequence that satisfy the condition.</returns>
  15686. /// <exception cref="T:System.ArgumentNullException">
  15687. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  15688. public static IQbservable<TSource> Where<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int, bool>> predicate)
  15689. {
  15690. if (source == null)
  15691. throw new ArgumentNullException("source");
  15692. if (predicate == null)
  15693. throw new ArgumentNullException("predicate");
  15694. return source.Provider.CreateQuery<TSource>(
  15695. Expression.Call(
  15696. null,
  15697. #if CRIPPLED_REFLECTION
  15698. InfoOf(() => Qbservable.Where<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, bool>>))),
  15699. #else
  15700. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15701. #endif
  15702. source.Expression,
  15703. predicate
  15704. )
  15705. );
  15706. }
  15707. /// <summary>
  15708. /// 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.
  15709. /// </summary>
  15710. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  15711. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15712. /// <param name="source">Source to repeat as long as the <paramref name="condition" /> function evaluates to true.</param>
  15713. /// <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>
  15714. /// <returns>The observable sequence obtained by concatenating the <paramref name="source" /> sequence as long as the <paramref name="condition" /> holds.</returns>
  15715. /// <exception cref="T:System.ArgumentNullException">
  15716. /// <paramref name="condition" /> or <paramref name="source" /> is null.</exception>
  15717. public static IQbservable<TSource> While<TSource>(this IQbservableProvider provider, Expression<Func<bool>> condition, IObservable<TSource> source)
  15718. {
  15719. if (provider == null)
  15720. throw new ArgumentNullException("provider");
  15721. if (condition == null)
  15722. throw new ArgumentNullException("condition");
  15723. if (source == null)
  15724. throw new ArgumentNullException("source");
  15725. return provider.CreateQuery<TSource>(
  15726. Expression.Call(
  15727. null,
  15728. #if CRIPPLED_REFLECTION
  15729. InfoOf(() => Qbservable.While<TSource>(default(IQbservableProvider), default(Expression<Func<bool>>), default(IObservable<TSource>))),
  15730. #else
  15731. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15732. #endif
  15733. Expression.Constant(provider, typeof(IQbservableProvider)),
  15734. condition,
  15735. GetSourceExpression(source)
  15736. )
  15737. );
  15738. }
  15739. /// <summary>
  15740. /// Projects each element of an observable sequence into consecutive non-overlapping windows which are produced based on element count information.
  15741. /// </summary>
  15742. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  15743. /// <param name="source">Source sequence to produce windows over.</param>
  15744. /// <param name="count">Length of each window.</param>
  15745. /// <returns>An observable sequence of windows.</returns>
  15746. /// <exception cref="T:System.ArgumentNullException">
  15747. /// <paramref name="source" /> is null.</exception>
  15748. /// <exception cref="T:System.ArgumentOutOfRangeException">
  15749. /// <paramref name="count" /> is less than or equal to zero.</exception>
  15750. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, int count)
  15751. {
  15752. if (source == null)
  15753. throw new ArgumentNullException("source");
  15754. return source.Provider.CreateQuery<IObservable<TSource>>(
  15755. Expression.Call(
  15756. null,
  15757. #if CRIPPLED_REFLECTION
  15758. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(int))),
  15759. #else
  15760. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15761. #endif
  15762. source.Expression,
  15763. Expression.Constant(count, typeof(int))
  15764. )
  15765. );
  15766. }
  15767. /// <summary>
  15768. /// Projects each element of an observable sequence into zero or more windows which are produced based on element count information.
  15769. /// </summary>
  15770. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  15771. /// <param name="source">Source sequence to produce windows over.</param>
  15772. /// <param name="count">Length of each window.</param>
  15773. /// <param name="skip">Number of elements to skip between creation of consecutive windows.</param>
  15774. /// <returns>An observable sequence of windows.</returns>
  15775. /// <exception cref="T:System.ArgumentNullException">
  15776. /// <paramref name="source" /> is null.</exception>
  15777. /// <exception cref="T:System.ArgumentOutOfRangeException">
  15778. /// <paramref name="count" /> or <paramref name="skip" /> is less than or equal to zero.</exception>
  15779. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, int count, int skip)
  15780. {
  15781. if (source == null)
  15782. throw new ArgumentNullException("source");
  15783. return source.Provider.CreateQuery<IObservable<TSource>>(
  15784. Expression.Call(
  15785. null,
  15786. #if CRIPPLED_REFLECTION
  15787. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(int), default(int))),
  15788. #else
  15789. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15790. #endif
  15791. source.Expression,
  15792. Expression.Constant(count, typeof(int)),
  15793. Expression.Constant(skip, typeof(int))
  15794. )
  15795. );
  15796. }
  15797. /// <summary>
  15798. /// Projects each element of an observable sequence into consecutive non-overlapping windows which are produced based on timing information.
  15799. /// </summary>
  15800. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  15801. /// <param name="source">Source sequence to produce windows over.</param>
  15802. /// <param name="timeSpan">Length of each window.</param>
  15803. /// <returns>The sequence of windows.</returns>
  15804. /// <exception cref="T:System.ArgumentNullException">
  15805. /// <paramref name="source" /> is null.</exception>
  15806. /// <exception cref="T:System.ArgumentOutOfRangeException">
  15807. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  15808. /// <remarks>
  15809. /// 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.
  15810. /// 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
  15811. /// 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.
  15812. /// </remarks>
  15813. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan)
  15814. {
  15815. if (source == null)
  15816. throw new ArgumentNullException("source");
  15817. return source.Provider.CreateQuery<IObservable<TSource>>(
  15818. Expression.Call(
  15819. null,
  15820. #if CRIPPLED_REFLECTION
  15821. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  15822. #else
  15823. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15824. #endif
  15825. source.Expression,
  15826. Expression.Constant(timeSpan, typeof(TimeSpan))
  15827. )
  15828. );
  15829. }
  15830. /// <summary>
  15831. /// 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.
  15832. /// 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.
  15833. /// </summary>
  15834. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  15835. /// <param name="source">Source sequence to produce windows over.</param>
  15836. /// <param name="timeSpan">Maximum time length of a window.</param>
  15837. /// <param name="count">Maximum element count of a window.</param>
  15838. /// <returns>An observable sequence of windows.</returns>
  15839. /// <exception cref="T:System.ArgumentNullException">
  15840. /// <paramref name="source" /> is null.</exception>
  15841. /// <exception cref="T:System.ArgumentOutOfRangeException">
  15842. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero. -or- <paramref name="count" /> is less than or equal to zero.</exception>
  15843. /// <remarks>
  15844. /// 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.
  15845. /// 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
  15846. /// 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.
  15847. /// </remarks>
  15848. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, int count)
  15849. {
  15850. if (source == null)
  15851. throw new ArgumentNullException("source");
  15852. return source.Provider.CreateQuery<IObservable<TSource>>(
  15853. Expression.Call(
  15854. null,
  15855. #if CRIPPLED_REFLECTION
  15856. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(int))),
  15857. #else
  15858. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15859. #endif
  15860. source.Expression,
  15861. Expression.Constant(timeSpan, typeof(TimeSpan)),
  15862. Expression.Constant(count, typeof(int))
  15863. )
  15864. );
  15865. }
  15866. /// <summary>
  15867. /// 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.
  15868. /// 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.
  15869. /// </summary>
  15870. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  15871. /// <param name="source">Source sequence to produce windows over.</param>
  15872. /// <param name="timeSpan">Maximum time length of a window.</param>
  15873. /// <param name="count">Maximum element count of a window.</param>
  15874. /// <param name="scheduler">Scheduler to run windowing timers on.</param>
  15875. /// <returns>An observable sequence of windows.</returns>
  15876. /// <exception cref="T:System.ArgumentNullException">
  15877. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  15878. /// <exception cref="T:System.ArgumentOutOfRangeException">
  15879. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero. -or- <paramref name="count" /> is less than or equal to zero.</exception>
  15880. /// <remarks>
  15881. /// 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.
  15882. /// 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
  15883. /// 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.
  15884. /// </remarks>
  15885. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, int count, IScheduler scheduler)
  15886. {
  15887. if (source == null)
  15888. throw new ArgumentNullException("source");
  15889. if (scheduler == null)
  15890. throw new ArgumentNullException("scheduler");
  15891. return source.Provider.CreateQuery<IObservable<TSource>>(
  15892. Expression.Call(
  15893. null,
  15894. #if CRIPPLED_REFLECTION
  15895. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(int), default(IScheduler))),
  15896. #else
  15897. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15898. #endif
  15899. source.Expression,
  15900. Expression.Constant(timeSpan, typeof(TimeSpan)),
  15901. Expression.Constant(count, typeof(int)),
  15902. Expression.Constant(scheduler, typeof(IScheduler))
  15903. )
  15904. );
  15905. }
  15906. /// <summary>
  15907. /// 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.
  15908. /// </summary>
  15909. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  15910. /// <param name="source">Source sequence to produce windows over.</param>
  15911. /// <param name="timeSpan">Length of each window.</param>
  15912. /// <param name="scheduler">Scheduler to run windowing timers on.</param>
  15913. /// <returns>An observable sequence of windows.</returns>
  15914. /// <exception cref="T:System.ArgumentNullException">
  15915. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  15916. /// <exception cref="T:System.ArgumentOutOfRangeException">
  15917. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  15918. /// <remarks>
  15919. /// 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.
  15920. /// 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
  15921. /// 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.
  15922. /// </remarks>
  15923. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, IScheduler scheduler)
  15924. {
  15925. if (source == null)
  15926. throw new ArgumentNullException("source");
  15927. if (scheduler == null)
  15928. throw new ArgumentNullException("scheduler");
  15929. return source.Provider.CreateQuery<IObservable<TSource>>(
  15930. Expression.Call(
  15931. null,
  15932. #if CRIPPLED_REFLECTION
  15933. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  15934. #else
  15935. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15936. #endif
  15937. source.Expression,
  15938. Expression.Constant(timeSpan, typeof(TimeSpan)),
  15939. Expression.Constant(scheduler, typeof(IScheduler))
  15940. )
  15941. );
  15942. }
  15943. /// <summary>
  15944. /// Projects each element of an observable sequence into zero or more windows which are produced based on timing information.
  15945. /// </summary>
  15946. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  15947. /// <param name="source">Source sequence to produce windows over.</param>
  15948. /// <param name="timeSpan">Length of each window.</param>
  15949. /// <param name="timeShift">Interval between creation of consecutive windows.</param>
  15950. /// <returns>An observable sequence of windows.</returns>
  15951. /// <exception cref="T:System.ArgumentNullException">
  15952. /// <paramref name="source" /> is null.</exception>
  15953. /// <exception cref="T:System.ArgumentOutOfRangeException">
  15954. /// <paramref name="timeSpan" /> or <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  15955. /// <remarks>
  15956. /// <para>
  15957. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create windows with minimum duration
  15958. /// 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
  15959. /// current window may not execute immediately, despite the TimeSpan.Zero due time.
  15960. /// </para>
  15961. /// <para>
  15962. /// 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.
  15963. /// 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,
  15964. /// where the action to create a new window may not execute immediately, despite the TimeSpan.Zero due time.
  15965. /// </para>
  15966. /// </remarks>
  15967. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, TimeSpan timeShift)
  15968. {
  15969. if (source == null)
  15970. throw new ArgumentNullException("source");
  15971. return source.Provider.CreateQuery<IObservable<TSource>>(
  15972. Expression.Call(
  15973. null,
  15974. #if CRIPPLED_REFLECTION
  15975. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(TimeSpan))),
  15976. #else
  15977. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15978. #endif
  15979. source.Expression,
  15980. Expression.Constant(timeSpan, typeof(TimeSpan)),
  15981. Expression.Constant(timeShift, typeof(TimeSpan))
  15982. )
  15983. );
  15984. }
  15985. /// <summary>
  15986. /// 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.
  15987. /// </summary>
  15988. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  15989. /// <param name="source">Source sequence to produce windows over.</param>
  15990. /// <param name="timeSpan">Length of each window.</param>
  15991. /// <param name="timeShift">Interval between creation of consecutive windows.</param>
  15992. /// <param name="scheduler">Scheduler to run windowing timers on.</param>
  15993. /// <returns>An observable sequence of windows.</returns>
  15994. /// <exception cref="T:System.ArgumentNullException">
  15995. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  15996. /// <exception cref="T:System.ArgumentOutOfRangeException">
  15997. /// <paramref name="timeSpan" /> or <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  15998. /// <remarks>
  15999. /// <para>
  16000. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create windows with minimum duration
  16001. /// 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
  16002. /// current window may not execute immediately, despite the TimeSpan.Zero due time.
  16003. /// </para>
  16004. /// <para>
  16005. /// 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.
  16006. /// 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,
  16007. /// where the action to create a new window may not execute immediately, despite the TimeSpan.Zero due time.
  16008. /// </para>
  16009. /// </remarks>
  16010. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, TimeSpan timeShift, IScheduler scheduler)
  16011. {
  16012. if (source == null)
  16013. throw new ArgumentNullException("source");
  16014. if (scheduler == null)
  16015. throw new ArgumentNullException("scheduler");
  16016. return source.Provider.CreateQuery<IObservable<TSource>>(
  16017. Expression.Call(
  16018. null,
  16019. #if CRIPPLED_REFLECTION
  16020. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(TimeSpan), default(IScheduler))),
  16021. #else
  16022. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16023. #endif
  16024. source.Expression,
  16025. Expression.Constant(timeSpan, typeof(TimeSpan)),
  16026. Expression.Constant(timeShift, typeof(TimeSpan)),
  16027. Expression.Constant(scheduler, typeof(IScheduler))
  16028. )
  16029. );
  16030. }
  16031. /// <summary>
  16032. /// Projects each element of an observable sequence into consecutive non-overlapping windows.
  16033. /// </summary>
  16034. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16035. /// <typeparam name="TWindowBoundary">The type of the elements in the sequences indicating window boundary events.</typeparam>
  16036. /// <param name="source">Source sequence to produce windows over.</param>
  16037. /// <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>
  16038. /// <returns>An observable sequence of windows.</returns>
  16039. /// <exception cref="T:System.ArgumentNullException">
  16040. /// <paramref name="source" /> or <paramref name="windowBoundaries" /> is null.</exception>
  16041. public static IQbservable<IObservable<TSource>> Window<TSource, TWindowBoundary>(this IQbservable<TSource> source, IObservable<TWindowBoundary> windowBoundaries)
  16042. {
  16043. if (source == null)
  16044. throw new ArgumentNullException("source");
  16045. if (windowBoundaries == null)
  16046. throw new ArgumentNullException("windowBoundaries");
  16047. return source.Provider.CreateQuery<IObservable<TSource>>(
  16048. Expression.Call(
  16049. null,
  16050. #if CRIPPLED_REFLECTION
  16051. InfoOf(() => Qbservable.Window<TSource, TWindowBoundary>(default(IQbservable<TSource>), default(IObservable<TWindowBoundary>))),
  16052. #else
  16053. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TWindowBoundary)),
  16054. #endif
  16055. source.Expression,
  16056. GetSourceExpression(windowBoundaries)
  16057. )
  16058. );
  16059. }
  16060. /// <summary>
  16061. /// Projects each element of an observable sequence into consecutive non-overlapping windows.
  16062. /// </summary>
  16063. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16064. /// <typeparam name="TWindowClosing">The type of the elements in the sequences indicating window closing events.</typeparam>
  16065. /// <param name="source">Source sequence to produce windows over.</param>
  16066. /// <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>
  16067. /// <returns>An observable sequence of windows.</returns>
  16068. /// <exception cref="T:System.ArgumentNullException">
  16069. /// <paramref name="source" /> or <paramref name="windowClosingSelector" /> is null.</exception>
  16070. public static IQbservable<IObservable<TSource>> Window<TSource, TWindowClosing>(this IQbservable<TSource> source, Expression<Func<IObservable<TWindowClosing>>> windowClosingSelector)
  16071. {
  16072. if (source == null)
  16073. throw new ArgumentNullException("source");
  16074. if (windowClosingSelector == null)
  16075. throw new ArgumentNullException("windowClosingSelector");
  16076. return source.Provider.CreateQuery<IObservable<TSource>>(
  16077. Expression.Call(
  16078. null,
  16079. #if CRIPPLED_REFLECTION
  16080. InfoOf(() => Qbservable.Window<TSource, TWindowClosing>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TWindowClosing>>>))),
  16081. #else
  16082. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TWindowClosing)),
  16083. #endif
  16084. source.Expression,
  16085. windowClosingSelector
  16086. )
  16087. );
  16088. }
  16089. /// <summary>
  16090. /// Projects each element of an observable sequence into zero or more windows.
  16091. /// </summary>
  16092. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16093. /// <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>
  16094. /// <typeparam name="TWindowClosing">The type of the elements in the sequences indicating window closing events.</typeparam>
  16095. /// <param name="source">Source sequence to produce windows over.</param>
  16096. /// <param name="windowOpenings">Observable sequence whose elements denote the creation of new windows.</param>
  16097. /// <param name="windowClosingSelector">A function invoked to define the closing of each produced window.</param>
  16098. /// <returns>An observable sequence of windows.</returns>
  16099. /// <exception cref="T:System.ArgumentNullException">
  16100. /// <paramref name="source" /> or <paramref name="windowOpenings" /> or <paramref name="windowClosingSelector" /> is null.</exception>
  16101. public static IQbservable<IObservable<TSource>> Window<TSource, TWindowOpening, TWindowClosing>(this IQbservable<TSource> source, IObservable<TWindowOpening> windowOpenings, Expression<Func<TWindowOpening, IObservable<TWindowClosing>>> windowClosingSelector)
  16102. {
  16103. if (source == null)
  16104. throw new ArgumentNullException("source");
  16105. if (windowOpenings == null)
  16106. throw new ArgumentNullException("windowOpenings");
  16107. if (windowClosingSelector == null)
  16108. throw new ArgumentNullException("windowClosingSelector");
  16109. return source.Provider.CreateQuery<IObservable<TSource>>(
  16110. Expression.Call(
  16111. null,
  16112. #if CRIPPLED_REFLECTION
  16113. InfoOf(() => Qbservable.Window<TSource, TWindowOpening, TWindowClosing>(default(IQbservable<TSource>), default(IObservable<TWindowOpening>), default(Expression<Func<TWindowOpening, IObservable<TWindowClosing>>>))),
  16114. #else
  16115. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TWindowOpening), typeof(TWindowClosing)),
  16116. #endif
  16117. source.Expression,
  16118. GetSourceExpression(windowOpenings),
  16119. windowClosingSelector
  16120. )
  16121. );
  16122. }
  16123. /// <summary>
  16124. /// Merges the specified observable sequences into one observable sequence by emitting a list with the elements of the observable sequences at corresponding indexes.
  16125. /// </summary>
  16126. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  16127. /// <typeparam name="TSource">The type of the elements in the source sequences, and in the lists in the result sequence.</typeparam>
  16128. /// <param name="sources">Observable sources.</param>
  16129. /// <returns>An observable sequence containing lists of elements at corresponding indexes.</returns>
  16130. /// <exception cref="T:System.ArgumentNullException">
  16131. /// <paramref name="sources" /> is null.</exception>
  16132. public static IQbservable<IList<TSource>> Zip<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  16133. {
  16134. if (provider == null)
  16135. throw new ArgumentNullException("provider");
  16136. if (sources == null)
  16137. throw new ArgumentNullException("sources");
  16138. return provider.CreateQuery<IList<TSource>>(
  16139. Expression.Call(
  16140. null,
  16141. #if CRIPPLED_REFLECTION
  16142. InfoOf(() => Qbservable.Zip<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  16143. #else
  16144. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16145. #endif
  16146. Expression.Constant(provider, typeof(IQbservableProvider)),
  16147. GetSourceExpression(sources)
  16148. )
  16149. );
  16150. }
  16151. /// <summary>
  16152. /// Merges the specified observable sequences into one observable sequence by emitting a list with the elements of the observable sequences at corresponding indexes.
  16153. /// </summary>
  16154. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  16155. /// <typeparam name="TSource">The type of the elements in the source sequences, and in the lists in the result sequence.</typeparam>
  16156. /// <param name="sources">Observable sources.</param>
  16157. /// <returns>An observable sequence containing lists of elements at corresponding indexes.</returns>
  16158. /// <exception cref="T:System.ArgumentNullException">
  16159. /// <paramref name="sources" /> is null.</exception>
  16160. public static IQbservable<IList<TSource>> Zip<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  16161. {
  16162. if (provider == null)
  16163. throw new ArgumentNullException("provider");
  16164. if (sources == null)
  16165. throw new ArgumentNullException("sources");
  16166. return provider.CreateQuery<IList<TSource>>(
  16167. Expression.Call(
  16168. null,
  16169. #if CRIPPLED_REFLECTION
  16170. InfoOf(() => Qbservable.Zip<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  16171. #else
  16172. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16173. #endif
  16174. Expression.Constant(provider, typeof(IQbservableProvider)),
  16175. GetSourceExpression(sources)
  16176. )
  16177. );
  16178. }
  16179. /// <summary>
  16180. /// 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.
  16181. /// </summary>
  16182. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  16183. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  16184. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16185. /// <param name="sources">Observable sources.</param>
  16186. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16187. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16188. /// <exception cref="T:System.ArgumentNullException">
  16189. /// <paramref name="sources" /> or <paramref name="resultSelector" /> is null.</exception>
  16190. public static IQbservable<TResult> Zip<TSource, TResult>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, Expression<Func<IList<TSource>, TResult>> resultSelector)
  16191. {
  16192. if (provider == null)
  16193. throw new ArgumentNullException("provider");
  16194. if (sources == null)
  16195. throw new ArgumentNullException("sources");
  16196. if (resultSelector == null)
  16197. throw new ArgumentNullException("resultSelector");
  16198. return provider.CreateQuery<TResult>(
  16199. Expression.Call(
  16200. null,
  16201. #if CRIPPLED_REFLECTION
  16202. InfoOf(() => Qbservable.Zip<TSource, TResult>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(Expression<Func<IList<TSource>, TResult>>))),
  16203. #else
  16204. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  16205. #endif
  16206. Expression.Constant(provider, typeof(IQbservableProvider)),
  16207. GetSourceExpression(sources),
  16208. resultSelector
  16209. )
  16210. );
  16211. }
  16212. /// <summary>
  16213. /// Merges an observable sequence and an enumerable sequence into one observable sequence by using the selector function.
  16214. /// </summary>
  16215. /// <typeparam name="TSource1">The type of the elements in the first observable source sequence.</typeparam>
  16216. /// <typeparam name="TSource2">The type of the elements in the second enumerable source sequence.</typeparam>
  16217. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16218. /// <param name="first">First observable source.</param>
  16219. /// <param name="second">Second enumerable source.</param>
  16220. /// <param name="resultSelector">Function to invoke for each consecutive pair of elements from the first and second source.</param>
  16221. /// <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>
  16222. /// <exception cref="T:System.ArgumentNullException">
  16223. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="resultSelector" /> is null.</exception>
  16224. public static IQbservable<TResult> Zip<TSource1, TSource2, TResult>(this IQbservable<TSource1> first, IEnumerable<TSource2> second, Expression<Func<TSource1, TSource2, TResult>> resultSelector)
  16225. {
  16226. if (first == null)
  16227. throw new ArgumentNullException("first");
  16228. if (second == null)
  16229. throw new ArgumentNullException("second");
  16230. if (resultSelector == null)
  16231. throw new ArgumentNullException("resultSelector");
  16232. return first.Provider.CreateQuery<TResult>(
  16233. Expression.Call(
  16234. null,
  16235. #if CRIPPLED_REFLECTION
  16236. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TResult>(default(IQbservable<TSource1>), default(IEnumerable<TSource2>), default(Expression<Func<TSource1, TSource2, TResult>>))),
  16237. #else
  16238. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TResult)),
  16239. #endif
  16240. first.Expression,
  16241. GetSourceExpression(second),
  16242. resultSelector
  16243. )
  16244. );
  16245. }
  16246. /// <summary>
  16247. /// Merges two observable sequences into one observable sequence by combining their elements in a pairwise fashion.
  16248. /// </summary>
  16249. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16250. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16251. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16252. /// <param name="first">First observable source.</param>
  16253. /// <param name="second">Second observable source.</param>
  16254. /// <param name="resultSelector">Function to invoke for each consecutive pair of elements from the first and second source.</param>
  16255. /// <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>
  16256. /// <exception cref="T:System.ArgumentNullException">
  16257. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="resultSelector" /> is null.</exception>
  16258. public static IQbservable<TResult> Zip<TSource1, TSource2, TResult>(this IQbservable<TSource1> first, IObservable<TSource2> second, Expression<Func<TSource1, TSource2, TResult>> resultSelector)
  16259. {
  16260. if (first == null)
  16261. throw new ArgumentNullException("first");
  16262. if (second == null)
  16263. throw new ArgumentNullException("second");
  16264. if (resultSelector == null)
  16265. throw new ArgumentNullException("resultSelector");
  16266. return first.Provider.CreateQuery<TResult>(
  16267. Expression.Call(
  16268. null,
  16269. #if CRIPPLED_REFLECTION
  16270. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(Expression<Func<TSource1, TSource2, TResult>>))),
  16271. #else
  16272. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TResult)),
  16273. #endif
  16274. first.Expression,
  16275. GetSourceExpression(second),
  16276. resultSelector
  16277. )
  16278. );
  16279. }
  16280. /// <summary>
  16281. /// 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.
  16282. /// </summary>
  16283. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16284. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16285. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16286. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16287. /// <param name="source1">First observable source.</param>
  16288. /// <param name="source2">Second observable source.</param>
  16289. /// <param name="source3">Third observable source.</param>
  16290. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16291. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16292. /// <exception cref="T:System.ArgumentNullException">
  16293. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="resultSelector" /> is null.</exception>
  16294. 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)
  16295. {
  16296. if (source1 == null)
  16297. throw new ArgumentNullException("source1");
  16298. if (source2 == null)
  16299. throw new ArgumentNullException("source2");
  16300. if (source3 == null)
  16301. throw new ArgumentNullException("source3");
  16302. if (resultSelector == null)
  16303. throw new ArgumentNullException("resultSelector");
  16304. return source1.Provider.CreateQuery<TResult>(
  16305. Expression.Call(
  16306. null,
  16307. #if CRIPPLED_REFLECTION
  16308. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TSource3, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(Expression<Func<TSource1, TSource2, TSource3, TResult>>))),
  16309. #else
  16310. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TResult)),
  16311. #endif
  16312. source1.Expression,
  16313. GetSourceExpression(source2),
  16314. GetSourceExpression(source3),
  16315. resultSelector
  16316. )
  16317. );
  16318. }
  16319. /// <summary>
  16320. /// 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.
  16321. /// </summary>
  16322. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16323. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16324. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16325. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16326. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16327. /// <param name="source1">First observable source.</param>
  16328. /// <param name="source2">Second observable source.</param>
  16329. /// <param name="source3">Third observable source.</param>
  16330. /// <param name="source4">Fourth observable source.</param>
  16331. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16332. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16333. /// <exception cref="T:System.ArgumentNullException">
  16334. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="resultSelector" /> is null.</exception>
  16335. 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)
  16336. {
  16337. if (source1 == null)
  16338. throw new ArgumentNullException("source1");
  16339. if (source2 == null)
  16340. throw new ArgumentNullException("source2");
  16341. if (source3 == null)
  16342. throw new ArgumentNullException("source3");
  16343. if (source4 == null)
  16344. throw new ArgumentNullException("source4");
  16345. if (resultSelector == null)
  16346. throw new ArgumentNullException("resultSelector");
  16347. return source1.Provider.CreateQuery<TResult>(
  16348. Expression.Call(
  16349. null,
  16350. #if CRIPPLED_REFLECTION
  16351. 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>>))),
  16352. #else
  16353. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TResult)),
  16354. #endif
  16355. source1.Expression,
  16356. GetSourceExpression(source2),
  16357. GetSourceExpression(source3),
  16358. GetSourceExpression(source4),
  16359. resultSelector
  16360. )
  16361. );
  16362. }
  16363. #if !NO_LARGEARITY
  16364. /// <summary>
  16365. /// 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.
  16366. /// </summary>
  16367. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16368. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16369. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16370. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16371. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16372. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16373. /// <param name="source1">First observable source.</param>
  16374. /// <param name="source2">Second observable source.</param>
  16375. /// <param name="source3">Third observable source.</param>
  16376. /// <param name="source4">Fourth observable source.</param>
  16377. /// <param name="source5">Fifth observable source.</param>
  16378. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16379. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16380. /// <exception cref="T:System.ArgumentNullException">
  16381. /// <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>
  16382. 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)
  16383. {
  16384. if (source1 == null)
  16385. throw new ArgumentNullException("source1");
  16386. if (source2 == null)
  16387. throw new ArgumentNullException("source2");
  16388. if (source3 == null)
  16389. throw new ArgumentNullException("source3");
  16390. if (source4 == null)
  16391. throw new ArgumentNullException("source4");
  16392. if (source5 == null)
  16393. throw new ArgumentNullException("source5");
  16394. if (resultSelector == null)
  16395. throw new ArgumentNullException("resultSelector");
  16396. return source1.Provider.CreateQuery<TResult>(
  16397. Expression.Call(
  16398. null,
  16399. #if CRIPPLED_REFLECTION
  16400. 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>>))),
  16401. #else
  16402. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TResult)),
  16403. #endif
  16404. source1.Expression,
  16405. GetSourceExpression(source2),
  16406. GetSourceExpression(source3),
  16407. GetSourceExpression(source4),
  16408. GetSourceExpression(source5),
  16409. resultSelector
  16410. )
  16411. );
  16412. }
  16413. #endif
  16414. #if !NO_LARGEARITY
  16415. /// <summary>
  16416. /// 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.
  16417. /// </summary>
  16418. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16419. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16420. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16421. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16422. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16423. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16424. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16425. /// <param name="source1">First observable source.</param>
  16426. /// <param name="source2">Second observable source.</param>
  16427. /// <param name="source3">Third observable source.</param>
  16428. /// <param name="source4">Fourth observable source.</param>
  16429. /// <param name="source5">Fifth observable source.</param>
  16430. /// <param name="source6">Sixth observable source.</param>
  16431. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16432. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16433. /// <exception cref="T:System.ArgumentNullException">
  16434. /// <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>
  16435. 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)
  16436. {
  16437. if (source1 == null)
  16438. throw new ArgumentNullException("source1");
  16439. if (source2 == null)
  16440. throw new ArgumentNullException("source2");
  16441. if (source3 == null)
  16442. throw new ArgumentNullException("source3");
  16443. if (source4 == null)
  16444. throw new ArgumentNullException("source4");
  16445. if (source5 == null)
  16446. throw new ArgumentNullException("source5");
  16447. if (source6 == null)
  16448. throw new ArgumentNullException("source6");
  16449. if (resultSelector == null)
  16450. throw new ArgumentNullException("resultSelector");
  16451. return source1.Provider.CreateQuery<TResult>(
  16452. Expression.Call(
  16453. null,
  16454. #if CRIPPLED_REFLECTION
  16455. 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>>))),
  16456. #else
  16457. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TResult)),
  16458. #endif
  16459. source1.Expression,
  16460. GetSourceExpression(source2),
  16461. GetSourceExpression(source3),
  16462. GetSourceExpression(source4),
  16463. GetSourceExpression(source5),
  16464. GetSourceExpression(source6),
  16465. resultSelector
  16466. )
  16467. );
  16468. }
  16469. #endif
  16470. #if !NO_LARGEARITY
  16471. /// <summary>
  16472. /// 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.
  16473. /// </summary>
  16474. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16475. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16476. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16477. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16478. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16479. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16480. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16481. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16482. /// <param name="source1">First observable source.</param>
  16483. /// <param name="source2">Second observable source.</param>
  16484. /// <param name="source3">Third observable source.</param>
  16485. /// <param name="source4">Fourth observable source.</param>
  16486. /// <param name="source5">Fifth observable source.</param>
  16487. /// <param name="source6">Sixth observable source.</param>
  16488. /// <param name="source7">Seventh observable source.</param>
  16489. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16490. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16491. /// <exception cref="T:System.ArgumentNullException">
  16492. /// <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>
  16493. 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)
  16494. {
  16495. if (source1 == null)
  16496. throw new ArgumentNullException("source1");
  16497. if (source2 == null)
  16498. throw new ArgumentNullException("source2");
  16499. if (source3 == null)
  16500. throw new ArgumentNullException("source3");
  16501. if (source4 == null)
  16502. throw new ArgumentNullException("source4");
  16503. if (source5 == null)
  16504. throw new ArgumentNullException("source5");
  16505. if (source6 == null)
  16506. throw new ArgumentNullException("source6");
  16507. if (source7 == null)
  16508. throw new ArgumentNullException("source7");
  16509. if (resultSelector == null)
  16510. throw new ArgumentNullException("resultSelector");
  16511. return source1.Provider.CreateQuery<TResult>(
  16512. Expression.Call(
  16513. null,
  16514. #if CRIPPLED_REFLECTION
  16515. 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>>))),
  16516. #else
  16517. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TResult)),
  16518. #endif
  16519. source1.Expression,
  16520. GetSourceExpression(source2),
  16521. GetSourceExpression(source3),
  16522. GetSourceExpression(source4),
  16523. GetSourceExpression(source5),
  16524. GetSourceExpression(source6),
  16525. GetSourceExpression(source7),
  16526. resultSelector
  16527. )
  16528. );
  16529. }
  16530. #endif
  16531. #if !NO_LARGEARITY
  16532. /// <summary>
  16533. /// 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.
  16534. /// </summary>
  16535. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16536. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16537. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16538. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16539. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16540. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16541. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16542. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  16543. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16544. /// <param name="source1">First observable source.</param>
  16545. /// <param name="source2">Second observable source.</param>
  16546. /// <param name="source3">Third observable source.</param>
  16547. /// <param name="source4">Fourth observable source.</param>
  16548. /// <param name="source5">Fifth observable source.</param>
  16549. /// <param name="source6">Sixth observable source.</param>
  16550. /// <param name="source7">Seventh observable source.</param>
  16551. /// <param name="source8">Eighth observable source.</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="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>
  16556. 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)
  16557. {
  16558. if (source1 == null)
  16559. throw new ArgumentNullException("source1");
  16560. if (source2 == null)
  16561. throw new ArgumentNullException("source2");
  16562. if (source3 == null)
  16563. throw new ArgumentNullException("source3");
  16564. if (source4 == null)
  16565. throw new ArgumentNullException("source4");
  16566. if (source5 == null)
  16567. throw new ArgumentNullException("source5");
  16568. if (source6 == null)
  16569. throw new ArgumentNullException("source6");
  16570. if (source7 == null)
  16571. throw new ArgumentNullException("source7");
  16572. if (source8 == null)
  16573. throw new ArgumentNullException("source8");
  16574. if (resultSelector == null)
  16575. throw new ArgumentNullException("resultSelector");
  16576. return source1.Provider.CreateQuery<TResult>(
  16577. Expression.Call(
  16578. null,
  16579. #if CRIPPLED_REFLECTION
  16580. 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>>))),
  16581. #else
  16582. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TResult)),
  16583. #endif
  16584. source1.Expression,
  16585. GetSourceExpression(source2),
  16586. GetSourceExpression(source3),
  16587. GetSourceExpression(source4),
  16588. GetSourceExpression(source5),
  16589. GetSourceExpression(source6),
  16590. GetSourceExpression(source7),
  16591. GetSourceExpression(source8),
  16592. resultSelector
  16593. )
  16594. );
  16595. }
  16596. #endif
  16597. #if !NO_LARGEARITY
  16598. /// <summary>
  16599. /// 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.
  16600. /// </summary>
  16601. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16602. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16603. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16604. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16605. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16606. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16607. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16608. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  16609. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  16610. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16611. /// <param name="source1">First observable source.</param>
  16612. /// <param name="source2">Second observable source.</param>
  16613. /// <param name="source3">Third observable source.</param>
  16614. /// <param name="source4">Fourth observable source.</param>
  16615. /// <param name="source5">Fifth observable source.</param>
  16616. /// <param name="source6">Sixth observable source.</param>
  16617. /// <param name="source7">Seventh observable source.</param>
  16618. /// <param name="source8">Eighth observable source.</param>
  16619. /// <param name="source9">Ninth observable source.</param>
  16620. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16621. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16622. /// <exception cref="T:System.ArgumentNullException">
  16623. /// <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>
  16624. 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)
  16625. {
  16626. if (source1 == null)
  16627. throw new ArgumentNullException("source1");
  16628. if (source2 == null)
  16629. throw new ArgumentNullException("source2");
  16630. if (source3 == null)
  16631. throw new ArgumentNullException("source3");
  16632. if (source4 == null)
  16633. throw new ArgumentNullException("source4");
  16634. if (source5 == null)
  16635. throw new ArgumentNullException("source5");
  16636. if (source6 == null)
  16637. throw new ArgumentNullException("source6");
  16638. if (source7 == null)
  16639. throw new ArgumentNullException("source7");
  16640. if (source8 == null)
  16641. throw new ArgumentNullException("source8");
  16642. if (source9 == null)
  16643. throw new ArgumentNullException("source9");
  16644. if (resultSelector == null)
  16645. throw new ArgumentNullException("resultSelector");
  16646. return source1.Provider.CreateQuery<TResult>(
  16647. Expression.Call(
  16648. null,
  16649. #if CRIPPLED_REFLECTION
  16650. 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>>))),
  16651. #else
  16652. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TSource9), typeof(TResult)),
  16653. #endif
  16654. source1.Expression,
  16655. GetSourceExpression(source2),
  16656. GetSourceExpression(source3),
  16657. GetSourceExpression(source4),
  16658. GetSourceExpression(source5),
  16659. GetSourceExpression(source6),
  16660. GetSourceExpression(source7),
  16661. GetSourceExpression(source8),
  16662. GetSourceExpression(source9),
  16663. resultSelector
  16664. )
  16665. );
  16666. }
  16667. #endif
  16668. #if !NO_LARGEARITY
  16669. /// <summary>
  16670. /// 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.
  16671. /// </summary>
  16672. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16673. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16674. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16675. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16676. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16677. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16678. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16679. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  16680. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  16681. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  16682. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16683. /// <param name="source1">First observable source.</param>
  16684. /// <param name="source2">Second observable source.</param>
  16685. /// <param name="source3">Third observable source.</param>
  16686. /// <param name="source4">Fourth observable source.</param>
  16687. /// <param name="source5">Fifth observable source.</param>
  16688. /// <param name="source6">Sixth observable source.</param>
  16689. /// <param name="source7">Seventh observable source.</param>
  16690. /// <param name="source8">Eighth observable source.</param>
  16691. /// <param name="source9">Ninth observable source.</param>
  16692. /// <param name="source10">Tenth observable source.</param>
  16693. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16694. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16695. /// <exception cref="T:System.ArgumentNullException">
  16696. /// <paramref name="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>
  16697. 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)
  16698. {
  16699. if (source1 == null)
  16700. throw new ArgumentNullException("source1");
  16701. if (source2 == null)
  16702. throw new ArgumentNullException("source2");
  16703. if (source3 == null)
  16704. throw new ArgumentNullException("source3");
  16705. if (source4 == null)
  16706. throw new ArgumentNullException("source4");
  16707. if (source5 == null)
  16708. throw new ArgumentNullException("source5");
  16709. if (source6 == null)
  16710. throw new ArgumentNullException("source6");
  16711. if (source7 == null)
  16712. throw new ArgumentNullException("source7");
  16713. if (source8 == null)
  16714. throw new ArgumentNullException("source8");
  16715. if (source9 == null)
  16716. throw new ArgumentNullException("source9");
  16717. if (source10 == null)
  16718. throw new ArgumentNullException("source10");
  16719. if (resultSelector == null)
  16720. throw new ArgumentNullException("resultSelector");
  16721. return source1.Provider.CreateQuery<TResult>(
  16722. Expression.Call(
  16723. null,
  16724. #if CRIPPLED_REFLECTION
  16725. 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>>))),
  16726. #else
  16727. ((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)),
  16728. #endif
  16729. source1.Expression,
  16730. GetSourceExpression(source2),
  16731. GetSourceExpression(source3),
  16732. GetSourceExpression(source4),
  16733. GetSourceExpression(source5),
  16734. GetSourceExpression(source6),
  16735. GetSourceExpression(source7),
  16736. GetSourceExpression(source8),
  16737. GetSourceExpression(source9),
  16738. GetSourceExpression(source10),
  16739. resultSelector
  16740. )
  16741. );
  16742. }
  16743. #endif
  16744. #if !NO_LARGEARITY
  16745. /// <summary>
  16746. /// 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.
  16747. /// </summary>
  16748. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16749. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16750. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16751. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16752. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16753. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16754. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16755. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  16756. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  16757. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  16758. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  16759. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16760. /// <param name="source1">First observable source.</param>
  16761. /// <param name="source2">Second observable source.</param>
  16762. /// <param name="source3">Third observable source.</param>
  16763. /// <param name="source4">Fourth observable source.</param>
  16764. /// <param name="source5">Fifth observable source.</param>
  16765. /// <param name="source6">Sixth observable source.</param>
  16766. /// <param name="source7">Seventh observable source.</param>
  16767. /// <param name="source8">Eighth observable source.</param>
  16768. /// <param name="source9">Ninth observable source.</param>
  16769. /// <param name="source10">Tenth observable source.</param>
  16770. /// <param name="source11">Eleventh observable source.</param>
  16771. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16772. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16773. /// <exception cref="T:System.ArgumentNullException">
  16774. /// <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>
  16775. 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)
  16776. {
  16777. if (source1 == null)
  16778. throw new ArgumentNullException("source1");
  16779. if (source2 == null)
  16780. throw new ArgumentNullException("source2");
  16781. if (source3 == null)
  16782. throw new ArgumentNullException("source3");
  16783. if (source4 == null)
  16784. throw new ArgumentNullException("source4");
  16785. if (source5 == null)
  16786. throw new ArgumentNullException("source5");
  16787. if (source6 == null)
  16788. throw new ArgumentNullException("source6");
  16789. if (source7 == null)
  16790. throw new ArgumentNullException("source7");
  16791. if (source8 == null)
  16792. throw new ArgumentNullException("source8");
  16793. if (source9 == null)
  16794. throw new ArgumentNullException("source9");
  16795. if (source10 == null)
  16796. throw new ArgumentNullException("source10");
  16797. if (source11 == null)
  16798. throw new ArgumentNullException("source11");
  16799. if (resultSelector == null)
  16800. throw new ArgumentNullException("resultSelector");
  16801. return source1.Provider.CreateQuery<TResult>(
  16802. Expression.Call(
  16803. null,
  16804. #if CRIPPLED_REFLECTION
  16805. 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>>))),
  16806. #else
  16807. ((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)),
  16808. #endif
  16809. source1.Expression,
  16810. GetSourceExpression(source2),
  16811. GetSourceExpression(source3),
  16812. GetSourceExpression(source4),
  16813. GetSourceExpression(source5),
  16814. GetSourceExpression(source6),
  16815. GetSourceExpression(source7),
  16816. GetSourceExpression(source8),
  16817. GetSourceExpression(source9),
  16818. GetSourceExpression(source10),
  16819. GetSourceExpression(source11),
  16820. resultSelector
  16821. )
  16822. );
  16823. }
  16824. #endif
  16825. #if !NO_LARGEARITY
  16826. /// <summary>
  16827. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
  16828. /// </summary>
  16829. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16830. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16831. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16832. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16833. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16834. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16835. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16836. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  16837. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  16838. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  16839. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  16840. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  16841. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16842. /// <param name="source1">First observable source.</param>
  16843. /// <param name="source2">Second observable source.</param>
  16844. /// <param name="source3">Third observable source.</param>
  16845. /// <param name="source4">Fourth observable source.</param>
  16846. /// <param name="source5">Fifth observable source.</param>
  16847. /// <param name="source6">Sixth observable source.</param>
  16848. /// <param name="source7">Seventh observable source.</param>
  16849. /// <param name="source8">Eighth observable source.</param>
  16850. /// <param name="source9">Ninth observable source.</param>
  16851. /// <param name="source10">Tenth observable source.</param>
  16852. /// <param name="source11">Eleventh observable source.</param>
  16853. /// <param name="source12">Twelfth observable source.</param>
  16854. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16855. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16856. /// <exception cref="T:System.ArgumentNullException">
  16857. /// <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>
  16858. 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)
  16859. {
  16860. if (source1 == null)
  16861. throw new ArgumentNullException("source1");
  16862. if (source2 == null)
  16863. throw new ArgumentNullException("source2");
  16864. if (source3 == null)
  16865. throw new ArgumentNullException("source3");
  16866. if (source4 == null)
  16867. throw new ArgumentNullException("source4");
  16868. if (source5 == null)
  16869. throw new ArgumentNullException("source5");
  16870. if (source6 == null)
  16871. throw new ArgumentNullException("source6");
  16872. if (source7 == null)
  16873. throw new ArgumentNullException("source7");
  16874. if (source8 == null)
  16875. throw new ArgumentNullException("source8");
  16876. if (source9 == null)
  16877. throw new ArgumentNullException("source9");
  16878. if (source10 == null)
  16879. throw new ArgumentNullException("source10");
  16880. if (source11 == null)
  16881. throw new ArgumentNullException("source11");
  16882. if (source12 == null)
  16883. throw new ArgumentNullException("source12");
  16884. if (resultSelector == null)
  16885. throw new ArgumentNullException("resultSelector");
  16886. return source1.Provider.CreateQuery<TResult>(
  16887. Expression.Call(
  16888. null,
  16889. #if CRIPPLED_REFLECTION
  16890. 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>>))),
  16891. #else
  16892. ((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)),
  16893. #endif
  16894. source1.Expression,
  16895. GetSourceExpression(source2),
  16896. GetSourceExpression(source3),
  16897. GetSourceExpression(source4),
  16898. GetSourceExpression(source5),
  16899. GetSourceExpression(source6),
  16900. GetSourceExpression(source7),
  16901. GetSourceExpression(source8),
  16902. GetSourceExpression(source9),
  16903. GetSourceExpression(source10),
  16904. GetSourceExpression(source11),
  16905. GetSourceExpression(source12),
  16906. resultSelector
  16907. )
  16908. );
  16909. }
  16910. #endif
  16911. #if !NO_LARGEARITY
  16912. /// <summary>
  16913. /// 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.
  16914. /// </summary>
  16915. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16916. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16917. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16918. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16919. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16920. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16921. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16922. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  16923. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  16924. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  16925. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  16926. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  16927. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  16928. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16929. /// <param name="source1">First observable source.</param>
  16930. /// <param name="source2">Second observable source.</param>
  16931. /// <param name="source3">Third observable source.</param>
  16932. /// <param name="source4">Fourth observable source.</param>
  16933. /// <param name="source5">Fifth observable source.</param>
  16934. /// <param name="source6">Sixth observable source.</param>
  16935. /// <param name="source7">Seventh observable source.</param>
  16936. /// <param name="source8">Eighth observable source.</param>
  16937. /// <param name="source9">Ninth observable source.</param>
  16938. /// <param name="source10">Tenth observable source.</param>
  16939. /// <param name="source11">Eleventh observable source.</param>
  16940. /// <param name="source12">Twelfth observable source.</param>
  16941. /// <param name="source13">Thirteenth observable source.</param>
  16942. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16943. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16944. /// <exception cref="T:System.ArgumentNullException">
  16945. /// <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>
  16946. 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)
  16947. {
  16948. if (source1 == null)
  16949. throw new ArgumentNullException("source1");
  16950. if (source2 == null)
  16951. throw new ArgumentNullException("source2");
  16952. if (source3 == null)
  16953. throw new ArgumentNullException("source3");
  16954. if (source4 == null)
  16955. throw new ArgumentNullException("source4");
  16956. if (source5 == null)
  16957. throw new ArgumentNullException("source5");
  16958. if (source6 == null)
  16959. throw new ArgumentNullException("source6");
  16960. if (source7 == null)
  16961. throw new ArgumentNullException("source7");
  16962. if (source8 == null)
  16963. throw new ArgumentNullException("source8");
  16964. if (source9 == null)
  16965. throw new ArgumentNullException("source9");
  16966. if (source10 == null)
  16967. throw new ArgumentNullException("source10");
  16968. if (source11 == null)
  16969. throw new ArgumentNullException("source11");
  16970. if (source12 == null)
  16971. throw new ArgumentNullException("source12");
  16972. if (source13 == null)
  16973. throw new ArgumentNullException("source13");
  16974. if (resultSelector == null)
  16975. throw new ArgumentNullException("resultSelector");
  16976. return source1.Provider.CreateQuery<TResult>(
  16977. Expression.Call(
  16978. null,
  16979. #if CRIPPLED_REFLECTION
  16980. 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>>))),
  16981. #else
  16982. ((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)),
  16983. #endif
  16984. source1.Expression,
  16985. GetSourceExpression(source2),
  16986. GetSourceExpression(source3),
  16987. GetSourceExpression(source4),
  16988. GetSourceExpression(source5),
  16989. GetSourceExpression(source6),
  16990. GetSourceExpression(source7),
  16991. GetSourceExpression(source8),
  16992. GetSourceExpression(source9),
  16993. GetSourceExpression(source10),
  16994. GetSourceExpression(source11),
  16995. GetSourceExpression(source12),
  16996. GetSourceExpression(source13),
  16997. resultSelector
  16998. )
  16999. );
  17000. }
  17001. #endif
  17002. #if !NO_LARGEARITY
  17003. /// <summary>
  17004. /// 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.
  17005. /// </summary>
  17006. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  17007. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  17008. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  17009. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  17010. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  17011. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  17012. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  17013. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  17014. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  17015. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  17016. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  17017. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  17018. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  17019. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  17020. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  17021. /// <param name="source1">First observable source.</param>
  17022. /// <param name="source2">Second observable source.</param>
  17023. /// <param name="source3">Third observable source.</param>
  17024. /// <param name="source4">Fourth observable source.</param>
  17025. /// <param name="source5">Fifth observable source.</param>
  17026. /// <param name="source6">Sixth observable source.</param>
  17027. /// <param name="source7">Seventh observable source.</param>
  17028. /// <param name="source8">Eighth observable source.</param>
  17029. /// <param name="source9">Ninth observable source.</param>
  17030. /// <param name="source10">Tenth observable source.</param>
  17031. /// <param name="source11">Eleventh observable source.</param>
  17032. /// <param name="source12">Twelfth observable source.</param>
  17033. /// <param name="source13">Thirteenth observable source.</param>
  17034. /// <param name="source14">Fourteenth observable source.</param>
  17035. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  17036. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  17037. /// <exception cref="T:System.ArgumentNullException">
  17038. /// <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>
  17039. 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)
  17040. {
  17041. if (source1 == null)
  17042. throw new ArgumentNullException("source1");
  17043. if (source2 == null)
  17044. throw new ArgumentNullException("source2");
  17045. if (source3 == null)
  17046. throw new ArgumentNullException("source3");
  17047. if (source4 == null)
  17048. throw new ArgumentNullException("source4");
  17049. if (source5 == null)
  17050. throw new ArgumentNullException("source5");
  17051. if (source6 == null)
  17052. throw new ArgumentNullException("source6");
  17053. if (source7 == null)
  17054. throw new ArgumentNullException("source7");
  17055. if (source8 == null)
  17056. throw new ArgumentNullException("source8");
  17057. if (source9 == null)
  17058. throw new ArgumentNullException("source9");
  17059. if (source10 == null)
  17060. throw new ArgumentNullException("source10");
  17061. if (source11 == null)
  17062. throw new ArgumentNullException("source11");
  17063. if (source12 == null)
  17064. throw new ArgumentNullException("source12");
  17065. if (source13 == null)
  17066. throw new ArgumentNullException("source13");
  17067. if (source14 == null)
  17068. throw new ArgumentNullException("source14");
  17069. if (resultSelector == null)
  17070. throw new ArgumentNullException("resultSelector");
  17071. return source1.Provider.CreateQuery<TResult>(
  17072. Expression.Call(
  17073. null,
  17074. #if CRIPPLED_REFLECTION
  17075. 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>>))),
  17076. #else
  17077. ((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)),
  17078. #endif
  17079. source1.Expression,
  17080. GetSourceExpression(source2),
  17081. GetSourceExpression(source3),
  17082. GetSourceExpression(source4),
  17083. GetSourceExpression(source5),
  17084. GetSourceExpression(source6),
  17085. GetSourceExpression(source7),
  17086. GetSourceExpression(source8),
  17087. GetSourceExpression(source9),
  17088. GetSourceExpression(source10),
  17089. GetSourceExpression(source11),
  17090. GetSourceExpression(source12),
  17091. GetSourceExpression(source13),
  17092. GetSourceExpression(source14),
  17093. resultSelector
  17094. )
  17095. );
  17096. }
  17097. #endif
  17098. #if !NO_LARGEARITY
  17099. /// <summary>
  17100. /// 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.
  17101. /// </summary>
  17102. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  17103. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  17104. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  17105. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  17106. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  17107. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  17108. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  17109. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  17110. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  17111. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  17112. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  17113. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  17114. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  17115. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  17116. /// <typeparam name="TSource15">The type of the elements in the fifteenth source sequence.</typeparam>
  17117. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  17118. /// <param name="source1">First observable source.</param>
  17119. /// <param name="source2">Second observable source.</param>
  17120. /// <param name="source3">Third observable source.</param>
  17121. /// <param name="source4">Fourth observable source.</param>
  17122. /// <param name="source5">Fifth observable source.</param>
  17123. /// <param name="source6">Sixth observable source.</param>
  17124. /// <param name="source7">Seventh observable source.</param>
  17125. /// <param name="source8">Eighth observable source.</param>
  17126. /// <param name="source9">Ninth observable source.</param>
  17127. /// <param name="source10">Tenth observable source.</param>
  17128. /// <param name="source11">Eleventh observable source.</param>
  17129. /// <param name="source12">Twelfth observable source.</param>
  17130. /// <param name="source13">Thirteenth observable source.</param>
  17131. /// <param name="source14">Fourteenth observable source.</param>
  17132. /// <param name="source15">Fifteenth observable source.</param>
  17133. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  17134. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  17135. /// <exception cref="T:System.ArgumentNullException">
  17136. /// <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>
  17137. 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)
  17138. {
  17139. if (source1 == null)
  17140. throw new ArgumentNullException("source1");
  17141. if (source2 == null)
  17142. throw new ArgumentNullException("source2");
  17143. if (source3 == null)
  17144. throw new ArgumentNullException("source3");
  17145. if (source4 == null)
  17146. throw new ArgumentNullException("source4");
  17147. if (source5 == null)
  17148. throw new ArgumentNullException("source5");
  17149. if (source6 == null)
  17150. throw new ArgumentNullException("source6");
  17151. if (source7 == null)
  17152. throw new ArgumentNullException("source7");
  17153. if (source8 == null)
  17154. throw new ArgumentNullException("source8");
  17155. if (source9 == null)
  17156. throw new ArgumentNullException("source9");
  17157. if (source10 == null)
  17158. throw new ArgumentNullException("source10");
  17159. if (source11 == null)
  17160. throw new ArgumentNullException("source11");
  17161. if (source12 == null)
  17162. throw new ArgumentNullException("source12");
  17163. if (source13 == null)
  17164. throw new ArgumentNullException("source13");
  17165. if (source14 == null)
  17166. throw new ArgumentNullException("source14");
  17167. if (source15 == null)
  17168. throw new ArgumentNullException("source15");
  17169. if (resultSelector == null)
  17170. throw new ArgumentNullException("resultSelector");
  17171. return source1.Provider.CreateQuery<TResult>(
  17172. Expression.Call(
  17173. null,
  17174. #if CRIPPLED_REFLECTION
  17175. 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>>))),
  17176. #else
  17177. ((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)),
  17178. #endif
  17179. source1.Expression,
  17180. GetSourceExpression(source2),
  17181. GetSourceExpression(source3),
  17182. GetSourceExpression(source4),
  17183. GetSourceExpression(source5),
  17184. GetSourceExpression(source6),
  17185. GetSourceExpression(source7),
  17186. GetSourceExpression(source8),
  17187. GetSourceExpression(source9),
  17188. GetSourceExpression(source10),
  17189. GetSourceExpression(source11),
  17190. GetSourceExpression(source12),
  17191. GetSourceExpression(source13),
  17192. GetSourceExpression(source14),
  17193. GetSourceExpression(source15),
  17194. resultSelector
  17195. )
  17196. );
  17197. }
  17198. #endif
  17199. #if !NO_LARGEARITY
  17200. /// <summary>
  17201. /// 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.
  17202. /// </summary>
  17203. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  17204. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  17205. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  17206. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  17207. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  17208. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  17209. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  17210. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  17211. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  17212. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  17213. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  17214. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  17215. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  17216. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  17217. /// <typeparam name="TSource15">The type of the elements in the fifteenth source sequence.</typeparam>
  17218. /// <typeparam name="TSource16">The type of the elements in the sixteenth source sequence.</typeparam>
  17219. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  17220. /// <param name="source1">First observable source.</param>
  17221. /// <param name="source2">Second observable source.</param>
  17222. /// <param name="source3">Third observable source.</param>
  17223. /// <param name="source4">Fourth observable source.</param>
  17224. /// <param name="source5">Fifth observable source.</param>
  17225. /// <param name="source6">Sixth observable source.</param>
  17226. /// <param name="source7">Seventh observable source.</param>
  17227. /// <param name="source8">Eighth observable source.</param>
  17228. /// <param name="source9">Ninth observable source.</param>
  17229. /// <param name="source10">Tenth observable source.</param>
  17230. /// <param name="source11">Eleventh observable source.</param>
  17231. /// <param name="source12">Twelfth observable source.</param>
  17232. /// <param name="source13">Thirteenth observable source.</param>
  17233. /// <param name="source14">Fourteenth observable source.</param>
  17234. /// <param name="source15">Fifteenth observable source.</param>
  17235. /// <param name="source16">Sixteenth observable source.</param>
  17236. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  17237. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  17238. /// <exception cref="T:System.ArgumentNullException">
  17239. /// <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>
  17240. 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)
  17241. {
  17242. if (source1 == null)
  17243. throw new ArgumentNullException("source1");
  17244. if (source2 == null)
  17245. throw new ArgumentNullException("source2");
  17246. if (source3 == null)
  17247. throw new ArgumentNullException("source3");
  17248. if (source4 == null)
  17249. throw new ArgumentNullException("source4");
  17250. if (source5 == null)
  17251. throw new ArgumentNullException("source5");
  17252. if (source6 == null)
  17253. throw new ArgumentNullException("source6");
  17254. if (source7 == null)
  17255. throw new ArgumentNullException("source7");
  17256. if (source8 == null)
  17257. throw new ArgumentNullException("source8");
  17258. if (source9 == null)
  17259. throw new ArgumentNullException("source9");
  17260. if (source10 == null)
  17261. throw new ArgumentNullException("source10");
  17262. if (source11 == null)
  17263. throw new ArgumentNullException("source11");
  17264. if (source12 == null)
  17265. throw new ArgumentNullException("source12");
  17266. if (source13 == null)
  17267. throw new ArgumentNullException("source13");
  17268. if (source14 == null)
  17269. throw new ArgumentNullException("source14");
  17270. if (source15 == null)
  17271. throw new ArgumentNullException("source15");
  17272. if (source16 == null)
  17273. throw new ArgumentNullException("source16");
  17274. if (resultSelector == null)
  17275. throw new ArgumentNullException("resultSelector");
  17276. return source1.Provider.CreateQuery<TResult>(
  17277. Expression.Call(
  17278. null,
  17279. #if CRIPPLED_REFLECTION
  17280. 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>>))),
  17281. #else
  17282. ((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)),
  17283. #endif
  17284. source1.Expression,
  17285. GetSourceExpression(source2),
  17286. GetSourceExpression(source3),
  17287. GetSourceExpression(source4),
  17288. GetSourceExpression(source5),
  17289. GetSourceExpression(source6),
  17290. GetSourceExpression(source7),
  17291. GetSourceExpression(source8),
  17292. GetSourceExpression(source9),
  17293. GetSourceExpression(source10),
  17294. GetSourceExpression(source11),
  17295. GetSourceExpression(source12),
  17296. GetSourceExpression(source13),
  17297. GetSourceExpression(source14),
  17298. GetSourceExpression(source15),
  17299. GetSourceExpression(source16),
  17300. resultSelector
  17301. )
  17302. );
  17303. }
  17304. #endif
  17305. /// <summary>
  17306. /// 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.
  17307. /// </summary>
  17308. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17309. /// <param name="action">Action to convert to an asynchronous action.</param>
  17310. /// <returns>Asynchronous action.</returns>
  17311. /// <exception cref="T:System.ArgumentNullException">
  17312. /// <paramref name="action" /> is null.</exception>
  17313. public static Func<IQbservable<Unit>> ToAsync(this IQbservableProvider provider, Expression<Action> action)
  17314. {
  17315. if (provider == null)
  17316. throw new ArgumentNullException("provider");
  17317. if (action == null)
  17318. throw new ArgumentNullException("action");
  17319. #if CRIPPLED_REFLECTION
  17320. var m = InfoOf(() => Qbservable.ToAsync(default(IQbservableProvider), default(Expression<Action>)));
  17321. #else
  17322. var m = (MethodInfo)MethodInfo.GetCurrentMethod();
  17323. #endif
  17324. return () => provider.CreateQuery<Unit>(
  17325. Expression.Invoke(
  17326. Expression.Call(
  17327. null,
  17328. m,
  17329. Expression.Constant(provider, typeof(IQbservableProvider)),
  17330. action
  17331. )
  17332. )
  17333. );
  17334. }
  17335. /// <summary>
  17336. /// 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.
  17337. /// </summary>
  17338. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17339. /// <param name="action">Action to convert to an asynchronous action.</param>
  17340. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17341. /// <returns>Asynchronous action.</returns>
  17342. /// <exception cref="T:System.ArgumentNullException">
  17343. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17344. public static Func<IQbservable<Unit>> ToAsync(this IQbservableProvider provider, Expression<Action> action, IScheduler scheduler)
  17345. {
  17346. if (provider == null)
  17347. throw new ArgumentNullException("provider");
  17348. if (action == null)
  17349. throw new ArgumentNullException("action");
  17350. if (scheduler == null)
  17351. throw new ArgumentNullException("scheduler");
  17352. #if CRIPPLED_REFLECTION
  17353. var m = InfoOf(() => Qbservable.ToAsync(default(IQbservableProvider), default(Expression<Action>), default(IScheduler)));
  17354. #else
  17355. var m = (MethodInfo)MethodInfo.GetCurrentMethod();
  17356. #endif
  17357. return () => provider.CreateQuery<Unit>(
  17358. Expression.Invoke(
  17359. Expression.Call(
  17360. null,
  17361. m,
  17362. Expression.Constant(provider, typeof(IQbservableProvider)),
  17363. action,
  17364. Expression.Constant(scheduler, typeof(IScheduler))
  17365. )
  17366. )
  17367. );
  17368. }
  17369. /// <summary>
  17370. /// 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.
  17371. /// </summary>
  17372. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17373. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17374. /// <param name="action">Action to convert to an asynchronous action.</param>
  17375. /// <returns>Asynchronous action.</returns>
  17376. /// <exception cref="T:System.ArgumentNullException">
  17377. /// <paramref name="action" /> is null.</exception>
  17378. public static Func<TArg1, IQbservable<Unit>> ToAsync<TArg1>(this IQbservableProvider provider, Expression<Action<TArg1>> action)
  17379. {
  17380. if (provider == null)
  17381. throw new ArgumentNullException("provider");
  17382. if (action == null)
  17383. throw new ArgumentNullException("action");
  17384. #if CRIPPLED_REFLECTION
  17385. var m = InfoOf(() => Qbservable.ToAsync<TArg1>(default(IQbservableProvider), default(Expression<Action<TArg1>>)));
  17386. #else
  17387. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1));
  17388. #endif
  17389. return (t1) => provider.CreateQuery<Unit>(
  17390. Expression.Invoke(
  17391. Expression.Call(
  17392. null,
  17393. m,
  17394. Expression.Constant(provider, typeof(IQbservableProvider)),
  17395. action
  17396. ),
  17397. Expression.Constant(t1, typeof(TArg1))
  17398. )
  17399. );
  17400. }
  17401. /// <summary>
  17402. /// 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.
  17403. /// </summary>
  17404. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17405. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17406. /// <param name="action">Action to convert to an asynchronous action.</param>
  17407. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17408. /// <returns>Asynchronous action.</returns>
  17409. /// <exception cref="T:System.ArgumentNullException">
  17410. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17411. public static Func<TArg1, IQbservable<Unit>> ToAsync<TArg1>(this IQbservableProvider provider, Expression<Action<TArg1>> action, IScheduler scheduler)
  17412. {
  17413. if (provider == null)
  17414. throw new ArgumentNullException("provider");
  17415. if (action == null)
  17416. throw new ArgumentNullException("action");
  17417. if (scheduler == null)
  17418. throw new ArgumentNullException("scheduler");
  17419. #if CRIPPLED_REFLECTION
  17420. var m = InfoOf(() => Qbservable.ToAsync<TArg1>(default(IQbservableProvider), default(Expression<Action<TArg1>>), default(IScheduler)));
  17421. #else
  17422. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1));
  17423. #endif
  17424. return (t1) => provider.CreateQuery<Unit>(
  17425. Expression.Invoke(
  17426. Expression.Call(
  17427. null,
  17428. m,
  17429. Expression.Constant(provider, typeof(IQbservableProvider)),
  17430. action,
  17431. Expression.Constant(scheduler, typeof(IScheduler))
  17432. ),
  17433. Expression.Constant(t1, typeof(TArg1))
  17434. )
  17435. );
  17436. }
  17437. /// <summary>
  17438. /// 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.
  17439. /// </summary>
  17440. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17441. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17442. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17443. /// <param name="action">Action to convert to an asynchronous action.</param>
  17444. /// <returns>Asynchronous action.</returns>
  17445. /// <exception cref="T:System.ArgumentNullException">
  17446. /// <paramref name="action" /> is null.</exception>
  17447. public static Func<TArg1, TArg2, IQbservable<Unit>> ToAsync<TArg1, TArg2>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2>> action)
  17448. {
  17449. if (provider == null)
  17450. throw new ArgumentNullException("provider");
  17451. if (action == null)
  17452. throw new ArgumentNullException("action");
  17453. #if CRIPPLED_REFLECTION
  17454. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2>>)));
  17455. #else
  17456. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2));
  17457. #endif
  17458. return (t1, t2) => provider.CreateQuery<Unit>(
  17459. Expression.Invoke(
  17460. Expression.Call(
  17461. null,
  17462. m,
  17463. Expression.Constant(provider, typeof(IQbservableProvider)),
  17464. action
  17465. ),
  17466. Expression.Constant(t1, typeof(TArg1)),
  17467. Expression.Constant(t2, typeof(TArg2))
  17468. )
  17469. );
  17470. }
  17471. /// <summary>
  17472. /// 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.
  17473. /// </summary>
  17474. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17475. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17476. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17477. /// <param name="action">Action to convert to an asynchronous action.</param>
  17478. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17479. /// <returns>Asynchronous action.</returns>
  17480. /// <exception cref="T:System.ArgumentNullException">
  17481. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17482. public static Func<TArg1, TArg2, IQbservable<Unit>> ToAsync<TArg1, TArg2>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2>> action, IScheduler scheduler)
  17483. {
  17484. if (provider == null)
  17485. throw new ArgumentNullException("provider");
  17486. if (action == null)
  17487. throw new ArgumentNullException("action");
  17488. if (scheduler == null)
  17489. throw new ArgumentNullException("scheduler");
  17490. #if CRIPPLED_REFLECTION
  17491. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2>>), default(IScheduler)));
  17492. #else
  17493. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2));
  17494. #endif
  17495. return (t1, t2) => provider.CreateQuery<Unit>(
  17496. Expression.Invoke(
  17497. Expression.Call(
  17498. null,
  17499. m,
  17500. Expression.Constant(provider, typeof(IQbservableProvider)),
  17501. action,
  17502. Expression.Constant(scheduler, typeof(IScheduler))
  17503. ),
  17504. Expression.Constant(t1, typeof(TArg1)),
  17505. Expression.Constant(t2, typeof(TArg2))
  17506. )
  17507. );
  17508. }
  17509. /// <summary>
  17510. /// 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.
  17511. /// </summary>
  17512. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17513. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17514. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17515. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17516. /// <param name="action">Action to convert to an asynchronous action.</param>
  17517. /// <returns>Asynchronous action.</returns>
  17518. /// <exception cref="T:System.ArgumentNullException">
  17519. /// <paramref name="action" /> is null.</exception>
  17520. public static Func<TArg1, TArg2, TArg3, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3>> action)
  17521. {
  17522. if (provider == null)
  17523. throw new ArgumentNullException("provider");
  17524. if (action == null)
  17525. throw new ArgumentNullException("action");
  17526. #if CRIPPLED_REFLECTION
  17527. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3>>)));
  17528. #else
  17529. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3));
  17530. #endif
  17531. return (t1, t2, t3) => provider.CreateQuery<Unit>(
  17532. Expression.Invoke(
  17533. Expression.Call(
  17534. null,
  17535. m,
  17536. Expression.Constant(provider, typeof(IQbservableProvider)),
  17537. action
  17538. ),
  17539. Expression.Constant(t1, typeof(TArg1)),
  17540. Expression.Constant(t2, typeof(TArg2)),
  17541. Expression.Constant(t3, typeof(TArg3))
  17542. )
  17543. );
  17544. }
  17545. /// <summary>
  17546. /// 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.
  17547. /// </summary>
  17548. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17549. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17550. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17551. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17552. /// <param name="action">Action to convert to an asynchronous action.</param>
  17553. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17554. /// <returns>Asynchronous action.</returns>
  17555. /// <exception cref="T:System.ArgumentNullException">
  17556. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17557. public static Func<TArg1, TArg2, TArg3, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3>> action, IScheduler scheduler)
  17558. {
  17559. if (provider == null)
  17560. throw new ArgumentNullException("provider");
  17561. if (action == null)
  17562. throw new ArgumentNullException("action");
  17563. if (scheduler == null)
  17564. throw new ArgumentNullException("scheduler");
  17565. #if CRIPPLED_REFLECTION
  17566. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3>>), default(IScheduler)));
  17567. #else
  17568. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3));
  17569. #endif
  17570. return (t1, t2, t3) => provider.CreateQuery<Unit>(
  17571. Expression.Invoke(
  17572. Expression.Call(
  17573. null,
  17574. m,
  17575. Expression.Constant(provider, typeof(IQbservableProvider)),
  17576. action,
  17577. Expression.Constant(scheduler, typeof(IScheduler))
  17578. ),
  17579. Expression.Constant(t1, typeof(TArg1)),
  17580. Expression.Constant(t2, typeof(TArg2)),
  17581. Expression.Constant(t3, typeof(TArg3))
  17582. )
  17583. );
  17584. }
  17585. /// <summary>
  17586. /// 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.
  17587. /// </summary>
  17588. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17589. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17590. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17591. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17592. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17593. /// <param name="action">Action to convert to an asynchronous action.</param>
  17594. /// <returns>Asynchronous action.</returns>
  17595. /// <exception cref="T:System.ArgumentNullException">
  17596. /// <paramref name="action" /> is null.</exception>
  17597. public static Func<TArg1, TArg2, TArg3, TArg4, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3, TArg4>> action)
  17598. {
  17599. if (provider == null)
  17600. throw new ArgumentNullException("provider");
  17601. if (action == null)
  17602. throw new ArgumentNullException("action");
  17603. #if CRIPPLED_REFLECTION
  17604. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4>>)));
  17605. #else
  17606. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4));
  17607. #endif
  17608. return (t1, t2, t3, t4) => provider.CreateQuery<Unit>(
  17609. Expression.Invoke(
  17610. Expression.Call(
  17611. null,
  17612. m,
  17613. Expression.Constant(provider, typeof(IQbservableProvider)),
  17614. action
  17615. ),
  17616. Expression.Constant(t1, typeof(TArg1)),
  17617. Expression.Constant(t2, typeof(TArg2)),
  17618. Expression.Constant(t3, typeof(TArg3)),
  17619. Expression.Constant(t4, typeof(TArg4))
  17620. )
  17621. );
  17622. }
  17623. /// <summary>
  17624. /// 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.
  17625. /// </summary>
  17626. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17627. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17628. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17629. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17630. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17631. /// <param name="action">Action to convert to an asynchronous action.</param>
  17632. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17633. /// <returns>Asynchronous action.</returns>
  17634. /// <exception cref="T:System.ArgumentNullException">
  17635. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17636. 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)
  17637. {
  17638. if (provider == null)
  17639. throw new ArgumentNullException("provider");
  17640. if (action == null)
  17641. throw new ArgumentNullException("action");
  17642. if (scheduler == null)
  17643. throw new ArgumentNullException("scheduler");
  17644. #if CRIPPLED_REFLECTION
  17645. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4>>), default(IScheduler)));
  17646. #else
  17647. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4));
  17648. #endif
  17649. return (t1, t2, t3, t4) => provider.CreateQuery<Unit>(
  17650. Expression.Invoke(
  17651. Expression.Call(
  17652. null,
  17653. m,
  17654. Expression.Constant(provider, typeof(IQbservableProvider)),
  17655. action,
  17656. Expression.Constant(scheduler, typeof(IScheduler))
  17657. ),
  17658. Expression.Constant(t1, typeof(TArg1)),
  17659. Expression.Constant(t2, typeof(TArg2)),
  17660. Expression.Constant(t3, typeof(TArg3)),
  17661. Expression.Constant(t4, typeof(TArg4))
  17662. )
  17663. );
  17664. }
  17665. #if !NO_LARGEARITY
  17666. /// <summary>
  17667. /// 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.
  17668. /// </summary>
  17669. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17670. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17671. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17672. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17673. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17674. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  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<TArg1, TArg2, TArg3, TArg4, TArg5, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5>> 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<TArg1, TArg2, TArg3, TArg4, TArg5>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5>>)));
  17687. #else
  17688. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5));
  17689. #endif
  17690. return (t1, t2, t3, t4, t5) => provider.CreateQuery<Unit>(
  17691. Expression.Invoke(
  17692. Expression.Call(
  17693. null,
  17694. m,
  17695. Expression.Constant(provider, typeof(IQbservableProvider)),
  17696. action
  17697. ),
  17698. Expression.Constant(t1, typeof(TArg1)),
  17699. Expression.Constant(t2, typeof(TArg2)),
  17700. Expression.Constant(t3, typeof(TArg3)),
  17701. Expression.Constant(t4, typeof(TArg4)),
  17702. Expression.Constant(t5, typeof(TArg5))
  17703. )
  17704. );
  17705. }
  17706. /// <summary>
  17707. /// 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.
  17708. /// </summary>
  17709. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17710. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17711. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17712. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17713. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17714. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17715. /// <param name="action">Action to convert to an asynchronous action.</param>
  17716. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17717. /// <returns>Asynchronous action.</returns>
  17718. /// <exception cref="T:System.ArgumentNullException">
  17719. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17720. 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)
  17721. {
  17722. if (provider == null)
  17723. throw new ArgumentNullException("provider");
  17724. if (action == null)
  17725. throw new ArgumentNullException("action");
  17726. if (scheduler == null)
  17727. throw new ArgumentNullException("scheduler");
  17728. #if CRIPPLED_REFLECTION
  17729. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5>>), default(IScheduler)));
  17730. #else
  17731. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5));
  17732. #endif
  17733. return (t1, t2, t3, t4, t5) => provider.CreateQuery<Unit>(
  17734. Expression.Invoke(
  17735. Expression.Call(
  17736. null,
  17737. m,
  17738. Expression.Constant(provider, typeof(IQbservableProvider)),
  17739. action,
  17740. Expression.Constant(scheduler, typeof(IScheduler))
  17741. ),
  17742. Expression.Constant(t1, typeof(TArg1)),
  17743. Expression.Constant(t2, typeof(TArg2)),
  17744. Expression.Constant(t3, typeof(TArg3)),
  17745. Expression.Constant(t4, typeof(TArg4)),
  17746. Expression.Constant(t5, typeof(TArg5))
  17747. )
  17748. );
  17749. }
  17750. /// <summary>
  17751. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  17752. /// </summary>
  17753. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17754. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17755. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17756. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17757. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17758. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17759. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  17760. /// <param name="action">Action to convert to an asynchronous action.</param>
  17761. /// <returns>Asynchronous action.</returns>
  17762. /// <exception cref="T:System.ArgumentNullException">
  17763. /// <paramref name="action" /> is null.</exception>
  17764. 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)
  17765. {
  17766. if (provider == null)
  17767. throw new ArgumentNullException("provider");
  17768. if (action == null)
  17769. throw new ArgumentNullException("action");
  17770. #if CRIPPLED_REFLECTION
  17771. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>>)));
  17772. #else
  17773. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6));
  17774. #endif
  17775. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<Unit>(
  17776. Expression.Invoke(
  17777. Expression.Call(
  17778. null,
  17779. m,
  17780. Expression.Constant(provider, typeof(IQbservableProvider)),
  17781. action
  17782. ),
  17783. Expression.Constant(t1, typeof(TArg1)),
  17784. Expression.Constant(t2, typeof(TArg2)),
  17785. Expression.Constant(t3, typeof(TArg3)),
  17786. Expression.Constant(t4, typeof(TArg4)),
  17787. Expression.Constant(t5, typeof(TArg5)),
  17788. Expression.Constant(t6, typeof(TArg6))
  17789. )
  17790. );
  17791. }
  17792. /// <summary>
  17793. /// 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.
  17794. /// </summary>
  17795. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17796. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17797. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17798. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17799. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17800. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17801. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  17802. /// <param name="action">Action to convert to an asynchronous action.</param>
  17803. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17804. /// <returns>Asynchronous action.</returns>
  17805. /// <exception cref="T:System.ArgumentNullException">
  17806. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17807. 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)
  17808. {
  17809. if (provider == null)
  17810. throw new ArgumentNullException("provider");
  17811. if (action == null)
  17812. throw new ArgumentNullException("action");
  17813. if (scheduler == null)
  17814. throw new ArgumentNullException("scheduler");
  17815. #if CRIPPLED_REFLECTION
  17816. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>>), default(IScheduler)));
  17817. #else
  17818. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6));
  17819. #endif
  17820. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<Unit>(
  17821. Expression.Invoke(
  17822. Expression.Call(
  17823. null,
  17824. m,
  17825. Expression.Constant(provider, typeof(IQbservableProvider)),
  17826. action,
  17827. Expression.Constant(scheduler, typeof(IScheduler))
  17828. ),
  17829. Expression.Constant(t1, typeof(TArg1)),
  17830. Expression.Constant(t2, typeof(TArg2)),
  17831. Expression.Constant(t3, typeof(TArg3)),
  17832. Expression.Constant(t4, typeof(TArg4)),
  17833. Expression.Constant(t5, typeof(TArg5)),
  17834. Expression.Constant(t6, typeof(TArg6))
  17835. )
  17836. );
  17837. }
  17838. /// <summary>
  17839. /// 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.
  17840. /// </summary>
  17841. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17842. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17843. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17844. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17845. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17846. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17847. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  17848. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  17849. /// <param name="action">Action to convert to an asynchronous action.</param>
  17850. /// <returns>Asynchronous action.</returns>
  17851. /// <exception cref="T:System.ArgumentNullException">
  17852. /// <paramref name="action" /> is null.</exception>
  17853. 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)
  17854. {
  17855. if (provider == null)
  17856. throw new ArgumentNullException("provider");
  17857. if (action == null)
  17858. throw new ArgumentNullException("action");
  17859. #if CRIPPLED_REFLECTION
  17860. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7>>)));
  17861. #else
  17862. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7));
  17863. #endif
  17864. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<Unit>(
  17865. Expression.Invoke(
  17866. Expression.Call(
  17867. null,
  17868. m,
  17869. Expression.Constant(provider, typeof(IQbservableProvider)),
  17870. action
  17871. ),
  17872. Expression.Constant(t1, typeof(TArg1)),
  17873. Expression.Constant(t2, typeof(TArg2)),
  17874. Expression.Constant(t3, typeof(TArg3)),
  17875. Expression.Constant(t4, typeof(TArg4)),
  17876. Expression.Constant(t5, typeof(TArg5)),
  17877. Expression.Constant(t6, typeof(TArg6)),
  17878. Expression.Constant(t7, typeof(TArg7))
  17879. )
  17880. );
  17881. }
  17882. /// <summary>
  17883. /// 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.
  17884. /// </summary>
  17885. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17886. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17887. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17888. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17889. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17890. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17891. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  17892. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  17893. /// <param name="action">Action to convert to an asynchronous action.</param>
  17894. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17895. /// <returns>Asynchronous action.</returns>
  17896. /// <exception cref="T:System.ArgumentNullException">
  17897. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17898. 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)
  17899. {
  17900. if (provider == null)
  17901. throw new ArgumentNullException("provider");
  17902. if (action == null)
  17903. throw new ArgumentNullException("action");
  17904. if (scheduler == null)
  17905. throw new ArgumentNullException("scheduler");
  17906. #if CRIPPLED_REFLECTION
  17907. 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)));
  17908. #else
  17909. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7));
  17910. #endif
  17911. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<Unit>(
  17912. Expression.Invoke(
  17913. Expression.Call(
  17914. null,
  17915. m,
  17916. Expression.Constant(provider, typeof(IQbservableProvider)),
  17917. action,
  17918. Expression.Constant(scheduler, typeof(IScheduler))
  17919. ),
  17920. Expression.Constant(t1, typeof(TArg1)),
  17921. Expression.Constant(t2, typeof(TArg2)),
  17922. Expression.Constant(t3, typeof(TArg3)),
  17923. Expression.Constant(t4, typeof(TArg4)),
  17924. Expression.Constant(t5, typeof(TArg5)),
  17925. Expression.Constant(t6, typeof(TArg6)),
  17926. Expression.Constant(t7, typeof(TArg7))
  17927. )
  17928. );
  17929. }
  17930. /// <summary>
  17931. /// 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.
  17932. /// </summary>
  17933. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17934. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17935. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17936. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17937. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17938. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17939. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  17940. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  17941. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  17942. /// <param name="action">Action to convert to an asynchronous action.</param>
  17943. /// <returns>Asynchronous action.</returns>
  17944. /// <exception cref="T:System.ArgumentNullException">
  17945. /// <paramref name="action" /> is null.</exception>
  17946. 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)
  17947. {
  17948. if (provider == null)
  17949. throw new ArgumentNullException("provider");
  17950. if (action == null)
  17951. throw new ArgumentNullException("action");
  17952. #if CRIPPLED_REFLECTION
  17953. 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>>)));
  17954. #else
  17955. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8));
  17956. #endif
  17957. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<Unit>(
  17958. Expression.Invoke(
  17959. Expression.Call(
  17960. null,
  17961. m,
  17962. Expression.Constant(provider, typeof(IQbservableProvider)),
  17963. action
  17964. ),
  17965. Expression.Constant(t1, typeof(TArg1)),
  17966. Expression.Constant(t2, typeof(TArg2)),
  17967. Expression.Constant(t3, typeof(TArg3)),
  17968. Expression.Constant(t4, typeof(TArg4)),
  17969. Expression.Constant(t5, typeof(TArg5)),
  17970. Expression.Constant(t6, typeof(TArg6)),
  17971. Expression.Constant(t7, typeof(TArg7)),
  17972. Expression.Constant(t8, typeof(TArg8))
  17973. )
  17974. );
  17975. }
  17976. /// <summary>
  17977. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  17978. /// </summary>
  17979. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  17980. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17981. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17982. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17983. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17984. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17985. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  17986. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  17987. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  17988. /// <param name="action">Action to convert to an asynchronous action.</param>
  17989. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17990. /// <returns>Asynchronous action.</returns>
  17991. /// <exception cref="T:System.ArgumentNullException">
  17992. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17993. 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)
  17994. {
  17995. if (provider == null)
  17996. throw new ArgumentNullException("provider");
  17997. if (action == null)
  17998. throw new ArgumentNullException("action");
  17999. if (scheduler == null)
  18000. throw new ArgumentNullException("scheduler");
  18001. #if CRIPPLED_REFLECTION
  18002. 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)));
  18003. #else
  18004. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8));
  18005. #endif
  18006. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<Unit>(
  18007. Expression.Invoke(
  18008. Expression.Call(
  18009. null,
  18010. m,
  18011. Expression.Constant(provider, typeof(IQbservableProvider)),
  18012. action,
  18013. Expression.Constant(scheduler, typeof(IScheduler))
  18014. ),
  18015. Expression.Constant(t1, typeof(TArg1)),
  18016. Expression.Constant(t2, typeof(TArg2)),
  18017. Expression.Constant(t3, typeof(TArg3)),
  18018. Expression.Constant(t4, typeof(TArg4)),
  18019. Expression.Constant(t5, typeof(TArg5)),
  18020. Expression.Constant(t6, typeof(TArg6)),
  18021. Expression.Constant(t7, typeof(TArg7)),
  18022. Expression.Constant(t8, typeof(TArg8))
  18023. )
  18024. );
  18025. }
  18026. /// <summary>
  18027. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  18028. /// </summary>
  18029. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18030. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18031. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18032. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18033. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18034. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18035. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18036. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18037. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18038. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18039. /// <param name="action">Action to convert to an asynchronous action.</param>
  18040. /// <returns>Asynchronous action.</returns>
  18041. /// <exception cref="T:System.ArgumentNullException">
  18042. /// <paramref name="action" /> is null.</exception>
  18043. 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)
  18044. {
  18045. if (provider == null)
  18046. throw new ArgumentNullException("provider");
  18047. if (action == null)
  18048. throw new ArgumentNullException("action");
  18049. #if CRIPPLED_REFLECTION
  18050. 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>>)));
  18051. #else
  18052. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9));
  18053. #endif
  18054. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<Unit>(
  18055. Expression.Invoke(
  18056. Expression.Call(
  18057. null,
  18058. m,
  18059. Expression.Constant(provider, typeof(IQbservableProvider)),
  18060. action
  18061. ),
  18062. Expression.Constant(t1, typeof(TArg1)),
  18063. Expression.Constant(t2, typeof(TArg2)),
  18064. Expression.Constant(t3, typeof(TArg3)),
  18065. Expression.Constant(t4, typeof(TArg4)),
  18066. Expression.Constant(t5, typeof(TArg5)),
  18067. Expression.Constant(t6, typeof(TArg6)),
  18068. Expression.Constant(t7, typeof(TArg7)),
  18069. Expression.Constant(t8, typeof(TArg8)),
  18070. Expression.Constant(t9, typeof(TArg9))
  18071. )
  18072. );
  18073. }
  18074. /// <summary>
  18075. /// 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.
  18076. /// </summary>
  18077. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18078. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18079. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18080. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18081. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18082. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18083. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18084. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18085. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18086. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18087. /// <param name="action">Action to convert to an asynchronous action.</param>
  18088. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18089. /// <returns>Asynchronous action.</returns>
  18090. /// <exception cref="T:System.ArgumentNullException">
  18091. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18092. 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)
  18093. {
  18094. if (provider == null)
  18095. throw new ArgumentNullException("provider");
  18096. if (action == null)
  18097. throw new ArgumentNullException("action");
  18098. if (scheduler == null)
  18099. throw new ArgumentNullException("scheduler");
  18100. #if CRIPPLED_REFLECTION
  18101. 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)));
  18102. #else
  18103. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9));
  18104. #endif
  18105. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<Unit>(
  18106. Expression.Invoke(
  18107. Expression.Call(
  18108. null,
  18109. m,
  18110. Expression.Constant(provider, typeof(IQbservableProvider)),
  18111. action,
  18112. Expression.Constant(scheduler, typeof(IScheduler))
  18113. ),
  18114. Expression.Constant(t1, typeof(TArg1)),
  18115. Expression.Constant(t2, typeof(TArg2)),
  18116. Expression.Constant(t3, typeof(TArg3)),
  18117. Expression.Constant(t4, typeof(TArg4)),
  18118. Expression.Constant(t5, typeof(TArg5)),
  18119. Expression.Constant(t6, typeof(TArg6)),
  18120. Expression.Constant(t7, typeof(TArg7)),
  18121. Expression.Constant(t8, typeof(TArg8)),
  18122. Expression.Constant(t9, typeof(TArg9))
  18123. )
  18124. );
  18125. }
  18126. /// <summary>
  18127. /// 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.
  18128. /// </summary>
  18129. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18130. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18131. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18132. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18133. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18134. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18135. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18136. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18137. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18138. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18139. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18140. /// <param name="action">Action to convert to an asynchronous action.</param>
  18141. /// <returns>Asynchronous action.</returns>
  18142. /// <exception cref="T:System.ArgumentNullException">
  18143. /// <paramref name="action" /> is null.</exception>
  18144. 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)
  18145. {
  18146. if (provider == null)
  18147. throw new ArgumentNullException("provider");
  18148. if (action == null)
  18149. throw new ArgumentNullException("action");
  18150. #if CRIPPLED_REFLECTION
  18151. 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>>)));
  18152. #else
  18153. 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));
  18154. #endif
  18155. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<Unit>(
  18156. Expression.Invoke(
  18157. Expression.Call(
  18158. null,
  18159. m,
  18160. Expression.Constant(provider, typeof(IQbservableProvider)),
  18161. action
  18162. ),
  18163. Expression.Constant(t1, typeof(TArg1)),
  18164. Expression.Constant(t2, typeof(TArg2)),
  18165. Expression.Constant(t3, typeof(TArg3)),
  18166. Expression.Constant(t4, typeof(TArg4)),
  18167. Expression.Constant(t5, typeof(TArg5)),
  18168. Expression.Constant(t6, typeof(TArg6)),
  18169. Expression.Constant(t7, typeof(TArg7)),
  18170. Expression.Constant(t8, typeof(TArg8)),
  18171. Expression.Constant(t9, typeof(TArg9)),
  18172. Expression.Constant(t10, typeof(TArg10))
  18173. )
  18174. );
  18175. }
  18176. /// <summary>
  18177. /// 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.
  18178. /// </summary>
  18179. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18180. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18181. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18182. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18183. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18184. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18185. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18186. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18187. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18188. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18189. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18190. /// <param name="action">Action to convert to an asynchronous action.</param>
  18191. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18192. /// <returns>Asynchronous action.</returns>
  18193. /// <exception cref="T:System.ArgumentNullException">
  18194. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18195. 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)
  18196. {
  18197. if (provider == null)
  18198. throw new ArgumentNullException("provider");
  18199. if (action == null)
  18200. throw new ArgumentNullException("action");
  18201. if (scheduler == null)
  18202. throw new ArgumentNullException("scheduler");
  18203. #if CRIPPLED_REFLECTION
  18204. 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)));
  18205. #else
  18206. 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));
  18207. #endif
  18208. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<Unit>(
  18209. Expression.Invoke(
  18210. Expression.Call(
  18211. null,
  18212. m,
  18213. Expression.Constant(provider, typeof(IQbservableProvider)),
  18214. action,
  18215. Expression.Constant(scheduler, typeof(IScheduler))
  18216. ),
  18217. Expression.Constant(t1, typeof(TArg1)),
  18218. Expression.Constant(t2, typeof(TArg2)),
  18219. Expression.Constant(t3, typeof(TArg3)),
  18220. Expression.Constant(t4, typeof(TArg4)),
  18221. Expression.Constant(t5, typeof(TArg5)),
  18222. Expression.Constant(t6, typeof(TArg6)),
  18223. Expression.Constant(t7, typeof(TArg7)),
  18224. Expression.Constant(t8, typeof(TArg8)),
  18225. Expression.Constant(t9, typeof(TArg9)),
  18226. Expression.Constant(t10, typeof(TArg10))
  18227. )
  18228. );
  18229. }
  18230. /// <summary>
  18231. /// 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.
  18232. /// </summary>
  18233. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18234. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18235. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18236. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18237. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18238. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18239. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18240. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18241. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18242. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18243. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18244. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18245. /// <param name="action">Action to convert to an asynchronous action.</param>
  18246. /// <returns>Asynchronous action.</returns>
  18247. /// <exception cref="T:System.ArgumentNullException">
  18248. /// <paramref name="action" /> is null.</exception>
  18249. 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)
  18250. {
  18251. if (provider == null)
  18252. throw new ArgumentNullException("provider");
  18253. if (action == null)
  18254. throw new ArgumentNullException("action");
  18255. #if CRIPPLED_REFLECTION
  18256. 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>>)));
  18257. #else
  18258. 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));
  18259. #endif
  18260. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<Unit>(
  18261. Expression.Invoke(
  18262. Expression.Call(
  18263. null,
  18264. m,
  18265. Expression.Constant(provider, typeof(IQbservableProvider)),
  18266. action
  18267. ),
  18268. Expression.Constant(t1, typeof(TArg1)),
  18269. Expression.Constant(t2, typeof(TArg2)),
  18270. Expression.Constant(t3, typeof(TArg3)),
  18271. Expression.Constant(t4, typeof(TArg4)),
  18272. Expression.Constant(t5, typeof(TArg5)),
  18273. Expression.Constant(t6, typeof(TArg6)),
  18274. Expression.Constant(t7, typeof(TArg7)),
  18275. Expression.Constant(t8, typeof(TArg8)),
  18276. Expression.Constant(t9, typeof(TArg9)),
  18277. Expression.Constant(t10, typeof(TArg10)),
  18278. Expression.Constant(t11, typeof(TArg11))
  18279. )
  18280. );
  18281. }
  18282. /// <summary>
  18283. /// 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.
  18284. /// </summary>
  18285. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18286. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18287. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18288. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18289. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18290. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18291. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18292. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18293. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18294. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18295. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18296. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18297. /// <param name="action">Action to convert to an asynchronous action.</param>
  18298. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18299. /// <returns>Asynchronous action.</returns>
  18300. /// <exception cref="T:System.ArgumentNullException">
  18301. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18302. 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)
  18303. {
  18304. if (provider == null)
  18305. throw new ArgumentNullException("provider");
  18306. if (action == null)
  18307. throw new ArgumentNullException("action");
  18308. if (scheduler == null)
  18309. throw new ArgumentNullException("scheduler");
  18310. #if CRIPPLED_REFLECTION
  18311. 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)));
  18312. #else
  18313. 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));
  18314. #endif
  18315. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<Unit>(
  18316. Expression.Invoke(
  18317. Expression.Call(
  18318. null,
  18319. m,
  18320. Expression.Constant(provider, typeof(IQbservableProvider)),
  18321. action,
  18322. Expression.Constant(scheduler, typeof(IScheduler))
  18323. ),
  18324. Expression.Constant(t1, typeof(TArg1)),
  18325. Expression.Constant(t2, typeof(TArg2)),
  18326. Expression.Constant(t3, typeof(TArg3)),
  18327. Expression.Constant(t4, typeof(TArg4)),
  18328. Expression.Constant(t5, typeof(TArg5)),
  18329. Expression.Constant(t6, typeof(TArg6)),
  18330. Expression.Constant(t7, typeof(TArg7)),
  18331. Expression.Constant(t8, typeof(TArg8)),
  18332. Expression.Constant(t9, typeof(TArg9)),
  18333. Expression.Constant(t10, typeof(TArg10)),
  18334. Expression.Constant(t11, typeof(TArg11))
  18335. )
  18336. );
  18337. }
  18338. /// <summary>
  18339. /// 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.
  18340. /// </summary>
  18341. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18342. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18343. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18344. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18345. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18346. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18347. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18348. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18349. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18350. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18351. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18352. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18353. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18354. /// <param name="action">Action to convert to an asynchronous action.</param>
  18355. /// <returns>Asynchronous action.</returns>
  18356. /// <exception cref="T:System.ArgumentNullException">
  18357. /// <paramref name="action" /> is null.</exception>
  18358. 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)
  18359. {
  18360. if (provider == null)
  18361. throw new ArgumentNullException("provider");
  18362. if (action == null)
  18363. throw new ArgumentNullException("action");
  18364. #if CRIPPLED_REFLECTION
  18365. 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>>)));
  18366. #else
  18367. 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));
  18368. #endif
  18369. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<Unit>(
  18370. Expression.Invoke(
  18371. Expression.Call(
  18372. null,
  18373. m,
  18374. Expression.Constant(provider, typeof(IQbservableProvider)),
  18375. action
  18376. ),
  18377. Expression.Constant(t1, typeof(TArg1)),
  18378. Expression.Constant(t2, typeof(TArg2)),
  18379. Expression.Constant(t3, typeof(TArg3)),
  18380. Expression.Constant(t4, typeof(TArg4)),
  18381. Expression.Constant(t5, typeof(TArg5)),
  18382. Expression.Constant(t6, typeof(TArg6)),
  18383. Expression.Constant(t7, typeof(TArg7)),
  18384. Expression.Constant(t8, typeof(TArg8)),
  18385. Expression.Constant(t9, typeof(TArg9)),
  18386. Expression.Constant(t10, typeof(TArg10)),
  18387. Expression.Constant(t11, typeof(TArg11)),
  18388. Expression.Constant(t12, typeof(TArg12))
  18389. )
  18390. );
  18391. }
  18392. /// <summary>
  18393. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  18394. /// </summary>
  18395. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18396. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18397. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18398. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18399. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18400. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18401. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18402. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18403. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18404. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18405. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18406. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18407. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18408. /// <param name="action">Action to convert to an asynchronous action.</param>
  18409. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18410. /// <returns>Asynchronous action.</returns>
  18411. /// <exception cref="T:System.ArgumentNullException">
  18412. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18413. 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)
  18414. {
  18415. if (provider == null)
  18416. throw new ArgumentNullException("provider");
  18417. if (action == null)
  18418. throw new ArgumentNullException("action");
  18419. if (scheduler == null)
  18420. throw new ArgumentNullException("scheduler");
  18421. #if CRIPPLED_REFLECTION
  18422. 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)));
  18423. #else
  18424. 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));
  18425. #endif
  18426. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<Unit>(
  18427. Expression.Invoke(
  18428. Expression.Call(
  18429. null,
  18430. m,
  18431. Expression.Constant(provider, typeof(IQbservableProvider)),
  18432. action,
  18433. Expression.Constant(scheduler, typeof(IScheduler))
  18434. ),
  18435. Expression.Constant(t1, typeof(TArg1)),
  18436. Expression.Constant(t2, typeof(TArg2)),
  18437. Expression.Constant(t3, typeof(TArg3)),
  18438. Expression.Constant(t4, typeof(TArg4)),
  18439. Expression.Constant(t5, typeof(TArg5)),
  18440. Expression.Constant(t6, typeof(TArg6)),
  18441. Expression.Constant(t7, typeof(TArg7)),
  18442. Expression.Constant(t8, typeof(TArg8)),
  18443. Expression.Constant(t9, typeof(TArg9)),
  18444. Expression.Constant(t10, typeof(TArg10)),
  18445. Expression.Constant(t11, typeof(TArg11)),
  18446. Expression.Constant(t12, typeof(TArg12))
  18447. )
  18448. );
  18449. }
  18450. /// <summary>
  18451. /// 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.
  18452. /// </summary>
  18453. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18454. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18455. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18456. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18457. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18458. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18459. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18460. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18461. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18462. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18463. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18464. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18465. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18466. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18467. /// <param name="action">Action to convert to an asynchronous action.</param>
  18468. /// <returns>Asynchronous action.</returns>
  18469. /// <exception cref="T:System.ArgumentNullException">
  18470. /// <paramref name="action" /> is null.</exception>
  18471. 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)
  18472. {
  18473. if (provider == null)
  18474. throw new ArgumentNullException("provider");
  18475. if (action == null)
  18476. throw new ArgumentNullException("action");
  18477. #if CRIPPLED_REFLECTION
  18478. 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>>)));
  18479. #else
  18480. 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));
  18481. #endif
  18482. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<Unit>(
  18483. Expression.Invoke(
  18484. Expression.Call(
  18485. null,
  18486. m,
  18487. Expression.Constant(provider, typeof(IQbservableProvider)),
  18488. action
  18489. ),
  18490. Expression.Constant(t1, typeof(TArg1)),
  18491. Expression.Constant(t2, typeof(TArg2)),
  18492. Expression.Constant(t3, typeof(TArg3)),
  18493. Expression.Constant(t4, typeof(TArg4)),
  18494. Expression.Constant(t5, typeof(TArg5)),
  18495. Expression.Constant(t6, typeof(TArg6)),
  18496. Expression.Constant(t7, typeof(TArg7)),
  18497. Expression.Constant(t8, typeof(TArg8)),
  18498. Expression.Constant(t9, typeof(TArg9)),
  18499. Expression.Constant(t10, typeof(TArg10)),
  18500. Expression.Constant(t11, typeof(TArg11)),
  18501. Expression.Constant(t12, typeof(TArg12)),
  18502. Expression.Constant(t13, typeof(TArg13))
  18503. )
  18504. );
  18505. }
  18506. /// <summary>
  18507. /// 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.
  18508. /// </summary>
  18509. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18510. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18511. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18512. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18513. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18514. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18515. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18516. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18517. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18518. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18519. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18520. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18521. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18522. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18523. /// <param name="action">Action to convert to an asynchronous action.</param>
  18524. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18525. /// <returns>Asynchronous action.</returns>
  18526. /// <exception cref="T:System.ArgumentNullException">
  18527. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18528. 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)
  18529. {
  18530. if (provider == null)
  18531. throw new ArgumentNullException("provider");
  18532. if (action == null)
  18533. throw new ArgumentNullException("action");
  18534. if (scheduler == null)
  18535. throw new ArgumentNullException("scheduler");
  18536. #if CRIPPLED_REFLECTION
  18537. 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)));
  18538. #else
  18539. 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));
  18540. #endif
  18541. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<Unit>(
  18542. Expression.Invoke(
  18543. Expression.Call(
  18544. null,
  18545. m,
  18546. Expression.Constant(provider, typeof(IQbservableProvider)),
  18547. action,
  18548. Expression.Constant(scheduler, typeof(IScheduler))
  18549. ),
  18550. Expression.Constant(t1, typeof(TArg1)),
  18551. Expression.Constant(t2, typeof(TArg2)),
  18552. Expression.Constant(t3, typeof(TArg3)),
  18553. Expression.Constant(t4, typeof(TArg4)),
  18554. Expression.Constant(t5, typeof(TArg5)),
  18555. Expression.Constant(t6, typeof(TArg6)),
  18556. Expression.Constant(t7, typeof(TArg7)),
  18557. Expression.Constant(t8, typeof(TArg8)),
  18558. Expression.Constant(t9, typeof(TArg9)),
  18559. Expression.Constant(t10, typeof(TArg10)),
  18560. Expression.Constant(t11, typeof(TArg11)),
  18561. Expression.Constant(t12, typeof(TArg12)),
  18562. Expression.Constant(t13, typeof(TArg13))
  18563. )
  18564. );
  18565. }
  18566. /// <summary>
  18567. /// 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.
  18568. /// </summary>
  18569. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18570. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18571. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18572. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18573. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18574. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18575. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18576. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18577. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18578. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18579. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18580. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18581. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18582. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18583. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  18584. /// <param name="action">Action to convert to an asynchronous action.</param>
  18585. /// <returns>Asynchronous action.</returns>
  18586. /// <exception cref="T:System.ArgumentNullException">
  18587. /// <paramref name="action" /> is null.</exception>
  18588. 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)
  18589. {
  18590. if (provider == null)
  18591. throw new ArgumentNullException("provider");
  18592. if (action == null)
  18593. throw new ArgumentNullException("action");
  18594. #if CRIPPLED_REFLECTION
  18595. 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>>)));
  18596. #else
  18597. 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));
  18598. #endif
  18599. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<Unit>(
  18600. Expression.Invoke(
  18601. Expression.Call(
  18602. null,
  18603. m,
  18604. Expression.Constant(provider, typeof(IQbservableProvider)),
  18605. action
  18606. ),
  18607. Expression.Constant(t1, typeof(TArg1)),
  18608. Expression.Constant(t2, typeof(TArg2)),
  18609. Expression.Constant(t3, typeof(TArg3)),
  18610. Expression.Constant(t4, typeof(TArg4)),
  18611. Expression.Constant(t5, typeof(TArg5)),
  18612. Expression.Constant(t6, typeof(TArg6)),
  18613. Expression.Constant(t7, typeof(TArg7)),
  18614. Expression.Constant(t8, typeof(TArg8)),
  18615. Expression.Constant(t9, typeof(TArg9)),
  18616. Expression.Constant(t10, typeof(TArg10)),
  18617. Expression.Constant(t11, typeof(TArg11)),
  18618. Expression.Constant(t12, typeof(TArg12)),
  18619. Expression.Constant(t13, typeof(TArg13)),
  18620. Expression.Constant(t14, typeof(TArg14))
  18621. )
  18622. );
  18623. }
  18624. /// <summary>
  18625. /// 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.
  18626. /// </summary>
  18627. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18628. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18629. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18630. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18631. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18632. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18633. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18634. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18635. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18636. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18637. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18638. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18639. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18640. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18641. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  18642. /// <param name="action">Action to convert to an asynchronous action.</param>
  18643. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18644. /// <returns>Asynchronous action.</returns>
  18645. /// <exception cref="T:System.ArgumentNullException">
  18646. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18647. 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)
  18648. {
  18649. if (provider == null)
  18650. throw new ArgumentNullException("provider");
  18651. if (action == null)
  18652. throw new ArgumentNullException("action");
  18653. if (scheduler == null)
  18654. throw new ArgumentNullException("scheduler");
  18655. #if CRIPPLED_REFLECTION
  18656. 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)));
  18657. #else
  18658. 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));
  18659. #endif
  18660. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<Unit>(
  18661. Expression.Invoke(
  18662. Expression.Call(
  18663. null,
  18664. m,
  18665. Expression.Constant(provider, typeof(IQbservableProvider)),
  18666. action,
  18667. Expression.Constant(scheduler, typeof(IScheduler))
  18668. ),
  18669. Expression.Constant(t1, typeof(TArg1)),
  18670. Expression.Constant(t2, typeof(TArg2)),
  18671. Expression.Constant(t3, typeof(TArg3)),
  18672. Expression.Constant(t4, typeof(TArg4)),
  18673. Expression.Constant(t5, typeof(TArg5)),
  18674. Expression.Constant(t6, typeof(TArg6)),
  18675. Expression.Constant(t7, typeof(TArg7)),
  18676. Expression.Constant(t8, typeof(TArg8)),
  18677. Expression.Constant(t9, typeof(TArg9)),
  18678. Expression.Constant(t10, typeof(TArg10)),
  18679. Expression.Constant(t11, typeof(TArg11)),
  18680. Expression.Constant(t12, typeof(TArg12)),
  18681. Expression.Constant(t13, typeof(TArg13)),
  18682. Expression.Constant(t14, typeof(TArg14))
  18683. )
  18684. );
  18685. }
  18686. /// <summary>
  18687. /// 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.
  18688. /// </summary>
  18689. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18690. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18691. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18692. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18693. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18694. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18695. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18696. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18697. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18698. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18699. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18700. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18701. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18702. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18703. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  18704. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the action.</typeparam>
  18705. /// <param name="action">Action to convert to an asynchronous action.</param>
  18706. /// <returns>Asynchronous action.</returns>
  18707. /// <exception cref="T:System.ArgumentNullException">
  18708. /// <paramref name="action" /> is null.</exception>
  18709. 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)
  18710. {
  18711. if (provider == null)
  18712. throw new ArgumentNullException("provider");
  18713. if (action == null)
  18714. throw new ArgumentNullException("action");
  18715. #if CRIPPLED_REFLECTION
  18716. 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>>)));
  18717. #else
  18718. 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));
  18719. #endif
  18720. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) => provider.CreateQuery<Unit>(
  18721. Expression.Invoke(
  18722. Expression.Call(
  18723. null,
  18724. m,
  18725. Expression.Constant(provider, typeof(IQbservableProvider)),
  18726. action
  18727. ),
  18728. Expression.Constant(t1, typeof(TArg1)),
  18729. Expression.Constant(t2, typeof(TArg2)),
  18730. Expression.Constant(t3, typeof(TArg3)),
  18731. Expression.Constant(t4, typeof(TArg4)),
  18732. Expression.Constant(t5, typeof(TArg5)),
  18733. Expression.Constant(t6, typeof(TArg6)),
  18734. Expression.Constant(t7, typeof(TArg7)),
  18735. Expression.Constant(t8, typeof(TArg8)),
  18736. Expression.Constant(t9, typeof(TArg9)),
  18737. Expression.Constant(t10, typeof(TArg10)),
  18738. Expression.Constant(t11, typeof(TArg11)),
  18739. Expression.Constant(t12, typeof(TArg12)),
  18740. Expression.Constant(t13, typeof(TArg13)),
  18741. Expression.Constant(t14, typeof(TArg14)),
  18742. Expression.Constant(t15, typeof(TArg15))
  18743. )
  18744. );
  18745. }
  18746. /// <summary>
  18747. /// 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.
  18748. /// </summary>
  18749. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18750. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18751. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18752. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18753. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18754. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18755. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18756. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18757. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18758. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18759. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18760. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18761. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18762. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18763. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  18764. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the action.</typeparam>
  18765. /// <param name="action">Action to convert to an asynchronous action.</param>
  18766. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18767. /// <returns>Asynchronous action.</returns>
  18768. /// <exception cref="T:System.ArgumentNullException">
  18769. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18770. 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)
  18771. {
  18772. if (provider == null)
  18773. throw new ArgumentNullException("provider");
  18774. if (action == null)
  18775. throw new ArgumentNullException("action");
  18776. if (scheduler == null)
  18777. throw new ArgumentNullException("scheduler");
  18778. #if CRIPPLED_REFLECTION
  18779. 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)));
  18780. #else
  18781. 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));
  18782. #endif
  18783. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) => provider.CreateQuery<Unit>(
  18784. Expression.Invoke(
  18785. Expression.Call(
  18786. null,
  18787. m,
  18788. Expression.Constant(provider, typeof(IQbservableProvider)),
  18789. action,
  18790. Expression.Constant(scheduler, typeof(IScheduler))
  18791. ),
  18792. Expression.Constant(t1, typeof(TArg1)),
  18793. Expression.Constant(t2, typeof(TArg2)),
  18794. Expression.Constant(t3, typeof(TArg3)),
  18795. Expression.Constant(t4, typeof(TArg4)),
  18796. Expression.Constant(t5, typeof(TArg5)),
  18797. Expression.Constant(t6, typeof(TArg6)),
  18798. Expression.Constant(t7, typeof(TArg7)),
  18799. Expression.Constant(t8, typeof(TArg8)),
  18800. Expression.Constant(t9, typeof(TArg9)),
  18801. Expression.Constant(t10, typeof(TArg10)),
  18802. Expression.Constant(t11, typeof(TArg11)),
  18803. Expression.Constant(t12, typeof(TArg12)),
  18804. Expression.Constant(t13, typeof(TArg13)),
  18805. Expression.Constant(t14, typeof(TArg14)),
  18806. Expression.Constant(t15, typeof(TArg15))
  18807. )
  18808. );
  18809. }
  18810. /// <summary>
  18811. /// 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.
  18812. /// </summary>
  18813. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18814. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18815. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18816. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18817. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18818. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18819. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18820. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18821. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18822. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18823. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18824. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18825. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18826. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18827. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  18828. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the action.</typeparam>
  18829. /// <typeparam name="TArg16">The type of the sixteenth argument passed to the action.</typeparam>
  18830. /// <param name="action">Action to convert to an asynchronous action.</param>
  18831. /// <returns>Asynchronous action.</returns>
  18832. /// <exception cref="T:System.ArgumentNullException">
  18833. /// <paramref name="action" /> is null.</exception>
  18834. 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)
  18835. {
  18836. if (provider == null)
  18837. throw new ArgumentNullException("provider");
  18838. if (action == null)
  18839. throw new ArgumentNullException("action");
  18840. #if CRIPPLED_REFLECTION
  18841. 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>>)));
  18842. #else
  18843. 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));
  18844. #endif
  18845. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) => provider.CreateQuery<Unit>(
  18846. Expression.Invoke(
  18847. Expression.Call(
  18848. null,
  18849. m,
  18850. Expression.Constant(provider, typeof(IQbservableProvider)),
  18851. action
  18852. ),
  18853. Expression.Constant(t1, typeof(TArg1)),
  18854. Expression.Constant(t2, typeof(TArg2)),
  18855. Expression.Constant(t3, typeof(TArg3)),
  18856. Expression.Constant(t4, typeof(TArg4)),
  18857. Expression.Constant(t5, typeof(TArg5)),
  18858. Expression.Constant(t6, typeof(TArg6)),
  18859. Expression.Constant(t7, typeof(TArg7)),
  18860. Expression.Constant(t8, typeof(TArg8)),
  18861. Expression.Constant(t9, typeof(TArg9)),
  18862. Expression.Constant(t10, typeof(TArg10)),
  18863. Expression.Constant(t11, typeof(TArg11)),
  18864. Expression.Constant(t12, typeof(TArg12)),
  18865. Expression.Constant(t13, typeof(TArg13)),
  18866. Expression.Constant(t14, typeof(TArg14)),
  18867. Expression.Constant(t15, typeof(TArg15)),
  18868. Expression.Constant(t16, typeof(TArg16))
  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. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  18890. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the action.</typeparam>
  18891. /// <typeparam name="TArg16">The type of the sixteenth argument passed to the action.</typeparam>
  18892. /// <param name="action">Action to convert to an asynchronous action.</param>
  18893. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18894. /// <returns>Asynchronous action.</returns>
  18895. /// <exception cref="T:System.ArgumentNullException">
  18896. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18897. 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)
  18898. {
  18899. if (provider == null)
  18900. throw new ArgumentNullException("provider");
  18901. if (action == null)
  18902. throw new ArgumentNullException("action");
  18903. if (scheduler == null)
  18904. throw new ArgumentNullException("scheduler");
  18905. #if CRIPPLED_REFLECTION
  18906. 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)));
  18907. #else
  18908. 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));
  18909. #endif
  18910. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) => provider.CreateQuery<Unit>(
  18911. Expression.Invoke(
  18912. Expression.Call(
  18913. null,
  18914. m,
  18915. Expression.Constant(provider, typeof(IQbservableProvider)),
  18916. action,
  18917. Expression.Constant(scheduler, typeof(IScheduler))
  18918. ),
  18919. Expression.Constant(t1, typeof(TArg1)),
  18920. Expression.Constant(t2, typeof(TArg2)),
  18921. Expression.Constant(t3, typeof(TArg3)),
  18922. Expression.Constant(t4, typeof(TArg4)),
  18923. Expression.Constant(t5, typeof(TArg5)),
  18924. Expression.Constant(t6, typeof(TArg6)),
  18925. Expression.Constant(t7, typeof(TArg7)),
  18926. Expression.Constant(t8, typeof(TArg8)),
  18927. Expression.Constant(t9, typeof(TArg9)),
  18928. Expression.Constant(t10, typeof(TArg10)),
  18929. Expression.Constant(t11, typeof(TArg11)),
  18930. Expression.Constant(t12, typeof(TArg12)),
  18931. Expression.Constant(t13, typeof(TArg13)),
  18932. Expression.Constant(t14, typeof(TArg14)),
  18933. Expression.Constant(t15, typeof(TArg15)),
  18934. Expression.Constant(t16, typeof(TArg16))
  18935. )
  18936. );
  18937. }
  18938. #endif
  18939. /// <summary>
  18940. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  18941. /// </summary>
  18942. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18943. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  18944. /// <param name="function">Function to convert to an asynchronous function.</param>
  18945. /// <returns>Asynchronous function.</returns>
  18946. /// <exception cref="T:System.ArgumentNullException">
  18947. /// <paramref name="function" /> is null.</exception>
  18948. public static Func<IQbservable<TResult>> ToAsync<TResult>(this IQbservableProvider provider, Expression<Func<TResult>> function)
  18949. {
  18950. if (provider == null)
  18951. throw new ArgumentNullException("provider");
  18952. if (function == null)
  18953. throw new ArgumentNullException("function");
  18954. #if CRIPPLED_REFLECTION
  18955. var m = InfoOf(() => Qbservable.ToAsync<TResult>(default(IQbservableProvider), default(Expression<Func<TResult>>)));
  18956. #else
  18957. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult));
  18958. #endif
  18959. return () => provider.CreateQuery<TResult>(
  18960. Expression.Invoke(
  18961. Expression.Call(
  18962. null,
  18963. m,
  18964. Expression.Constant(provider, typeof(IQbservableProvider)),
  18965. function
  18966. )
  18967. )
  18968. );
  18969. }
  18970. /// <summary>
  18971. /// 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.
  18972. /// </summary>
  18973. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  18974. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  18975. /// <param name="function">Function to convert to an asynchronous function.</param>
  18976. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  18977. /// <returns>Asynchronous function.</returns>
  18978. /// <exception cref="T:System.ArgumentNullException">
  18979. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  18980. public static Func<IQbservable<TResult>> ToAsync<TResult>(this IQbservableProvider provider, Expression<Func<TResult>> function, IScheduler scheduler)
  18981. {
  18982. if (provider == null)
  18983. throw new ArgumentNullException("provider");
  18984. if (function == null)
  18985. throw new ArgumentNullException("function");
  18986. if (scheduler == null)
  18987. throw new ArgumentNullException("scheduler");
  18988. #if CRIPPLED_REFLECTION
  18989. var m = InfoOf(() => Qbservable.ToAsync<TResult>(default(IQbservableProvider), default(Expression<Func<TResult>>), default(IScheduler)));
  18990. #else
  18991. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult));
  18992. #endif
  18993. return () => provider.CreateQuery<TResult>(
  18994. Expression.Invoke(
  18995. Expression.Call(
  18996. null,
  18997. m,
  18998. Expression.Constant(provider, typeof(IQbservableProvider)),
  18999. function,
  19000. Expression.Constant(scheduler, typeof(IScheduler))
  19001. )
  19002. )
  19003. );
  19004. }
  19005. /// <summary>
  19006. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19007. /// </summary>
  19008. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19009. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19010. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19011. /// <param name="function">Function to convert to an asynchronous function.</param>
  19012. /// <returns>Asynchronous function.</returns>
  19013. /// <exception cref="T:System.ArgumentNullException">
  19014. /// <paramref name="function" /> is null.</exception>
  19015. public static Func<TArg1, IQbservable<TResult>> ToAsync<TArg1, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TResult>> function)
  19016. {
  19017. if (provider == null)
  19018. throw new ArgumentNullException("provider");
  19019. if (function == null)
  19020. throw new ArgumentNullException("function");
  19021. #if CRIPPLED_REFLECTION
  19022. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TResult>>)));
  19023. #else
  19024. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TResult));
  19025. #endif
  19026. return (t1) => provider.CreateQuery<TResult>(
  19027. Expression.Invoke(
  19028. Expression.Call(
  19029. null,
  19030. m,
  19031. Expression.Constant(provider, typeof(IQbservableProvider)),
  19032. function
  19033. ),
  19034. Expression.Constant(t1, typeof(TArg1))
  19035. )
  19036. );
  19037. }
  19038. /// <summary>
  19039. /// 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.
  19040. /// </summary>
  19041. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19042. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19043. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19044. /// <param name="function">Function to convert to an asynchronous function.</param>
  19045. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19046. /// <returns>Asynchronous function.</returns>
  19047. /// <exception cref="T:System.ArgumentNullException">
  19048. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19049. public static Func<TArg1, IQbservable<TResult>> ToAsync<TArg1, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TResult>> function, IScheduler scheduler)
  19050. {
  19051. if (provider == null)
  19052. throw new ArgumentNullException("provider");
  19053. if (function == null)
  19054. throw new ArgumentNullException("function");
  19055. if (scheduler == null)
  19056. throw new ArgumentNullException("scheduler");
  19057. #if CRIPPLED_REFLECTION
  19058. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TResult>>), default(IScheduler)));
  19059. #else
  19060. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TResult));
  19061. #endif
  19062. return (t1) => provider.CreateQuery<TResult>(
  19063. Expression.Invoke(
  19064. Expression.Call(
  19065. null,
  19066. m,
  19067. Expression.Constant(provider, typeof(IQbservableProvider)),
  19068. function,
  19069. Expression.Constant(scheduler, typeof(IScheduler))
  19070. ),
  19071. Expression.Constant(t1, typeof(TArg1))
  19072. )
  19073. );
  19074. }
  19075. /// <summary>
  19076. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19077. /// </summary>
  19078. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19079. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19080. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19081. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19082. /// <param name="function">Function to convert to an asynchronous function.</param>
  19083. /// <returns>Asynchronous function.</returns>
  19084. /// <exception cref="T:System.ArgumentNullException">
  19085. /// <paramref name="function" /> is null.</exception>
  19086. public static Func<TArg1, TArg2, IQbservable<TResult>> ToAsync<TArg1, TArg2, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TResult>> function)
  19087. {
  19088. if (provider == null)
  19089. throw new ArgumentNullException("provider");
  19090. if (function == null)
  19091. throw new ArgumentNullException("function");
  19092. #if CRIPPLED_REFLECTION
  19093. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TResult>>)));
  19094. #else
  19095. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TResult));
  19096. #endif
  19097. return (t1, t2) => provider.CreateQuery<TResult>(
  19098. Expression.Invoke(
  19099. Expression.Call(
  19100. null,
  19101. m,
  19102. Expression.Constant(provider, typeof(IQbservableProvider)),
  19103. function
  19104. ),
  19105. Expression.Constant(t1, typeof(TArg1)),
  19106. Expression.Constant(t2, typeof(TArg2))
  19107. )
  19108. );
  19109. }
  19110. /// <summary>
  19111. /// 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.
  19112. /// </summary>
  19113. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19114. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19115. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19116. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19117. /// <param name="function">Function to convert to an asynchronous function.</param>
  19118. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19119. /// <returns>Asynchronous function.</returns>
  19120. /// <exception cref="T:System.ArgumentNullException">
  19121. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19122. public static Func<TArg1, TArg2, IQbservable<TResult>> ToAsync<TArg1, TArg2, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TResult>> function, IScheduler scheduler)
  19123. {
  19124. if (provider == null)
  19125. throw new ArgumentNullException("provider");
  19126. if (function == null)
  19127. throw new ArgumentNullException("function");
  19128. if (scheduler == null)
  19129. throw new ArgumentNullException("scheduler");
  19130. #if CRIPPLED_REFLECTION
  19131. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TResult>>), default(IScheduler)));
  19132. #else
  19133. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TResult));
  19134. #endif
  19135. return (t1, t2) => provider.CreateQuery<TResult>(
  19136. Expression.Invoke(
  19137. Expression.Call(
  19138. null,
  19139. m,
  19140. Expression.Constant(provider, typeof(IQbservableProvider)),
  19141. function,
  19142. Expression.Constant(scheduler, typeof(IScheduler))
  19143. ),
  19144. Expression.Constant(t1, typeof(TArg1)),
  19145. Expression.Constant(t2, typeof(TArg2))
  19146. )
  19147. );
  19148. }
  19149. /// <summary>
  19150. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19151. /// </summary>
  19152. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19153. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19154. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19155. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19156. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19157. /// <param name="function">Function to convert to an asynchronous function.</param>
  19158. /// <returns>Asynchronous function.</returns>
  19159. /// <exception cref="T:System.ArgumentNullException">
  19160. /// <paramref name="function" /> is null.</exception>
  19161. public static Func<TArg1, TArg2, TArg3, IQbservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TResult>> function)
  19162. {
  19163. if (provider == null)
  19164. throw new ArgumentNullException("provider");
  19165. if (function == null)
  19166. throw new ArgumentNullException("function");
  19167. #if CRIPPLED_REFLECTION
  19168. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TResult>>)));
  19169. #else
  19170. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TResult));
  19171. #endif
  19172. return (t1, t2, t3) => provider.CreateQuery<TResult>(
  19173. Expression.Invoke(
  19174. Expression.Call(
  19175. null,
  19176. m,
  19177. Expression.Constant(provider, typeof(IQbservableProvider)),
  19178. function
  19179. ),
  19180. Expression.Constant(t1, typeof(TArg1)),
  19181. Expression.Constant(t2, typeof(TArg2)),
  19182. Expression.Constant(t3, typeof(TArg3))
  19183. )
  19184. );
  19185. }
  19186. /// <summary>
  19187. /// 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.
  19188. /// </summary>
  19189. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19190. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19191. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19192. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19193. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19194. /// <param name="function">Function to convert to an asynchronous function.</param>
  19195. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19196. /// <returns>Asynchronous function.</returns>
  19197. /// <exception cref="T:System.ArgumentNullException">
  19198. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19199. 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)
  19200. {
  19201. if (provider == null)
  19202. throw new ArgumentNullException("provider");
  19203. if (function == null)
  19204. throw new ArgumentNullException("function");
  19205. if (scheduler == null)
  19206. throw new ArgumentNullException("scheduler");
  19207. #if CRIPPLED_REFLECTION
  19208. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TResult>>), default(IScheduler)));
  19209. #else
  19210. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TResult));
  19211. #endif
  19212. return (t1, t2, t3) => provider.CreateQuery<TResult>(
  19213. Expression.Invoke(
  19214. Expression.Call(
  19215. null,
  19216. m,
  19217. Expression.Constant(provider, typeof(IQbservableProvider)),
  19218. function,
  19219. Expression.Constant(scheduler, typeof(IScheduler))
  19220. ),
  19221. Expression.Constant(t1, typeof(TArg1)),
  19222. Expression.Constant(t2, typeof(TArg2)),
  19223. Expression.Constant(t3, typeof(TArg3))
  19224. )
  19225. );
  19226. }
  19227. /// <summary>
  19228. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19229. /// </summary>
  19230. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19231. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19232. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19233. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19234. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19235. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19236. /// <param name="function">Function to convert to an asynchronous function.</param>
  19237. /// <returns>Asynchronous function.</returns>
  19238. /// <exception cref="T:System.ArgumentNullException">
  19239. /// <paramref name="function" /> is null.</exception>
  19240. 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)
  19241. {
  19242. if (provider == null)
  19243. throw new ArgumentNullException("provider");
  19244. if (function == null)
  19245. throw new ArgumentNullException("function");
  19246. #if CRIPPLED_REFLECTION
  19247. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TResult>>)));
  19248. #else
  19249. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TResult));
  19250. #endif
  19251. return (t1, t2, t3, t4) => provider.CreateQuery<TResult>(
  19252. Expression.Invoke(
  19253. Expression.Call(
  19254. null,
  19255. m,
  19256. Expression.Constant(provider, typeof(IQbservableProvider)),
  19257. function
  19258. ),
  19259. Expression.Constant(t1, typeof(TArg1)),
  19260. Expression.Constant(t2, typeof(TArg2)),
  19261. Expression.Constant(t3, typeof(TArg3)),
  19262. Expression.Constant(t4, typeof(TArg4))
  19263. )
  19264. );
  19265. }
  19266. /// <summary>
  19267. /// 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.
  19268. /// </summary>
  19269. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19270. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19271. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19272. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19273. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19274. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19275. /// <param name="function">Function to convert to an asynchronous function.</param>
  19276. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19277. /// <returns>Asynchronous function.</returns>
  19278. /// <exception cref="T:System.ArgumentNullException">
  19279. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19280. 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)
  19281. {
  19282. if (provider == null)
  19283. throw new ArgumentNullException("provider");
  19284. if (function == null)
  19285. throw new ArgumentNullException("function");
  19286. if (scheduler == null)
  19287. throw new ArgumentNullException("scheduler");
  19288. #if CRIPPLED_REFLECTION
  19289. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TResult>>), default(IScheduler)));
  19290. #else
  19291. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TResult));
  19292. #endif
  19293. return (t1, t2, t3, t4) => provider.CreateQuery<TResult>(
  19294. Expression.Invoke(
  19295. Expression.Call(
  19296. null,
  19297. m,
  19298. Expression.Constant(provider, typeof(IQbservableProvider)),
  19299. function,
  19300. Expression.Constant(scheduler, typeof(IScheduler))
  19301. ),
  19302. Expression.Constant(t1, typeof(TArg1)),
  19303. Expression.Constant(t2, typeof(TArg2)),
  19304. Expression.Constant(t3, typeof(TArg3)),
  19305. Expression.Constant(t4, typeof(TArg4))
  19306. )
  19307. );
  19308. }
  19309. #if !NO_LARGEARITY
  19310. /// <summary>
  19311. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19312. /// </summary>
  19313. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19314. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19315. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19316. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19317. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19318. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19319. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19320. /// <param name="function">Function to convert to an asynchronous function.</param>
  19321. /// <returns>Asynchronous function.</returns>
  19322. /// <exception cref="T:System.ArgumentNullException">
  19323. /// <paramref name="function" /> is null.</exception>
  19324. 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)
  19325. {
  19326. if (provider == null)
  19327. throw new ArgumentNullException("provider");
  19328. if (function == null)
  19329. throw new ArgumentNullException("function");
  19330. #if CRIPPLED_REFLECTION
  19331. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>>)));
  19332. #else
  19333. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TResult));
  19334. #endif
  19335. return (t1, t2, t3, t4, t5) => provider.CreateQuery<TResult>(
  19336. Expression.Invoke(
  19337. Expression.Call(
  19338. null,
  19339. m,
  19340. Expression.Constant(provider, typeof(IQbservableProvider)),
  19341. function
  19342. ),
  19343. Expression.Constant(t1, typeof(TArg1)),
  19344. Expression.Constant(t2, typeof(TArg2)),
  19345. Expression.Constant(t3, typeof(TArg3)),
  19346. Expression.Constant(t4, typeof(TArg4)),
  19347. Expression.Constant(t5, typeof(TArg5))
  19348. )
  19349. );
  19350. }
  19351. /// <summary>
  19352. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  19353. /// </summary>
  19354. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19355. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19356. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19357. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19358. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19359. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19360. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19361. /// <param name="function">Function to convert to an asynchronous function.</param>
  19362. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19363. /// <returns>Asynchronous function.</returns>
  19364. /// <exception cref="T:System.ArgumentNullException">
  19365. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19366. 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)
  19367. {
  19368. if (provider == null)
  19369. throw new ArgumentNullException("provider");
  19370. if (function == null)
  19371. throw new ArgumentNullException("function");
  19372. if (scheduler == null)
  19373. throw new ArgumentNullException("scheduler");
  19374. #if CRIPPLED_REFLECTION
  19375. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>>), default(IScheduler)));
  19376. #else
  19377. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TResult));
  19378. #endif
  19379. return (t1, t2, t3, t4, t5) => provider.CreateQuery<TResult>(
  19380. Expression.Invoke(
  19381. Expression.Call(
  19382. null,
  19383. m,
  19384. Expression.Constant(provider, typeof(IQbservableProvider)),
  19385. function,
  19386. Expression.Constant(scheduler, typeof(IScheduler))
  19387. ),
  19388. Expression.Constant(t1, typeof(TArg1)),
  19389. Expression.Constant(t2, typeof(TArg2)),
  19390. Expression.Constant(t3, typeof(TArg3)),
  19391. Expression.Constant(t4, typeof(TArg4)),
  19392. Expression.Constant(t5, typeof(TArg5))
  19393. )
  19394. );
  19395. }
  19396. /// <summary>
  19397. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19398. /// </summary>
  19399. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19400. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19401. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19402. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19403. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19404. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19405. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19406. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19407. /// <param name="function">Function to convert to an asynchronous function.</param>
  19408. /// <returns>Asynchronous function.</returns>
  19409. /// <exception cref="T:System.ArgumentNullException">
  19410. /// <paramref name="function" /> is null.</exception>
  19411. 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)
  19412. {
  19413. if (provider == null)
  19414. throw new ArgumentNullException("provider");
  19415. if (function == null)
  19416. throw new ArgumentNullException("function");
  19417. #if CRIPPLED_REFLECTION
  19418. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TResult>>)));
  19419. #else
  19420. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TResult));
  19421. #endif
  19422. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<TResult>(
  19423. Expression.Invoke(
  19424. Expression.Call(
  19425. null,
  19426. m,
  19427. Expression.Constant(provider, typeof(IQbservableProvider)),
  19428. function
  19429. ),
  19430. Expression.Constant(t1, typeof(TArg1)),
  19431. Expression.Constant(t2, typeof(TArg2)),
  19432. Expression.Constant(t3, typeof(TArg3)),
  19433. Expression.Constant(t4, typeof(TArg4)),
  19434. Expression.Constant(t5, typeof(TArg5)),
  19435. Expression.Constant(t6, typeof(TArg6))
  19436. )
  19437. );
  19438. }
  19439. /// <summary>
  19440. /// 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.
  19441. /// </summary>
  19442. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19443. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19444. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19445. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19446. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19447. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19448. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19449. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19450. /// <param name="function">Function to convert to an asynchronous function.</param>
  19451. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19452. /// <returns>Asynchronous function.</returns>
  19453. /// <exception cref="T:System.ArgumentNullException">
  19454. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19455. 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)
  19456. {
  19457. if (provider == null)
  19458. throw new ArgumentNullException("provider");
  19459. if (function == null)
  19460. throw new ArgumentNullException("function");
  19461. if (scheduler == null)
  19462. throw new ArgumentNullException("scheduler");
  19463. #if CRIPPLED_REFLECTION
  19464. 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)));
  19465. #else
  19466. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TResult));
  19467. #endif
  19468. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<TResult>(
  19469. Expression.Invoke(
  19470. Expression.Call(
  19471. null,
  19472. m,
  19473. Expression.Constant(provider, typeof(IQbservableProvider)),
  19474. function,
  19475. Expression.Constant(scheduler, typeof(IScheduler))
  19476. ),
  19477. Expression.Constant(t1, typeof(TArg1)),
  19478. Expression.Constant(t2, typeof(TArg2)),
  19479. Expression.Constant(t3, typeof(TArg3)),
  19480. Expression.Constant(t4, typeof(TArg4)),
  19481. Expression.Constant(t5, typeof(TArg5)),
  19482. Expression.Constant(t6, typeof(TArg6))
  19483. )
  19484. );
  19485. }
  19486. /// <summary>
  19487. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19488. /// </summary>
  19489. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19490. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19491. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19492. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19493. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19494. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19495. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19496. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19497. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19498. /// <param name="function">Function to convert to an asynchronous function.</param>
  19499. /// <returns>Asynchronous function.</returns>
  19500. /// <exception cref="T:System.ArgumentNullException">
  19501. /// <paramref name="function" /> is null.</exception>
  19502. 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)
  19503. {
  19504. if (provider == null)
  19505. throw new ArgumentNullException("provider");
  19506. if (function == null)
  19507. throw new ArgumentNullException("function");
  19508. #if CRIPPLED_REFLECTION
  19509. 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>>)));
  19510. #else
  19511. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TResult));
  19512. #endif
  19513. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<TResult>(
  19514. Expression.Invoke(
  19515. Expression.Call(
  19516. null,
  19517. m,
  19518. Expression.Constant(provider, typeof(IQbservableProvider)),
  19519. function
  19520. ),
  19521. Expression.Constant(t1, typeof(TArg1)),
  19522. Expression.Constant(t2, typeof(TArg2)),
  19523. Expression.Constant(t3, typeof(TArg3)),
  19524. Expression.Constant(t4, typeof(TArg4)),
  19525. Expression.Constant(t5, typeof(TArg5)),
  19526. Expression.Constant(t6, typeof(TArg6)),
  19527. Expression.Constant(t7, typeof(TArg7))
  19528. )
  19529. );
  19530. }
  19531. /// <summary>
  19532. /// 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.
  19533. /// </summary>
  19534. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19535. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19536. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19537. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19538. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19539. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19540. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19541. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19542. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19543. /// <param name="function">Function to convert to an asynchronous function.</param>
  19544. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19545. /// <returns>Asynchronous function.</returns>
  19546. /// <exception cref="T:System.ArgumentNullException">
  19547. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19548. 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)
  19549. {
  19550. if (provider == null)
  19551. throw new ArgumentNullException("provider");
  19552. if (function == null)
  19553. throw new ArgumentNullException("function");
  19554. if (scheduler == null)
  19555. throw new ArgumentNullException("scheduler");
  19556. #if CRIPPLED_REFLECTION
  19557. 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)));
  19558. #else
  19559. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TResult));
  19560. #endif
  19561. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<TResult>(
  19562. Expression.Invoke(
  19563. Expression.Call(
  19564. null,
  19565. m,
  19566. Expression.Constant(provider, typeof(IQbservableProvider)),
  19567. function,
  19568. Expression.Constant(scheduler, typeof(IScheduler))
  19569. ),
  19570. Expression.Constant(t1, typeof(TArg1)),
  19571. Expression.Constant(t2, typeof(TArg2)),
  19572. Expression.Constant(t3, typeof(TArg3)),
  19573. Expression.Constant(t4, typeof(TArg4)),
  19574. Expression.Constant(t5, typeof(TArg5)),
  19575. Expression.Constant(t6, typeof(TArg6)),
  19576. Expression.Constant(t7, typeof(TArg7))
  19577. )
  19578. );
  19579. }
  19580. /// <summary>
  19581. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19582. /// </summary>
  19583. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19584. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19585. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19586. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19587. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19588. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19589. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19590. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19591. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19592. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19593. /// <param name="function">Function to convert to an asynchronous function.</param>
  19594. /// <returns>Asynchronous function.</returns>
  19595. /// <exception cref="T:System.ArgumentNullException">
  19596. /// <paramref name="function" /> is null.</exception>
  19597. 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)
  19598. {
  19599. if (provider == null)
  19600. throw new ArgumentNullException("provider");
  19601. if (function == null)
  19602. throw new ArgumentNullException("function");
  19603. #if CRIPPLED_REFLECTION
  19604. 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>>)));
  19605. #else
  19606. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TResult));
  19607. #endif
  19608. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<TResult>(
  19609. Expression.Invoke(
  19610. Expression.Call(
  19611. null,
  19612. m,
  19613. Expression.Constant(provider, typeof(IQbservableProvider)),
  19614. function
  19615. ),
  19616. Expression.Constant(t1, typeof(TArg1)),
  19617. Expression.Constant(t2, typeof(TArg2)),
  19618. Expression.Constant(t3, typeof(TArg3)),
  19619. Expression.Constant(t4, typeof(TArg4)),
  19620. Expression.Constant(t5, typeof(TArg5)),
  19621. Expression.Constant(t6, typeof(TArg6)),
  19622. Expression.Constant(t7, typeof(TArg7)),
  19623. Expression.Constant(t8, typeof(TArg8))
  19624. )
  19625. );
  19626. }
  19627. /// <summary>
  19628. /// 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.
  19629. /// </summary>
  19630. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19631. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19632. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19633. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19634. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19635. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19636. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19637. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19638. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19639. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19640. /// <param name="function">Function to convert to an asynchronous function.</param>
  19641. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19642. /// <returns>Asynchronous function.</returns>
  19643. /// <exception cref="T:System.ArgumentNullException">
  19644. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19645. 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)
  19646. {
  19647. if (provider == null)
  19648. throw new ArgumentNullException("provider");
  19649. if (function == null)
  19650. throw new ArgumentNullException("function");
  19651. if (scheduler == null)
  19652. throw new ArgumentNullException("scheduler");
  19653. #if CRIPPLED_REFLECTION
  19654. 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)));
  19655. #else
  19656. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TResult));
  19657. #endif
  19658. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<TResult>(
  19659. Expression.Invoke(
  19660. Expression.Call(
  19661. null,
  19662. m,
  19663. Expression.Constant(provider, typeof(IQbservableProvider)),
  19664. function,
  19665. Expression.Constant(scheduler, typeof(IScheduler))
  19666. ),
  19667. Expression.Constant(t1, typeof(TArg1)),
  19668. Expression.Constant(t2, typeof(TArg2)),
  19669. Expression.Constant(t3, typeof(TArg3)),
  19670. Expression.Constant(t4, typeof(TArg4)),
  19671. Expression.Constant(t5, typeof(TArg5)),
  19672. Expression.Constant(t6, typeof(TArg6)),
  19673. Expression.Constant(t7, typeof(TArg7)),
  19674. Expression.Constant(t8, typeof(TArg8))
  19675. )
  19676. );
  19677. }
  19678. /// <summary>
  19679. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19680. /// </summary>
  19681. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19682. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19683. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19684. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19685. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19686. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19687. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19688. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19689. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19690. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  19691. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19692. /// <param name="function">Function to convert to an asynchronous function.</param>
  19693. /// <returns>Asynchronous function.</returns>
  19694. /// <exception cref="T:System.ArgumentNullException">
  19695. /// <paramref name="function" /> is null.</exception>
  19696. 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)
  19697. {
  19698. if (provider == null)
  19699. throw new ArgumentNullException("provider");
  19700. if (function == null)
  19701. throw new ArgumentNullException("function");
  19702. #if CRIPPLED_REFLECTION
  19703. 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>>)));
  19704. #else
  19705. 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));
  19706. #endif
  19707. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<TResult>(
  19708. Expression.Invoke(
  19709. Expression.Call(
  19710. null,
  19711. m,
  19712. Expression.Constant(provider, typeof(IQbservableProvider)),
  19713. function
  19714. ),
  19715. Expression.Constant(t1, typeof(TArg1)),
  19716. Expression.Constant(t2, typeof(TArg2)),
  19717. Expression.Constant(t3, typeof(TArg3)),
  19718. Expression.Constant(t4, typeof(TArg4)),
  19719. Expression.Constant(t5, typeof(TArg5)),
  19720. Expression.Constant(t6, typeof(TArg6)),
  19721. Expression.Constant(t7, typeof(TArg7)),
  19722. Expression.Constant(t8, typeof(TArg8)),
  19723. Expression.Constant(t9, typeof(TArg9))
  19724. )
  19725. );
  19726. }
  19727. /// <summary>
  19728. /// 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.
  19729. /// </summary>
  19730. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19731. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19732. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19733. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19734. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19735. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19736. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19737. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19738. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19739. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  19740. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19741. /// <param name="function">Function to convert to an asynchronous function.</param>
  19742. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19743. /// <returns>Asynchronous function.</returns>
  19744. /// <exception cref="T:System.ArgumentNullException">
  19745. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19746. 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)
  19747. {
  19748. if (provider == null)
  19749. throw new ArgumentNullException("provider");
  19750. if (function == null)
  19751. throw new ArgumentNullException("function");
  19752. if (scheduler == null)
  19753. throw new ArgumentNullException("scheduler");
  19754. #if CRIPPLED_REFLECTION
  19755. 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)));
  19756. #else
  19757. 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));
  19758. #endif
  19759. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<TResult>(
  19760. Expression.Invoke(
  19761. Expression.Call(
  19762. null,
  19763. m,
  19764. Expression.Constant(provider, typeof(IQbservableProvider)),
  19765. function,
  19766. Expression.Constant(scheduler, typeof(IScheduler))
  19767. ),
  19768. Expression.Constant(t1, typeof(TArg1)),
  19769. Expression.Constant(t2, typeof(TArg2)),
  19770. Expression.Constant(t3, typeof(TArg3)),
  19771. Expression.Constant(t4, typeof(TArg4)),
  19772. Expression.Constant(t5, typeof(TArg5)),
  19773. Expression.Constant(t6, typeof(TArg6)),
  19774. Expression.Constant(t7, typeof(TArg7)),
  19775. Expression.Constant(t8, typeof(TArg8)),
  19776. Expression.Constant(t9, typeof(TArg9))
  19777. )
  19778. );
  19779. }
  19780. /// <summary>
  19781. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19782. /// </summary>
  19783. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19784. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19785. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19786. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19787. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19788. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19789. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19790. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19791. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19792. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  19793. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  19794. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19795. /// <param name="function">Function to convert to an asynchronous function.</param>
  19796. /// <returns>Asynchronous function.</returns>
  19797. /// <exception cref="T:System.ArgumentNullException">
  19798. /// <paramref name="function" /> is null.</exception>
  19799. 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)
  19800. {
  19801. if (provider == null)
  19802. throw new ArgumentNullException("provider");
  19803. if (function == null)
  19804. throw new ArgumentNullException("function");
  19805. #if CRIPPLED_REFLECTION
  19806. 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>>)));
  19807. #else
  19808. 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));
  19809. #endif
  19810. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<TResult>(
  19811. Expression.Invoke(
  19812. Expression.Call(
  19813. null,
  19814. m,
  19815. Expression.Constant(provider, typeof(IQbservableProvider)),
  19816. function
  19817. ),
  19818. Expression.Constant(t1, typeof(TArg1)),
  19819. Expression.Constant(t2, typeof(TArg2)),
  19820. Expression.Constant(t3, typeof(TArg3)),
  19821. Expression.Constant(t4, typeof(TArg4)),
  19822. Expression.Constant(t5, typeof(TArg5)),
  19823. Expression.Constant(t6, typeof(TArg6)),
  19824. Expression.Constant(t7, typeof(TArg7)),
  19825. Expression.Constant(t8, typeof(TArg8)),
  19826. Expression.Constant(t9, typeof(TArg9)),
  19827. Expression.Constant(t10, typeof(TArg10))
  19828. )
  19829. );
  19830. }
  19831. /// <summary>
  19832. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  19833. /// </summary>
  19834. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19835. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19836. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19837. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19838. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19839. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19840. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19841. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19842. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19843. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  19844. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  19845. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19846. /// <param name="function">Function to convert to an asynchronous function.</param>
  19847. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19848. /// <returns>Asynchronous function.</returns>
  19849. /// <exception cref="T:System.ArgumentNullException">
  19850. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19851. 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)
  19852. {
  19853. if (provider == null)
  19854. throw new ArgumentNullException("provider");
  19855. if (function == null)
  19856. throw new ArgumentNullException("function");
  19857. if (scheduler == null)
  19858. throw new ArgumentNullException("scheduler");
  19859. #if CRIPPLED_REFLECTION
  19860. 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)));
  19861. #else
  19862. 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));
  19863. #endif
  19864. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<TResult>(
  19865. Expression.Invoke(
  19866. Expression.Call(
  19867. null,
  19868. m,
  19869. Expression.Constant(provider, typeof(IQbservableProvider)),
  19870. function,
  19871. Expression.Constant(scheduler, typeof(IScheduler))
  19872. ),
  19873. Expression.Constant(t1, typeof(TArg1)),
  19874. Expression.Constant(t2, typeof(TArg2)),
  19875. Expression.Constant(t3, typeof(TArg3)),
  19876. Expression.Constant(t4, typeof(TArg4)),
  19877. Expression.Constant(t5, typeof(TArg5)),
  19878. Expression.Constant(t6, typeof(TArg6)),
  19879. Expression.Constant(t7, typeof(TArg7)),
  19880. Expression.Constant(t8, typeof(TArg8)),
  19881. Expression.Constant(t9, typeof(TArg9)),
  19882. Expression.Constant(t10, typeof(TArg10))
  19883. )
  19884. );
  19885. }
  19886. /// <summary>
  19887. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19888. /// </summary>
  19889. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19890. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19891. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19892. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19893. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19894. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19895. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19896. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19897. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19898. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  19899. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  19900. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  19901. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19902. /// <param name="function">Function to convert to an asynchronous function.</param>
  19903. /// <returns>Asynchronous function.</returns>
  19904. /// <exception cref="T:System.ArgumentNullException">
  19905. /// <paramref name="function" /> is null.</exception>
  19906. 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)
  19907. {
  19908. if (provider == null)
  19909. throw new ArgumentNullException("provider");
  19910. if (function == null)
  19911. throw new ArgumentNullException("function");
  19912. #if CRIPPLED_REFLECTION
  19913. 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>>)));
  19914. #else
  19915. 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));
  19916. #endif
  19917. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<TResult>(
  19918. Expression.Invoke(
  19919. Expression.Call(
  19920. null,
  19921. m,
  19922. Expression.Constant(provider, typeof(IQbservableProvider)),
  19923. function
  19924. ),
  19925. Expression.Constant(t1, typeof(TArg1)),
  19926. Expression.Constant(t2, typeof(TArg2)),
  19927. Expression.Constant(t3, typeof(TArg3)),
  19928. Expression.Constant(t4, typeof(TArg4)),
  19929. Expression.Constant(t5, typeof(TArg5)),
  19930. Expression.Constant(t6, typeof(TArg6)),
  19931. Expression.Constant(t7, typeof(TArg7)),
  19932. Expression.Constant(t8, typeof(TArg8)),
  19933. Expression.Constant(t9, typeof(TArg9)),
  19934. Expression.Constant(t10, typeof(TArg10)),
  19935. Expression.Constant(t11, typeof(TArg11))
  19936. )
  19937. );
  19938. }
  19939. /// <summary>
  19940. /// 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.
  19941. /// </summary>
  19942. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  19943. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19944. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19945. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19946. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19947. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19948. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19949. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19950. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19951. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  19952. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  19953. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  19954. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19955. /// <param name="function">Function to convert to an asynchronous function.</param>
  19956. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19957. /// <returns>Asynchronous function.</returns>
  19958. /// <exception cref="T:System.ArgumentNullException">
  19959. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19960. 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)
  19961. {
  19962. if (provider == null)
  19963. throw new ArgumentNullException("provider");
  19964. if (function == null)
  19965. throw new ArgumentNullException("function");
  19966. if (scheduler == null)
  19967. throw new ArgumentNullException("scheduler");
  19968. #if CRIPPLED_REFLECTION
  19969. 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)));
  19970. #else
  19971. 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));
  19972. #endif
  19973. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<TResult>(
  19974. Expression.Invoke(
  19975. Expression.Call(
  19976. null,
  19977. m,
  19978. Expression.Constant(provider, typeof(IQbservableProvider)),
  19979. function,
  19980. Expression.Constant(scheduler, typeof(IScheduler))
  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. Expression.Constant(t9, typeof(TArg9)),
  19991. Expression.Constant(t10, typeof(TArg10)),
  19992. Expression.Constant(t11, typeof(TArg11))
  19993. )
  19994. );
  19995. }
  19996. /// <summary>
  19997. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19998. /// </summary>
  19999. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20000. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20001. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20002. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20003. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20004. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20005. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20006. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20007. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20008. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20009. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20010. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20011. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20012. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20013. /// <param name="function">Function to convert to an asynchronous function.</param>
  20014. /// <returns>Asynchronous function.</returns>
  20015. /// <exception cref="T:System.ArgumentNullException">
  20016. /// <paramref name="function" /> is null.</exception>
  20017. 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)
  20018. {
  20019. if (provider == null)
  20020. throw new ArgumentNullException("provider");
  20021. if (function == null)
  20022. throw new ArgumentNullException("function");
  20023. #if CRIPPLED_REFLECTION
  20024. 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>>)));
  20025. #else
  20026. 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));
  20027. #endif
  20028. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<TResult>(
  20029. Expression.Invoke(
  20030. Expression.Call(
  20031. null,
  20032. m,
  20033. Expression.Constant(provider, typeof(IQbservableProvider)),
  20034. function
  20035. ),
  20036. Expression.Constant(t1, typeof(TArg1)),
  20037. Expression.Constant(t2, typeof(TArg2)),
  20038. Expression.Constant(t3, typeof(TArg3)),
  20039. Expression.Constant(t4, typeof(TArg4)),
  20040. Expression.Constant(t5, typeof(TArg5)),
  20041. Expression.Constant(t6, typeof(TArg6)),
  20042. Expression.Constant(t7, typeof(TArg7)),
  20043. Expression.Constant(t8, typeof(TArg8)),
  20044. Expression.Constant(t9, typeof(TArg9)),
  20045. Expression.Constant(t10, typeof(TArg10)),
  20046. Expression.Constant(t11, typeof(TArg11)),
  20047. Expression.Constant(t12, typeof(TArg12))
  20048. )
  20049. );
  20050. }
  20051. /// <summary>
  20052. /// 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.
  20053. /// </summary>
  20054. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20055. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20056. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20057. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20058. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20059. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20060. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20061. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20062. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20063. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20064. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20065. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20066. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20067. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20068. /// <param name="function">Function to convert to an asynchronous function.</param>
  20069. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20070. /// <returns>Asynchronous function.</returns>
  20071. /// <exception cref="T:System.ArgumentNullException">
  20072. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20073. 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)
  20074. {
  20075. if (provider == null)
  20076. throw new ArgumentNullException("provider");
  20077. if (function == null)
  20078. throw new ArgumentNullException("function");
  20079. if (scheduler == null)
  20080. throw new ArgumentNullException("scheduler");
  20081. #if CRIPPLED_REFLECTION
  20082. 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)));
  20083. #else
  20084. 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));
  20085. #endif
  20086. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<TResult>(
  20087. Expression.Invoke(
  20088. Expression.Call(
  20089. null,
  20090. m,
  20091. Expression.Constant(provider, typeof(IQbservableProvider)),
  20092. function,
  20093. Expression.Constant(scheduler, typeof(IScheduler))
  20094. ),
  20095. Expression.Constant(t1, typeof(TArg1)),
  20096. Expression.Constant(t2, typeof(TArg2)),
  20097. Expression.Constant(t3, typeof(TArg3)),
  20098. Expression.Constant(t4, typeof(TArg4)),
  20099. Expression.Constant(t5, typeof(TArg5)),
  20100. Expression.Constant(t6, typeof(TArg6)),
  20101. Expression.Constant(t7, typeof(TArg7)),
  20102. Expression.Constant(t8, typeof(TArg8)),
  20103. Expression.Constant(t9, typeof(TArg9)),
  20104. Expression.Constant(t10, typeof(TArg10)),
  20105. Expression.Constant(t11, typeof(TArg11)),
  20106. Expression.Constant(t12, typeof(TArg12))
  20107. )
  20108. );
  20109. }
  20110. /// <summary>
  20111. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20112. /// </summary>
  20113. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20114. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20115. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20116. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20117. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20118. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20119. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20120. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20121. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20122. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20123. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20124. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20125. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20126. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20127. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20128. /// <param name="function">Function to convert to an asynchronous function.</param>
  20129. /// <returns>Asynchronous function.</returns>
  20130. /// <exception cref="T:System.ArgumentNullException">
  20131. /// <paramref name="function" /> is null.</exception>
  20132. 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)
  20133. {
  20134. if (provider == null)
  20135. throw new ArgumentNullException("provider");
  20136. if (function == null)
  20137. throw new ArgumentNullException("function");
  20138. #if CRIPPLED_REFLECTION
  20139. 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>>)));
  20140. #else
  20141. 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));
  20142. #endif
  20143. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<TResult>(
  20144. Expression.Invoke(
  20145. Expression.Call(
  20146. null,
  20147. m,
  20148. Expression.Constant(provider, typeof(IQbservableProvider)),
  20149. function
  20150. ),
  20151. Expression.Constant(t1, typeof(TArg1)),
  20152. Expression.Constant(t2, typeof(TArg2)),
  20153. Expression.Constant(t3, typeof(TArg3)),
  20154. Expression.Constant(t4, typeof(TArg4)),
  20155. Expression.Constant(t5, typeof(TArg5)),
  20156. Expression.Constant(t6, typeof(TArg6)),
  20157. Expression.Constant(t7, typeof(TArg7)),
  20158. Expression.Constant(t8, typeof(TArg8)),
  20159. Expression.Constant(t9, typeof(TArg9)),
  20160. Expression.Constant(t10, typeof(TArg10)),
  20161. Expression.Constant(t11, typeof(TArg11)),
  20162. Expression.Constant(t12, typeof(TArg12)),
  20163. Expression.Constant(t13, typeof(TArg13))
  20164. )
  20165. );
  20166. }
  20167. /// <summary>
  20168. /// 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.
  20169. /// </summary>
  20170. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20171. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20172. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20173. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20174. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20175. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20176. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20177. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20178. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20179. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20180. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20181. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20182. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20183. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20184. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20185. /// <param name="function">Function to convert to an asynchronous function.</param>
  20186. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20187. /// <returns>Asynchronous function.</returns>
  20188. /// <exception cref="T:System.ArgumentNullException">
  20189. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20190. 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)
  20191. {
  20192. if (provider == null)
  20193. throw new ArgumentNullException("provider");
  20194. if (function == null)
  20195. throw new ArgumentNullException("function");
  20196. if (scheduler == null)
  20197. throw new ArgumentNullException("scheduler");
  20198. #if CRIPPLED_REFLECTION
  20199. 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)));
  20200. #else
  20201. 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));
  20202. #endif
  20203. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<TResult>(
  20204. Expression.Invoke(
  20205. Expression.Call(
  20206. null,
  20207. m,
  20208. Expression.Constant(provider, typeof(IQbservableProvider)),
  20209. function,
  20210. Expression.Constant(scheduler, typeof(IScheduler))
  20211. ),
  20212. Expression.Constant(t1, typeof(TArg1)),
  20213. Expression.Constant(t2, typeof(TArg2)),
  20214. Expression.Constant(t3, typeof(TArg3)),
  20215. Expression.Constant(t4, typeof(TArg4)),
  20216. Expression.Constant(t5, typeof(TArg5)),
  20217. Expression.Constant(t6, typeof(TArg6)),
  20218. Expression.Constant(t7, typeof(TArg7)),
  20219. Expression.Constant(t8, typeof(TArg8)),
  20220. Expression.Constant(t9, typeof(TArg9)),
  20221. Expression.Constant(t10, typeof(TArg10)),
  20222. Expression.Constant(t11, typeof(TArg11)),
  20223. Expression.Constant(t12, typeof(TArg12)),
  20224. Expression.Constant(t13, typeof(TArg13))
  20225. )
  20226. );
  20227. }
  20228. /// <summary>
  20229. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20230. /// </summary>
  20231. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20232. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20233. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20234. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20235. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20236. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20237. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20238. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20239. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20240. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20241. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20242. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20243. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20244. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20245. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20246. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20247. /// <param name="function">Function to convert to an asynchronous function.</param>
  20248. /// <returns>Asynchronous function.</returns>
  20249. /// <exception cref="T:System.ArgumentNullException">
  20250. /// <paramref name="function" /> is null.</exception>
  20251. 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)
  20252. {
  20253. if (provider == null)
  20254. throw new ArgumentNullException("provider");
  20255. if (function == null)
  20256. throw new ArgumentNullException("function");
  20257. #if CRIPPLED_REFLECTION
  20258. 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>>)));
  20259. #else
  20260. 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));
  20261. #endif
  20262. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<TResult>(
  20263. Expression.Invoke(
  20264. Expression.Call(
  20265. null,
  20266. m,
  20267. Expression.Constant(provider, typeof(IQbservableProvider)),
  20268. function
  20269. ),
  20270. Expression.Constant(t1, typeof(TArg1)),
  20271. Expression.Constant(t2, typeof(TArg2)),
  20272. Expression.Constant(t3, typeof(TArg3)),
  20273. Expression.Constant(t4, typeof(TArg4)),
  20274. Expression.Constant(t5, typeof(TArg5)),
  20275. Expression.Constant(t6, typeof(TArg6)),
  20276. Expression.Constant(t7, typeof(TArg7)),
  20277. Expression.Constant(t8, typeof(TArg8)),
  20278. Expression.Constant(t9, typeof(TArg9)),
  20279. Expression.Constant(t10, typeof(TArg10)),
  20280. Expression.Constant(t11, typeof(TArg11)),
  20281. Expression.Constant(t12, typeof(TArg12)),
  20282. Expression.Constant(t13, typeof(TArg13)),
  20283. Expression.Constant(t14, typeof(TArg14))
  20284. )
  20285. );
  20286. }
  20287. /// <summary>
  20288. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  20289. /// </summary>
  20290. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20291. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20292. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20293. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20294. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20295. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20296. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20297. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20298. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20299. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20300. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20301. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20302. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20303. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20304. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20305. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20306. /// <param name="function">Function to convert to an asynchronous function.</param>
  20307. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20308. /// <returns>Asynchronous function.</returns>
  20309. /// <exception cref="T:System.ArgumentNullException">
  20310. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20311. 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)
  20312. {
  20313. if (provider == null)
  20314. throw new ArgumentNullException("provider");
  20315. if (function == null)
  20316. throw new ArgumentNullException("function");
  20317. if (scheduler == null)
  20318. throw new ArgumentNullException("scheduler");
  20319. #if CRIPPLED_REFLECTION
  20320. 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)));
  20321. #else
  20322. 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));
  20323. #endif
  20324. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<TResult>(
  20325. Expression.Invoke(
  20326. Expression.Call(
  20327. null,
  20328. m,
  20329. Expression.Constant(provider, typeof(IQbservableProvider)),
  20330. function,
  20331. Expression.Constant(scheduler, typeof(IScheduler))
  20332. ),
  20333. Expression.Constant(t1, typeof(TArg1)),
  20334. Expression.Constant(t2, typeof(TArg2)),
  20335. Expression.Constant(t3, typeof(TArg3)),
  20336. Expression.Constant(t4, typeof(TArg4)),
  20337. Expression.Constant(t5, typeof(TArg5)),
  20338. Expression.Constant(t6, typeof(TArg6)),
  20339. Expression.Constant(t7, typeof(TArg7)),
  20340. Expression.Constant(t8, typeof(TArg8)),
  20341. Expression.Constant(t9, typeof(TArg9)),
  20342. Expression.Constant(t10, typeof(TArg10)),
  20343. Expression.Constant(t11, typeof(TArg11)),
  20344. Expression.Constant(t12, typeof(TArg12)),
  20345. Expression.Constant(t13, typeof(TArg13)),
  20346. Expression.Constant(t14, typeof(TArg14))
  20347. )
  20348. );
  20349. }
  20350. /// <summary>
  20351. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20352. /// </summary>
  20353. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20354. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20355. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20356. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20357. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20358. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20359. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20360. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20361. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20362. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20363. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20364. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20365. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20366. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20367. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20368. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the function.</typeparam>
  20369. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20370. /// <param name="function">Function to convert to an asynchronous function.</param>
  20371. /// <returns>Asynchronous function.</returns>
  20372. /// <exception cref="T:System.ArgumentNullException">
  20373. /// <paramref name="function" /> is null.</exception>
  20374. 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)
  20375. {
  20376. if (provider == null)
  20377. throw new ArgumentNullException("provider");
  20378. if (function == null)
  20379. throw new ArgumentNullException("function");
  20380. #if CRIPPLED_REFLECTION
  20381. 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>>)));
  20382. #else
  20383. 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));
  20384. #endif
  20385. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) => provider.CreateQuery<TResult>(
  20386. Expression.Invoke(
  20387. Expression.Call(
  20388. null,
  20389. m,
  20390. Expression.Constant(provider, typeof(IQbservableProvider)),
  20391. function
  20392. ),
  20393. Expression.Constant(t1, typeof(TArg1)),
  20394. Expression.Constant(t2, typeof(TArg2)),
  20395. Expression.Constant(t3, typeof(TArg3)),
  20396. Expression.Constant(t4, typeof(TArg4)),
  20397. Expression.Constant(t5, typeof(TArg5)),
  20398. Expression.Constant(t6, typeof(TArg6)),
  20399. Expression.Constant(t7, typeof(TArg7)),
  20400. Expression.Constant(t8, typeof(TArg8)),
  20401. Expression.Constant(t9, typeof(TArg9)),
  20402. Expression.Constant(t10, typeof(TArg10)),
  20403. Expression.Constant(t11, typeof(TArg11)),
  20404. Expression.Constant(t12, typeof(TArg12)),
  20405. Expression.Constant(t13, typeof(TArg13)),
  20406. Expression.Constant(t14, typeof(TArg14)),
  20407. Expression.Constant(t15, typeof(TArg15))
  20408. )
  20409. );
  20410. }
  20411. /// <summary>
  20412. /// 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.
  20413. /// </summary>
  20414. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20415. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20416. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20417. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20418. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20419. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20420. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20421. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20422. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20423. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20424. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20425. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20426. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20427. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20428. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20429. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the function.</typeparam>
  20430. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20431. /// <param name="function">Function to convert to an asynchronous function.</param>
  20432. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20433. /// <returns>Asynchronous function.</returns>
  20434. /// <exception cref="T:System.ArgumentNullException">
  20435. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20436. 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)
  20437. {
  20438. if (provider == null)
  20439. throw new ArgumentNullException("provider");
  20440. if (function == null)
  20441. throw new ArgumentNullException("function");
  20442. if (scheduler == null)
  20443. throw new ArgumentNullException("scheduler");
  20444. #if CRIPPLED_REFLECTION
  20445. 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)));
  20446. #else
  20447. 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));
  20448. #endif
  20449. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) => provider.CreateQuery<TResult>(
  20450. Expression.Invoke(
  20451. Expression.Call(
  20452. null,
  20453. m,
  20454. Expression.Constant(provider, typeof(IQbservableProvider)),
  20455. function,
  20456. Expression.Constant(scheduler, typeof(IScheduler))
  20457. ),
  20458. Expression.Constant(t1, typeof(TArg1)),
  20459. Expression.Constant(t2, typeof(TArg2)),
  20460. Expression.Constant(t3, typeof(TArg3)),
  20461. Expression.Constant(t4, typeof(TArg4)),
  20462. Expression.Constant(t5, typeof(TArg5)),
  20463. Expression.Constant(t6, typeof(TArg6)),
  20464. Expression.Constant(t7, typeof(TArg7)),
  20465. Expression.Constant(t8, typeof(TArg8)),
  20466. Expression.Constant(t9, typeof(TArg9)),
  20467. Expression.Constant(t10, typeof(TArg10)),
  20468. Expression.Constant(t11, typeof(TArg11)),
  20469. Expression.Constant(t12, typeof(TArg12)),
  20470. Expression.Constant(t13, typeof(TArg13)),
  20471. Expression.Constant(t14, typeof(TArg14)),
  20472. Expression.Constant(t15, typeof(TArg15))
  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="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20494. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the function.</typeparam>
  20495. /// <typeparam name="TArg16">The type of the sixteenth argument passed to the function.</typeparam>
  20496. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20497. /// <param name="function">Function to convert to an asynchronous function.</param>
  20498. /// <returns>Asynchronous function.</returns>
  20499. /// <exception cref="T:System.ArgumentNullException">
  20500. /// <paramref name="function" /> is null.</exception>
  20501. 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)
  20502. {
  20503. if (provider == null)
  20504. throw new ArgumentNullException("provider");
  20505. if (function == null)
  20506. throw new ArgumentNullException("function");
  20507. #if CRIPPLED_REFLECTION
  20508. 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>>)));
  20509. #else
  20510. 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));
  20511. #endif
  20512. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) => provider.CreateQuery<TResult>(
  20513. Expression.Invoke(
  20514. Expression.Call(
  20515. null,
  20516. m,
  20517. Expression.Constant(provider, typeof(IQbservableProvider)),
  20518. function
  20519. ),
  20520. Expression.Constant(t1, typeof(TArg1)),
  20521. Expression.Constant(t2, typeof(TArg2)),
  20522. Expression.Constant(t3, typeof(TArg3)),
  20523. Expression.Constant(t4, typeof(TArg4)),
  20524. Expression.Constant(t5, typeof(TArg5)),
  20525. Expression.Constant(t6, typeof(TArg6)),
  20526. Expression.Constant(t7, typeof(TArg7)),
  20527. Expression.Constant(t8, typeof(TArg8)),
  20528. Expression.Constant(t9, typeof(TArg9)),
  20529. Expression.Constant(t10, typeof(TArg10)),
  20530. Expression.Constant(t11, typeof(TArg11)),
  20531. Expression.Constant(t12, typeof(TArg12)),
  20532. Expression.Constant(t13, typeof(TArg13)),
  20533. Expression.Constant(t14, typeof(TArg14)),
  20534. Expression.Constant(t15, typeof(TArg15)),
  20535. Expression.Constant(t16, typeof(TArg16))
  20536. )
  20537. );
  20538. }
  20539. /// <summary>
  20540. /// 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.
  20541. /// </summary>
  20542. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20543. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20544. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20545. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20546. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20547. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20548. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20549. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20550. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20551. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20552. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20553. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20554. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20555. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20556. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20557. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the function.</typeparam>
  20558. /// <typeparam name="TArg16">The type of the sixteenth argument passed to the function.</typeparam>
  20559. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20560. /// <param name="function">Function to convert to an asynchronous function.</param>
  20561. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20562. /// <returns>Asynchronous function.</returns>
  20563. /// <exception cref="T:System.ArgumentNullException">
  20564. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20565. 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)
  20566. {
  20567. if (provider == null)
  20568. throw new ArgumentNullException("provider");
  20569. if (function == null)
  20570. throw new ArgumentNullException("function");
  20571. if (scheduler == null)
  20572. throw new ArgumentNullException("scheduler");
  20573. #if CRIPPLED_REFLECTION
  20574. 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)));
  20575. #else
  20576. 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));
  20577. #endif
  20578. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) => provider.CreateQuery<TResult>(
  20579. Expression.Invoke(
  20580. Expression.Call(
  20581. null,
  20582. m,
  20583. Expression.Constant(provider, typeof(IQbservableProvider)),
  20584. function,
  20585. Expression.Constant(scheduler, typeof(IScheduler))
  20586. ),
  20587. Expression.Constant(t1, typeof(TArg1)),
  20588. Expression.Constant(t2, typeof(TArg2)),
  20589. Expression.Constant(t3, typeof(TArg3)),
  20590. Expression.Constant(t4, typeof(TArg4)),
  20591. Expression.Constant(t5, typeof(TArg5)),
  20592. Expression.Constant(t6, typeof(TArg6)),
  20593. Expression.Constant(t7, typeof(TArg7)),
  20594. Expression.Constant(t8, typeof(TArg8)),
  20595. Expression.Constant(t9, typeof(TArg9)),
  20596. Expression.Constant(t10, typeof(TArg10)),
  20597. Expression.Constant(t11, typeof(TArg11)),
  20598. Expression.Constant(t12, typeof(TArg12)),
  20599. Expression.Constant(t13, typeof(TArg13)),
  20600. Expression.Constant(t14, typeof(TArg14)),
  20601. Expression.Constant(t15, typeof(TArg15)),
  20602. Expression.Constant(t16, typeof(TArg16))
  20603. )
  20604. );
  20605. }
  20606. #endif
  20607. /// <summary>
  20608. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20609. /// </summary>
  20610. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20611. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20612. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20613. /// <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>
  20614. /// <exception cref="T:System.ArgumentNullException">
  20615. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20616. /// <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>
  20617. #if PREFERASYNC
  20618. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20619. #endif
  20620. public static Func<IQbservable<Unit>> FromAsyncPattern(this IQbservableProvider provider, Expression<Func<AsyncCallback, object, IAsyncResult>> begin, Expression<Action<IAsyncResult>>end)
  20621. {
  20622. if (provider == null)
  20623. throw new ArgumentNullException("provider");
  20624. if (begin == null)
  20625. throw new ArgumentNullException("begin");
  20626. if (end == null)
  20627. throw new ArgumentNullException("end");
  20628. #if CRIPPLED_REFLECTION
  20629. var m = InfoOf(() => Qbservable.FromAsyncPattern(default(IQbservableProvider), default(Expression<Func<AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  20630. #else
  20631. var m = (MethodInfo)MethodInfo.GetCurrentMethod();
  20632. #endif
  20633. return () => provider.CreateQuery<Unit>(
  20634. Expression.Invoke(
  20635. Expression.Call(
  20636. null,
  20637. m,
  20638. Expression.Constant(provider, typeof(IQbservableProvider)),
  20639. begin,
  20640. end
  20641. )
  20642. )
  20643. );
  20644. }
  20645. /// <summary>
  20646. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20647. /// </summary>
  20648. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20649. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20650. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20651. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20652. /// <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>
  20653. /// <exception cref="T:System.ArgumentNullException">
  20654. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20655. /// <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>
  20656. #if PREFERASYNC
  20657. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20658. #endif
  20659. public static Func<TArg1, IQbservable<Unit>> FromAsyncPattern<TArg1>(this IQbservableProvider provider, Expression<Func<TArg1, AsyncCallback, object, IAsyncResult>> begin, Expression<Action<IAsyncResult>>end)
  20660. {
  20661. if (provider == null)
  20662. throw new ArgumentNullException("provider");
  20663. if (begin == null)
  20664. throw new ArgumentNullException("begin");
  20665. if (end == null)
  20666. throw new ArgumentNullException("end");
  20667. #if CRIPPLED_REFLECTION
  20668. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1>(default(IQbservableProvider), default(Expression<Func<TArg1, AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  20669. #else
  20670. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1));
  20671. #endif
  20672. return (t1) => provider.CreateQuery<Unit>(
  20673. Expression.Invoke(
  20674. Expression.Call(
  20675. null,
  20676. m,
  20677. Expression.Constant(provider, typeof(IQbservableProvider)),
  20678. begin,
  20679. end
  20680. ),
  20681. Expression.Constant(t1, typeof(TArg1))
  20682. )
  20683. );
  20684. }
  20685. /// <summary>
  20686. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20687. /// </summary>
  20688. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20689. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20690. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20691. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20692. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20693. /// <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>
  20694. /// <exception cref="T:System.ArgumentNullException">
  20695. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20696. /// <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>
  20697. #if PREFERASYNC
  20698. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20699. #endif
  20700. 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)
  20701. {
  20702. if (provider == null)
  20703. throw new ArgumentNullException("provider");
  20704. if (begin == null)
  20705. throw new ArgumentNullException("begin");
  20706. if (end == null)
  20707. throw new ArgumentNullException("end");
  20708. #if CRIPPLED_REFLECTION
  20709. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  20710. #else
  20711. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2));
  20712. #endif
  20713. return (t1, t2) => provider.CreateQuery<Unit>(
  20714. Expression.Invoke(
  20715. Expression.Call(
  20716. null,
  20717. m,
  20718. Expression.Constant(provider, typeof(IQbservableProvider)),
  20719. begin,
  20720. end
  20721. ),
  20722. Expression.Constant(t1, typeof(TArg1)),
  20723. Expression.Constant(t2, typeof(TArg2))
  20724. )
  20725. );
  20726. }
  20727. #if !NO_LARGEARITY
  20728. /// <summary>
  20729. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20730. /// </summary>
  20731. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20732. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20733. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20734. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  20735. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20736. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20737. /// <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>
  20738. /// <exception cref="T:System.ArgumentNullException">
  20739. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20740. /// <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>
  20741. #if PREFERASYNC
  20742. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20743. #endif
  20744. 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)
  20745. {
  20746. if (provider == null)
  20747. throw new ArgumentNullException("provider");
  20748. if (begin == null)
  20749. throw new ArgumentNullException("begin");
  20750. if (end == null)
  20751. throw new ArgumentNullException("end");
  20752. #if CRIPPLED_REFLECTION
  20753. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TArg3>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  20754. #else
  20755. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3));
  20756. #endif
  20757. return (t1, t2, t3) => provider.CreateQuery<Unit>(
  20758. Expression.Invoke(
  20759. Expression.Call(
  20760. null,
  20761. m,
  20762. Expression.Constant(provider, typeof(IQbservableProvider)),
  20763. begin,
  20764. end
  20765. ),
  20766. Expression.Constant(t1, typeof(TArg1)),
  20767. Expression.Constant(t2, typeof(TArg2)),
  20768. Expression.Constant(t3, typeof(TArg3))
  20769. )
  20770. );
  20771. }
  20772. /// <summary>
  20773. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20774. /// </summary>
  20775. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20776. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20777. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20778. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  20779. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  20780. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20781. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20782. /// <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>
  20783. /// <exception cref="T:System.ArgumentNullException">
  20784. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20785. /// <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>
  20786. #if PREFERASYNC
  20787. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20788. #endif
  20789. 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)
  20790. {
  20791. if (provider == null)
  20792. throw new ArgumentNullException("provider");
  20793. if (begin == null)
  20794. throw new ArgumentNullException("begin");
  20795. if (end == null)
  20796. throw new ArgumentNullException("end");
  20797. #if CRIPPLED_REFLECTION
  20798. 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>>)));
  20799. #else
  20800. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4));
  20801. #endif
  20802. return (t1, t2, t3, t4) => provider.CreateQuery<Unit>(
  20803. Expression.Invoke(
  20804. Expression.Call(
  20805. null,
  20806. m,
  20807. Expression.Constant(provider, typeof(IQbservableProvider)),
  20808. begin,
  20809. end
  20810. ),
  20811. Expression.Constant(t1, typeof(TArg1)),
  20812. Expression.Constant(t2, typeof(TArg2)),
  20813. Expression.Constant(t3, typeof(TArg3)),
  20814. Expression.Constant(t4, typeof(TArg4))
  20815. )
  20816. );
  20817. }
  20818. /// <summary>
  20819. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20820. /// </summary>
  20821. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20822. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20823. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20824. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  20825. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  20826. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  20827. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20828. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20829. /// <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>
  20830. /// <exception cref="T:System.ArgumentNullException">
  20831. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20832. /// <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>
  20833. #if PREFERASYNC
  20834. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20835. #endif
  20836. 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)
  20837. {
  20838. if (provider == null)
  20839. throw new ArgumentNullException("provider");
  20840. if (begin == null)
  20841. throw new ArgumentNullException("begin");
  20842. if (end == null)
  20843. throw new ArgumentNullException("end");
  20844. #if CRIPPLED_REFLECTION
  20845. 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>>)));
  20846. #else
  20847. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5));
  20848. #endif
  20849. return (t1, t2, t3, t4, t5) => provider.CreateQuery<Unit>(
  20850. Expression.Invoke(
  20851. Expression.Call(
  20852. null,
  20853. m,
  20854. Expression.Constant(provider, typeof(IQbservableProvider)),
  20855. begin,
  20856. end
  20857. ),
  20858. Expression.Constant(t1, typeof(TArg1)),
  20859. Expression.Constant(t2, typeof(TArg2)),
  20860. Expression.Constant(t3, typeof(TArg3)),
  20861. Expression.Constant(t4, typeof(TArg4)),
  20862. Expression.Constant(t5, typeof(TArg5))
  20863. )
  20864. );
  20865. }
  20866. /// <summary>
  20867. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20868. /// </summary>
  20869. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20870. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20871. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20872. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  20873. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  20874. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  20875. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  20876. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20877. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20878. /// <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>
  20879. /// <exception cref="T:System.ArgumentNullException">
  20880. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20881. /// <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>
  20882. #if PREFERASYNC
  20883. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20884. #endif
  20885. 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)
  20886. {
  20887. if (provider == null)
  20888. throw new ArgumentNullException("provider");
  20889. if (begin == null)
  20890. throw new ArgumentNullException("begin");
  20891. if (end == null)
  20892. throw new ArgumentNullException("end");
  20893. #if CRIPPLED_REFLECTION
  20894. 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>>)));
  20895. #else
  20896. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6));
  20897. #endif
  20898. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<Unit>(
  20899. Expression.Invoke(
  20900. Expression.Call(
  20901. null,
  20902. m,
  20903. Expression.Constant(provider, typeof(IQbservableProvider)),
  20904. begin,
  20905. end
  20906. ),
  20907. Expression.Constant(t1, typeof(TArg1)),
  20908. Expression.Constant(t2, typeof(TArg2)),
  20909. Expression.Constant(t3, typeof(TArg3)),
  20910. Expression.Constant(t4, typeof(TArg4)),
  20911. Expression.Constant(t5, typeof(TArg5)),
  20912. Expression.Constant(t6, typeof(TArg6))
  20913. )
  20914. );
  20915. }
  20916. /// <summary>
  20917. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20918. /// </summary>
  20919. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20920. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20921. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20922. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  20923. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  20924. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  20925. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  20926. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  20927. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20928. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20929. /// <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>
  20930. /// <exception cref="T:System.ArgumentNullException">
  20931. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20932. /// <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>
  20933. #if PREFERASYNC
  20934. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20935. #endif
  20936. 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)
  20937. {
  20938. if (provider == null)
  20939. throw new ArgumentNullException("provider");
  20940. if (begin == null)
  20941. throw new ArgumentNullException("begin");
  20942. if (end == null)
  20943. throw new ArgumentNullException("end");
  20944. #if CRIPPLED_REFLECTION
  20945. 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>>)));
  20946. #else
  20947. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7));
  20948. #endif
  20949. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<Unit>(
  20950. Expression.Invoke(
  20951. Expression.Call(
  20952. null,
  20953. m,
  20954. Expression.Constant(provider, typeof(IQbservableProvider)),
  20955. begin,
  20956. end
  20957. ),
  20958. Expression.Constant(t1, typeof(TArg1)),
  20959. Expression.Constant(t2, typeof(TArg2)),
  20960. Expression.Constant(t3, typeof(TArg3)),
  20961. Expression.Constant(t4, typeof(TArg4)),
  20962. Expression.Constant(t5, typeof(TArg5)),
  20963. Expression.Constant(t6, typeof(TArg6)),
  20964. Expression.Constant(t7, typeof(TArg7))
  20965. )
  20966. );
  20967. }
  20968. /// <summary>
  20969. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20970. /// </summary>
  20971. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  20972. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20973. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20974. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  20975. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  20976. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  20977. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  20978. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  20979. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  20980. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20981. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20982. /// <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>
  20983. /// <exception cref="T:System.ArgumentNullException">
  20984. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20985. /// <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>
  20986. #if PREFERASYNC
  20987. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20988. #endif
  20989. 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)
  20990. {
  20991. if (provider == null)
  20992. throw new ArgumentNullException("provider");
  20993. if (begin == null)
  20994. throw new ArgumentNullException("begin");
  20995. if (end == null)
  20996. throw new ArgumentNullException("end");
  20997. #if CRIPPLED_REFLECTION
  20998. 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>>)));
  20999. #else
  21000. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8));
  21001. #endif
  21002. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<Unit>(
  21003. Expression.Invoke(
  21004. Expression.Call(
  21005. null,
  21006. m,
  21007. Expression.Constant(provider, typeof(IQbservableProvider)),
  21008. begin,
  21009. end
  21010. ),
  21011. Expression.Constant(t1, typeof(TArg1)),
  21012. Expression.Constant(t2, typeof(TArg2)),
  21013. Expression.Constant(t3, typeof(TArg3)),
  21014. Expression.Constant(t4, typeof(TArg4)),
  21015. Expression.Constant(t5, typeof(TArg5)),
  21016. Expression.Constant(t6, typeof(TArg6)),
  21017. Expression.Constant(t7, typeof(TArg7)),
  21018. Expression.Constant(t8, typeof(TArg8))
  21019. )
  21020. );
  21021. }
  21022. /// <summary>
  21023. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21024. /// </summary>
  21025. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21026. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21027. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21028. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21029. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21030. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21031. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21032. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21033. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21034. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21035. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21036. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21037. /// <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>
  21038. /// <exception cref="T:System.ArgumentNullException">
  21039. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21040. /// <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>
  21041. #if PREFERASYNC
  21042. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21043. #endif
  21044. 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)
  21045. {
  21046. if (provider == null)
  21047. throw new ArgumentNullException("provider");
  21048. if (begin == null)
  21049. throw new ArgumentNullException("begin");
  21050. if (end == null)
  21051. throw new ArgumentNullException("end");
  21052. #if CRIPPLED_REFLECTION
  21053. 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>>)));
  21054. #else
  21055. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9));
  21056. #endif
  21057. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<Unit>(
  21058. Expression.Invoke(
  21059. Expression.Call(
  21060. null,
  21061. m,
  21062. Expression.Constant(provider, typeof(IQbservableProvider)),
  21063. begin,
  21064. end
  21065. ),
  21066. Expression.Constant(t1, typeof(TArg1)),
  21067. Expression.Constant(t2, typeof(TArg2)),
  21068. Expression.Constant(t3, typeof(TArg3)),
  21069. Expression.Constant(t4, typeof(TArg4)),
  21070. Expression.Constant(t5, typeof(TArg5)),
  21071. Expression.Constant(t6, typeof(TArg6)),
  21072. Expression.Constant(t7, typeof(TArg7)),
  21073. Expression.Constant(t8, typeof(TArg8)),
  21074. Expression.Constant(t9, typeof(TArg9))
  21075. )
  21076. );
  21077. }
  21078. /// <summary>
  21079. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21080. /// </summary>
  21081. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21082. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21083. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21084. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21085. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21086. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21087. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21088. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21089. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21090. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21091. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21092. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21093. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21094. /// <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>
  21095. /// <exception cref="T:System.ArgumentNullException">
  21096. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21097. /// <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>
  21098. #if PREFERASYNC
  21099. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21100. #endif
  21101. 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)
  21102. {
  21103. if (provider == null)
  21104. throw new ArgumentNullException("provider");
  21105. if (begin == null)
  21106. throw new ArgumentNullException("begin");
  21107. if (end == null)
  21108. throw new ArgumentNullException("end");
  21109. #if CRIPPLED_REFLECTION
  21110. 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>>)));
  21111. #else
  21112. 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));
  21113. #endif
  21114. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<Unit>(
  21115. Expression.Invoke(
  21116. Expression.Call(
  21117. null,
  21118. m,
  21119. Expression.Constant(provider, typeof(IQbservableProvider)),
  21120. begin,
  21121. end
  21122. ),
  21123. Expression.Constant(t1, typeof(TArg1)),
  21124. Expression.Constant(t2, typeof(TArg2)),
  21125. Expression.Constant(t3, typeof(TArg3)),
  21126. Expression.Constant(t4, typeof(TArg4)),
  21127. Expression.Constant(t5, typeof(TArg5)),
  21128. Expression.Constant(t6, typeof(TArg6)),
  21129. Expression.Constant(t7, typeof(TArg7)),
  21130. Expression.Constant(t8, typeof(TArg8)),
  21131. Expression.Constant(t9, typeof(TArg9)),
  21132. Expression.Constant(t10, typeof(TArg10))
  21133. )
  21134. );
  21135. }
  21136. /// <summary>
  21137. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21138. /// </summary>
  21139. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21140. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21141. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21142. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21143. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21144. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21145. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21146. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21147. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21148. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21149. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21150. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  21151. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21152. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21153. /// <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>
  21154. /// <exception cref="T:System.ArgumentNullException">
  21155. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21156. /// <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>
  21157. #if PREFERASYNC
  21158. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21159. #endif
  21160. 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)
  21161. {
  21162. if (provider == null)
  21163. throw new ArgumentNullException("provider");
  21164. if (begin == null)
  21165. throw new ArgumentNullException("begin");
  21166. if (end == null)
  21167. throw new ArgumentNullException("end");
  21168. #if CRIPPLED_REFLECTION
  21169. 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>>)));
  21170. #else
  21171. 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));
  21172. #endif
  21173. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<Unit>(
  21174. Expression.Invoke(
  21175. Expression.Call(
  21176. null,
  21177. m,
  21178. Expression.Constant(provider, typeof(IQbservableProvider)),
  21179. begin,
  21180. end
  21181. ),
  21182. Expression.Constant(t1, typeof(TArg1)),
  21183. Expression.Constant(t2, typeof(TArg2)),
  21184. Expression.Constant(t3, typeof(TArg3)),
  21185. Expression.Constant(t4, typeof(TArg4)),
  21186. Expression.Constant(t5, typeof(TArg5)),
  21187. Expression.Constant(t6, typeof(TArg6)),
  21188. Expression.Constant(t7, typeof(TArg7)),
  21189. Expression.Constant(t8, typeof(TArg8)),
  21190. Expression.Constant(t9, typeof(TArg9)),
  21191. Expression.Constant(t10, typeof(TArg10)),
  21192. Expression.Constant(t11, typeof(TArg11))
  21193. )
  21194. );
  21195. }
  21196. /// <summary>
  21197. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21198. /// </summary>
  21199. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21200. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21201. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21202. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21203. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21204. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21205. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21206. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21207. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21208. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21209. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21210. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  21211. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  21212. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21213. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21214. /// <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>
  21215. /// <exception cref="T:System.ArgumentNullException">
  21216. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21217. /// <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>
  21218. #if PREFERASYNC
  21219. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21220. #endif
  21221. 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)
  21222. {
  21223. if (provider == null)
  21224. throw new ArgumentNullException("provider");
  21225. if (begin == null)
  21226. throw new ArgumentNullException("begin");
  21227. if (end == null)
  21228. throw new ArgumentNullException("end");
  21229. #if CRIPPLED_REFLECTION
  21230. 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>>)));
  21231. #else
  21232. 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));
  21233. #endif
  21234. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<Unit>(
  21235. Expression.Invoke(
  21236. Expression.Call(
  21237. null,
  21238. m,
  21239. Expression.Constant(provider, typeof(IQbservableProvider)),
  21240. begin,
  21241. end
  21242. ),
  21243. Expression.Constant(t1, typeof(TArg1)),
  21244. Expression.Constant(t2, typeof(TArg2)),
  21245. Expression.Constant(t3, typeof(TArg3)),
  21246. Expression.Constant(t4, typeof(TArg4)),
  21247. Expression.Constant(t5, typeof(TArg5)),
  21248. Expression.Constant(t6, typeof(TArg6)),
  21249. Expression.Constant(t7, typeof(TArg7)),
  21250. Expression.Constant(t8, typeof(TArg8)),
  21251. Expression.Constant(t9, typeof(TArg9)),
  21252. Expression.Constant(t10, typeof(TArg10)),
  21253. Expression.Constant(t11, typeof(TArg11)),
  21254. Expression.Constant(t12, typeof(TArg12))
  21255. )
  21256. );
  21257. }
  21258. /// <summary>
  21259. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21260. /// </summary>
  21261. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21262. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21263. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21264. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21265. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21266. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21267. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21268. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21269. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21270. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21271. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21272. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  21273. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  21274. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the begin delegate.</typeparam>
  21275. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21276. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21277. /// <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>
  21278. /// <exception cref="T:System.ArgumentNullException">
  21279. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21280. /// <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>
  21281. #if PREFERASYNC
  21282. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21283. #endif
  21284. 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)
  21285. {
  21286. if (provider == null)
  21287. throw new ArgumentNullException("provider");
  21288. if (begin == null)
  21289. throw new ArgumentNullException("begin");
  21290. if (end == null)
  21291. throw new ArgumentNullException("end");
  21292. #if CRIPPLED_REFLECTION
  21293. 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>>)));
  21294. #else
  21295. 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));
  21296. #endif
  21297. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<Unit>(
  21298. Expression.Invoke(
  21299. Expression.Call(
  21300. null,
  21301. m,
  21302. Expression.Constant(provider, typeof(IQbservableProvider)),
  21303. begin,
  21304. end
  21305. ),
  21306. Expression.Constant(t1, typeof(TArg1)),
  21307. Expression.Constant(t2, typeof(TArg2)),
  21308. Expression.Constant(t3, typeof(TArg3)),
  21309. Expression.Constant(t4, typeof(TArg4)),
  21310. Expression.Constant(t5, typeof(TArg5)),
  21311. Expression.Constant(t6, typeof(TArg6)),
  21312. Expression.Constant(t7, typeof(TArg7)),
  21313. Expression.Constant(t8, typeof(TArg8)),
  21314. Expression.Constant(t9, typeof(TArg9)),
  21315. Expression.Constant(t10, typeof(TArg10)),
  21316. Expression.Constant(t11, typeof(TArg11)),
  21317. Expression.Constant(t12, typeof(TArg12)),
  21318. Expression.Constant(t13, typeof(TArg13))
  21319. )
  21320. );
  21321. }
  21322. /// <summary>
  21323. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21324. /// </summary>
  21325. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21326. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21327. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21328. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21329. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21330. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21331. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21332. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21333. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21334. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21335. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21336. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  21337. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  21338. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the begin delegate.</typeparam>
  21339. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the begin delegate.</typeparam>
  21340. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21341. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21342. /// <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>
  21343. /// <exception cref="T:System.ArgumentNullException">
  21344. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21345. /// <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>
  21346. #if PREFERASYNC
  21347. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21348. #endif
  21349. 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)
  21350. {
  21351. if (provider == null)
  21352. throw new ArgumentNullException("provider");
  21353. if (begin == null)
  21354. throw new ArgumentNullException("begin");
  21355. if (end == null)
  21356. throw new ArgumentNullException("end");
  21357. #if CRIPPLED_REFLECTION
  21358. 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>>)));
  21359. #else
  21360. 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));
  21361. #endif
  21362. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<Unit>(
  21363. Expression.Invoke(
  21364. Expression.Call(
  21365. null,
  21366. m,
  21367. Expression.Constant(provider, typeof(IQbservableProvider)),
  21368. begin,
  21369. end
  21370. ),
  21371. Expression.Constant(t1, typeof(TArg1)),
  21372. Expression.Constant(t2, typeof(TArg2)),
  21373. Expression.Constant(t3, typeof(TArg3)),
  21374. Expression.Constant(t4, typeof(TArg4)),
  21375. Expression.Constant(t5, typeof(TArg5)),
  21376. Expression.Constant(t6, typeof(TArg6)),
  21377. Expression.Constant(t7, typeof(TArg7)),
  21378. Expression.Constant(t8, typeof(TArg8)),
  21379. Expression.Constant(t9, typeof(TArg9)),
  21380. Expression.Constant(t10, typeof(TArg10)),
  21381. Expression.Constant(t11, typeof(TArg11)),
  21382. Expression.Constant(t12, typeof(TArg12)),
  21383. Expression.Constant(t13, typeof(TArg13)),
  21384. Expression.Constant(t14, typeof(TArg14))
  21385. )
  21386. );
  21387. }
  21388. #endif
  21389. /// <summary>
  21390. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21391. /// </summary>
  21392. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21393. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21394. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21395. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21396. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21397. /// <exception cref="T:System.ArgumentNullException">
  21398. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21399. /// <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>
  21400. #if PREFERASYNC
  21401. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21402. #endif
  21403. public static Func<IQbservable<TResult>> FromAsyncPattern<TResult>(this IQbservableProvider provider, Expression<Func<AsyncCallback, object, IAsyncResult>> begin, Expression<Func<IAsyncResult, TResult>>end)
  21404. {
  21405. if (provider == null)
  21406. throw new ArgumentNullException("provider");
  21407. if (begin == null)
  21408. throw new ArgumentNullException("begin");
  21409. if (end == null)
  21410. throw new ArgumentNullException("end");
  21411. #if CRIPPLED_REFLECTION
  21412. var m = InfoOf(() => Qbservable.FromAsyncPattern<TResult>(default(IQbservableProvider), default(Expression<Func<AsyncCallback, object, IAsyncResult>>), default(Expression<Func<IAsyncResult, TResult>>)));
  21413. #else
  21414. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult));
  21415. #endif
  21416. return () => provider.CreateQuery<TResult>(
  21417. Expression.Invoke(
  21418. Expression.Call(
  21419. null,
  21420. m,
  21421. Expression.Constant(provider, typeof(IQbservableProvider)),
  21422. begin,
  21423. end
  21424. )
  21425. )
  21426. );
  21427. }
  21428. /// <summary>
  21429. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21430. /// </summary>
  21431. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21432. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21433. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21434. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21435. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21436. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21437. /// <exception cref="T:System.ArgumentNullException">
  21438. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21439. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  21440. #if PREFERASYNC
  21441. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21442. #endif
  21443. public static Func<TArg1, IQbservable<TResult>> FromAsyncPattern<TArg1, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, AsyncCallback, object, IAsyncResult>> begin, Expression<Func<IAsyncResult, TResult>>end)
  21444. {
  21445. if (provider == null)
  21446. throw new ArgumentNullException("provider");
  21447. if (begin == null)
  21448. throw new ArgumentNullException("begin");
  21449. if (end == null)
  21450. throw new ArgumentNullException("end");
  21451. #if CRIPPLED_REFLECTION
  21452. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, AsyncCallback, object, IAsyncResult>>), default(Expression<Func<IAsyncResult, TResult>>)));
  21453. #else
  21454. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TResult));
  21455. #endif
  21456. return (t1) => provider.CreateQuery<TResult>(
  21457. Expression.Invoke(
  21458. Expression.Call(
  21459. null,
  21460. m,
  21461. Expression.Constant(provider, typeof(IQbservableProvider)),
  21462. begin,
  21463. end
  21464. ),
  21465. Expression.Constant(t1, typeof(TArg1))
  21466. )
  21467. );
  21468. }
  21469. /// <summary>
  21470. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21471. /// </summary>
  21472. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21473. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21474. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21475. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21476. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21477. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21478. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21479. /// <exception cref="T:System.ArgumentNullException">
  21480. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21481. /// <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>
  21482. #if PREFERASYNC
  21483. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21484. #endif
  21485. 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)
  21486. {
  21487. if (provider == null)
  21488. throw new ArgumentNullException("provider");
  21489. if (begin == null)
  21490. throw new ArgumentNullException("begin");
  21491. if (end == null)
  21492. throw new ArgumentNullException("end");
  21493. #if CRIPPLED_REFLECTION
  21494. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, AsyncCallback, object, IAsyncResult>>), default(Expression<Func<IAsyncResult, TResult>>)));
  21495. #else
  21496. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TResult));
  21497. #endif
  21498. return (t1, t2) => provider.CreateQuery<TResult>(
  21499. Expression.Invoke(
  21500. Expression.Call(
  21501. null,
  21502. m,
  21503. Expression.Constant(provider, typeof(IQbservableProvider)),
  21504. begin,
  21505. end
  21506. ),
  21507. Expression.Constant(t1, typeof(TArg1)),
  21508. Expression.Constant(t2, typeof(TArg2))
  21509. )
  21510. );
  21511. }
  21512. #if !NO_LARGEARITY
  21513. /// <summary>
  21514. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21515. /// </summary>
  21516. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21517. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21518. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21519. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21520. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21521. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21522. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21523. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21524. /// <exception cref="T:System.ArgumentNullException">
  21525. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21526. /// <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>
  21527. #if PREFERASYNC
  21528. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21529. #endif
  21530. 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)
  21531. {
  21532. if (provider == null)
  21533. throw new ArgumentNullException("provider");
  21534. if (begin == null)
  21535. throw new ArgumentNullException("begin");
  21536. if (end == null)
  21537. throw new ArgumentNullException("end");
  21538. #if CRIPPLED_REFLECTION
  21539. 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>>)));
  21540. #else
  21541. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TResult));
  21542. #endif
  21543. return (t1, t2, t3) => provider.CreateQuery<TResult>(
  21544. Expression.Invoke(
  21545. Expression.Call(
  21546. null,
  21547. m,
  21548. Expression.Constant(provider, typeof(IQbservableProvider)),
  21549. begin,
  21550. end
  21551. ),
  21552. Expression.Constant(t1, typeof(TArg1)),
  21553. Expression.Constant(t2, typeof(TArg2)),
  21554. Expression.Constant(t3, typeof(TArg3))
  21555. )
  21556. );
  21557. }
  21558. /// <summary>
  21559. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21560. /// </summary>
  21561. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21562. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21563. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21564. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21565. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21566. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21567. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21568. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21569. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21570. /// <exception cref="T:System.ArgumentNullException">
  21571. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21572. /// <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>
  21573. #if PREFERASYNC
  21574. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21575. #endif
  21576. 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)
  21577. {
  21578. if (provider == null)
  21579. throw new ArgumentNullException("provider");
  21580. if (begin == null)
  21581. throw new ArgumentNullException("begin");
  21582. if (end == null)
  21583. throw new ArgumentNullException("end");
  21584. #if CRIPPLED_REFLECTION
  21585. 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>>)));
  21586. #else
  21587. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TResult));
  21588. #endif
  21589. return (t1, t2, t3, t4) => provider.CreateQuery<TResult>(
  21590. Expression.Invoke(
  21591. Expression.Call(
  21592. null,
  21593. m,
  21594. Expression.Constant(provider, typeof(IQbservableProvider)),
  21595. begin,
  21596. end
  21597. ),
  21598. Expression.Constant(t1, typeof(TArg1)),
  21599. Expression.Constant(t2, typeof(TArg2)),
  21600. Expression.Constant(t3, typeof(TArg3)),
  21601. Expression.Constant(t4, typeof(TArg4))
  21602. )
  21603. );
  21604. }
  21605. /// <summary>
  21606. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21607. /// </summary>
  21608. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21609. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21610. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21611. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21612. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21613. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21614. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21615. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21616. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21617. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21618. /// <exception cref="T:System.ArgumentNullException">
  21619. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21620. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  21621. #if PREFERASYNC
  21622. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21623. #endif
  21624. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, 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)
  21625. {
  21626. if (provider == null)
  21627. throw new ArgumentNullException("provider");
  21628. if (begin == null)
  21629. throw new ArgumentNullException("begin");
  21630. if (end == null)
  21631. throw new ArgumentNullException("end");
  21632. #if CRIPPLED_REFLECTION
  21633. 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>>)));
  21634. #else
  21635. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TResult));
  21636. #endif
  21637. return (t1, t2, t3, t4, t5) => provider.CreateQuery<TResult>(
  21638. Expression.Invoke(
  21639. Expression.Call(
  21640. null,
  21641. m,
  21642. Expression.Constant(provider, typeof(IQbservableProvider)),
  21643. begin,
  21644. end
  21645. ),
  21646. Expression.Constant(t1, typeof(TArg1)),
  21647. Expression.Constant(t2, typeof(TArg2)),
  21648. Expression.Constant(t3, typeof(TArg3)),
  21649. Expression.Constant(t4, typeof(TArg4)),
  21650. Expression.Constant(t5, typeof(TArg5))
  21651. )
  21652. );
  21653. }
  21654. /// <summary>
  21655. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21656. /// </summary>
  21657. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21658. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21659. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21660. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21661. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21662. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21663. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21664. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21665. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21666. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21667. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21668. /// <exception cref="T:System.ArgumentNullException">
  21669. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21670. /// <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>
  21671. #if PREFERASYNC
  21672. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21673. #endif
  21674. 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)
  21675. {
  21676. if (provider == null)
  21677. throw new ArgumentNullException("provider");
  21678. if (begin == null)
  21679. throw new ArgumentNullException("begin");
  21680. if (end == null)
  21681. throw new ArgumentNullException("end");
  21682. #if CRIPPLED_REFLECTION
  21683. 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>>)));
  21684. #else
  21685. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TResult));
  21686. #endif
  21687. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<TResult>(
  21688. Expression.Invoke(
  21689. Expression.Call(
  21690. null,
  21691. m,
  21692. Expression.Constant(provider, typeof(IQbservableProvider)),
  21693. begin,
  21694. end
  21695. ),
  21696. Expression.Constant(t1, typeof(TArg1)),
  21697. Expression.Constant(t2, typeof(TArg2)),
  21698. Expression.Constant(t3, typeof(TArg3)),
  21699. Expression.Constant(t4, typeof(TArg4)),
  21700. Expression.Constant(t5, typeof(TArg5)),
  21701. Expression.Constant(t6, typeof(TArg6))
  21702. )
  21703. );
  21704. }
  21705. /// <summary>
  21706. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21707. /// </summary>
  21708. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21709. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21710. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21711. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21712. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21713. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21714. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21715. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21716. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21717. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21718. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21719. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21720. /// <exception cref="T:System.ArgumentNullException">
  21721. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21722. /// <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>
  21723. #if PREFERASYNC
  21724. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21725. #endif
  21726. 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)
  21727. {
  21728. if (provider == null)
  21729. throw new ArgumentNullException("provider");
  21730. if (begin == null)
  21731. throw new ArgumentNullException("begin");
  21732. if (end == null)
  21733. throw new ArgumentNullException("end");
  21734. #if CRIPPLED_REFLECTION
  21735. 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>>)));
  21736. #else
  21737. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TResult));
  21738. #endif
  21739. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<TResult>(
  21740. Expression.Invoke(
  21741. Expression.Call(
  21742. null,
  21743. m,
  21744. Expression.Constant(provider, typeof(IQbservableProvider)),
  21745. begin,
  21746. end
  21747. ),
  21748. Expression.Constant(t1, typeof(TArg1)),
  21749. Expression.Constant(t2, typeof(TArg2)),
  21750. Expression.Constant(t3, typeof(TArg3)),
  21751. Expression.Constant(t4, typeof(TArg4)),
  21752. Expression.Constant(t5, typeof(TArg5)),
  21753. Expression.Constant(t6, typeof(TArg6)),
  21754. Expression.Constant(t7, typeof(TArg7))
  21755. )
  21756. );
  21757. }
  21758. /// <summary>
  21759. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21760. /// </summary>
  21761. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21762. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21763. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21764. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21765. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21766. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21767. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21768. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21769. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21770. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21771. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21772. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21773. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21774. /// <exception cref="T:System.ArgumentNullException">
  21775. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21776. /// <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>
  21777. #if PREFERASYNC
  21778. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21779. #endif
  21780. 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)
  21781. {
  21782. if (provider == null)
  21783. throw new ArgumentNullException("provider");
  21784. if (begin == null)
  21785. throw new ArgumentNullException("begin");
  21786. if (end == null)
  21787. throw new ArgumentNullException("end");
  21788. #if CRIPPLED_REFLECTION
  21789. 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>>)));
  21790. #else
  21791. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TResult));
  21792. #endif
  21793. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<TResult>(
  21794. Expression.Invoke(
  21795. Expression.Call(
  21796. null,
  21797. m,
  21798. Expression.Constant(provider, typeof(IQbservableProvider)),
  21799. begin,
  21800. end
  21801. ),
  21802. Expression.Constant(t1, typeof(TArg1)),
  21803. Expression.Constant(t2, typeof(TArg2)),
  21804. Expression.Constant(t3, typeof(TArg3)),
  21805. Expression.Constant(t4, typeof(TArg4)),
  21806. Expression.Constant(t5, typeof(TArg5)),
  21807. Expression.Constant(t6, typeof(TArg6)),
  21808. Expression.Constant(t7, typeof(TArg7)),
  21809. Expression.Constant(t8, typeof(TArg8))
  21810. )
  21811. );
  21812. }
  21813. /// <summary>
  21814. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21815. /// </summary>
  21816. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21817. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21818. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21819. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21820. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21821. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21822. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21823. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21824. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21825. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21826. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21827. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21828. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21829. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21830. /// <exception cref="T:System.ArgumentNullException">
  21831. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21832. /// <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>
  21833. #if PREFERASYNC
  21834. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21835. #endif
  21836. 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)
  21837. {
  21838. if (provider == null)
  21839. throw new ArgumentNullException("provider");
  21840. if (begin == null)
  21841. throw new ArgumentNullException("begin");
  21842. if (end == null)
  21843. throw new ArgumentNullException("end");
  21844. #if CRIPPLED_REFLECTION
  21845. 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>>)));
  21846. #else
  21847. 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));
  21848. #endif
  21849. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<TResult>(
  21850. Expression.Invoke(
  21851. Expression.Call(
  21852. null,
  21853. m,
  21854. Expression.Constant(provider, typeof(IQbservableProvider)),
  21855. begin,
  21856. end
  21857. ),
  21858. Expression.Constant(t1, typeof(TArg1)),
  21859. Expression.Constant(t2, typeof(TArg2)),
  21860. Expression.Constant(t3, typeof(TArg3)),
  21861. Expression.Constant(t4, typeof(TArg4)),
  21862. Expression.Constant(t5, typeof(TArg5)),
  21863. Expression.Constant(t6, typeof(TArg6)),
  21864. Expression.Constant(t7, typeof(TArg7)),
  21865. Expression.Constant(t8, typeof(TArg8)),
  21866. Expression.Constant(t9, typeof(TArg9))
  21867. )
  21868. );
  21869. }
  21870. /// <summary>
  21871. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21872. /// </summary>
  21873. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21874. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21875. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21876. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21877. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21878. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21879. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21880. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21881. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21882. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21883. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21884. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21885. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21886. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21887. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21888. /// <exception cref="T:System.ArgumentNullException">
  21889. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21890. /// <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>
  21891. #if PREFERASYNC
  21892. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21893. #endif
  21894. 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)
  21895. {
  21896. if (provider == null)
  21897. throw new ArgumentNullException("provider");
  21898. if (begin == null)
  21899. throw new ArgumentNullException("begin");
  21900. if (end == null)
  21901. throw new ArgumentNullException("end");
  21902. #if CRIPPLED_REFLECTION
  21903. 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>>)));
  21904. #else
  21905. 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));
  21906. #endif
  21907. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<TResult>(
  21908. Expression.Invoke(
  21909. Expression.Call(
  21910. null,
  21911. m,
  21912. Expression.Constant(provider, typeof(IQbservableProvider)),
  21913. begin,
  21914. end
  21915. ),
  21916. Expression.Constant(t1, typeof(TArg1)),
  21917. Expression.Constant(t2, typeof(TArg2)),
  21918. Expression.Constant(t3, typeof(TArg3)),
  21919. Expression.Constant(t4, typeof(TArg4)),
  21920. Expression.Constant(t5, typeof(TArg5)),
  21921. Expression.Constant(t6, typeof(TArg6)),
  21922. Expression.Constant(t7, typeof(TArg7)),
  21923. Expression.Constant(t8, typeof(TArg8)),
  21924. Expression.Constant(t9, typeof(TArg9)),
  21925. Expression.Constant(t10, typeof(TArg10))
  21926. )
  21927. );
  21928. }
  21929. /// <summary>
  21930. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21931. /// </summary>
  21932. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21933. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21934. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21935. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21936. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21937. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21938. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21939. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21940. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21941. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21942. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21943. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  21944. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21945. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21946. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21947. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21948. /// <exception cref="T:System.ArgumentNullException">
  21949. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21950. /// <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>
  21951. #if PREFERASYNC
  21952. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21953. #endif
  21954. 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)
  21955. {
  21956. if (provider == null)
  21957. throw new ArgumentNullException("provider");
  21958. if (begin == null)
  21959. throw new ArgumentNullException("begin");
  21960. if (end == null)
  21961. throw new ArgumentNullException("end");
  21962. #if CRIPPLED_REFLECTION
  21963. 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>>)));
  21964. #else
  21965. 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));
  21966. #endif
  21967. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<TResult>(
  21968. Expression.Invoke(
  21969. Expression.Call(
  21970. null,
  21971. m,
  21972. Expression.Constant(provider, typeof(IQbservableProvider)),
  21973. begin,
  21974. end
  21975. ),
  21976. Expression.Constant(t1, typeof(TArg1)),
  21977. Expression.Constant(t2, typeof(TArg2)),
  21978. Expression.Constant(t3, typeof(TArg3)),
  21979. Expression.Constant(t4, typeof(TArg4)),
  21980. Expression.Constant(t5, typeof(TArg5)),
  21981. Expression.Constant(t6, typeof(TArg6)),
  21982. Expression.Constant(t7, typeof(TArg7)),
  21983. Expression.Constant(t8, typeof(TArg8)),
  21984. Expression.Constant(t9, typeof(TArg9)),
  21985. Expression.Constant(t10, typeof(TArg10)),
  21986. Expression.Constant(t11, typeof(TArg11))
  21987. )
  21988. );
  21989. }
  21990. /// <summary>
  21991. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21992. /// </summary>
  21993. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  21994. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21995. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21996. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21997. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21998. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21999. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22000. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  22001. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  22002. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  22003. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  22004. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  22005. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  22006. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22007. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22008. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22009. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22010. /// <exception cref="T:System.ArgumentNullException">
  22011. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22012. /// <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>
  22013. #if PREFERASYNC
  22014. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22015. #endif
  22016. 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)
  22017. {
  22018. if (provider == null)
  22019. throw new ArgumentNullException("provider");
  22020. if (begin == null)
  22021. throw new ArgumentNullException("begin");
  22022. if (end == null)
  22023. throw new ArgumentNullException("end");
  22024. #if CRIPPLED_REFLECTION
  22025. 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>>)));
  22026. #else
  22027. 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));
  22028. #endif
  22029. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<TResult>(
  22030. Expression.Invoke(
  22031. Expression.Call(
  22032. null,
  22033. m,
  22034. Expression.Constant(provider, typeof(IQbservableProvider)),
  22035. begin,
  22036. end
  22037. ),
  22038. Expression.Constant(t1, typeof(TArg1)),
  22039. Expression.Constant(t2, typeof(TArg2)),
  22040. Expression.Constant(t3, typeof(TArg3)),
  22041. Expression.Constant(t4, typeof(TArg4)),
  22042. Expression.Constant(t5, typeof(TArg5)),
  22043. Expression.Constant(t6, typeof(TArg6)),
  22044. Expression.Constant(t7, typeof(TArg7)),
  22045. Expression.Constant(t8, typeof(TArg8)),
  22046. Expression.Constant(t9, typeof(TArg9)),
  22047. Expression.Constant(t10, typeof(TArg10)),
  22048. Expression.Constant(t11, typeof(TArg11)),
  22049. Expression.Constant(t12, typeof(TArg12))
  22050. )
  22051. );
  22052. }
  22053. /// <summary>
  22054. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22055. /// </summary>
  22056. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  22057. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22058. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22059. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22060. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22061. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22062. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22063. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  22064. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  22065. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  22066. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  22067. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  22068. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  22069. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the begin delegate.</typeparam>
  22070. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22071. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22072. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22073. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22074. /// <exception cref="T:System.ArgumentNullException">
  22075. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22076. /// <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>
  22077. #if PREFERASYNC
  22078. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22079. #endif
  22080. 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)
  22081. {
  22082. if (provider == null)
  22083. throw new ArgumentNullException("provider");
  22084. if (begin == null)
  22085. throw new ArgumentNullException("begin");
  22086. if (end == null)
  22087. throw new ArgumentNullException("end");
  22088. #if CRIPPLED_REFLECTION
  22089. 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>>)));
  22090. #else
  22091. 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));
  22092. #endif
  22093. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<TResult>(
  22094. Expression.Invoke(
  22095. Expression.Call(
  22096. null,
  22097. m,
  22098. Expression.Constant(provider, typeof(IQbservableProvider)),
  22099. begin,
  22100. end
  22101. ),
  22102. Expression.Constant(t1, typeof(TArg1)),
  22103. Expression.Constant(t2, typeof(TArg2)),
  22104. Expression.Constant(t3, typeof(TArg3)),
  22105. Expression.Constant(t4, typeof(TArg4)),
  22106. Expression.Constant(t5, typeof(TArg5)),
  22107. Expression.Constant(t6, typeof(TArg6)),
  22108. Expression.Constant(t7, typeof(TArg7)),
  22109. Expression.Constant(t8, typeof(TArg8)),
  22110. Expression.Constant(t9, typeof(TArg9)),
  22111. Expression.Constant(t10, typeof(TArg10)),
  22112. Expression.Constant(t11, typeof(TArg11)),
  22113. Expression.Constant(t12, typeof(TArg12)),
  22114. Expression.Constant(t13, typeof(TArg13))
  22115. )
  22116. );
  22117. }
  22118. /// <summary>
  22119. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22120. /// </summary>
  22121. /// <param name="provider">Query provider used to construct the IQbservable&lt;T&gt; data source.</param>
  22122. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22123. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22124. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22125. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22126. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22127. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22128. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  22129. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  22130. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  22131. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  22132. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  22133. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  22134. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the begin delegate.</typeparam>
  22135. /// <typeparam name="TArg14">The type of the fourteenth 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, 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)
  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, 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>>)));
  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(TArg9), typeof(TArg10), typeof(TArg11), typeof(TArg12), typeof(TArg13), typeof(TArg14), typeof(TResult));
  22158. #endif
  22159. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => 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. Expression.Constant(t9, typeof(TArg9)),
  22177. Expression.Constant(t10, typeof(TArg10)),
  22178. Expression.Constant(t11, typeof(TArg11)),
  22179. Expression.Constant(t12, typeof(TArg12)),
  22180. Expression.Constant(t13, typeof(TArg13)),
  22181. Expression.Constant(t14, typeof(TArg14))
  22182. )
  22183. );
  22184. }
  22185. #endif
  22186. }
  22187. }
  22188. #endif
  22189. #pragma warning restore 1591