c# - How Can I Unfold This Event to an Observable Sequence? -


i'm trying write add-in outlook, , 1 of events i'm using itemsevents_event.itemchange - , handler's signature takes object parameter (the item changed):

items.itemchange += calendaritems_itemchange;  private void calendaritems_itemchange(object anitem) {...} 

how use observable.fromevent or observable.fromeventpattern create observable sequence event "stream" instead of attaching/detaching event usual?

you need use fromevent conversion overload tell rx how should interpret event:

iobservable<teventargs> fromevent<tdelegate, teventargs>(func<action<teventargs>, tdelegate> conversion,                                                           action<tdelegate> addhandler,                                                           action<tdelegate> removehandler); 

in case like:

var source = observable.fromevent<itemsevents_itemeventchangehandler, object>(   emit => new itemsevents_itemeventchangehandler((obj) => emit(obj)),   h => items.itemchange += h,   h => items.itemchange -= h); 

similar answer


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

how to prompt save As Box in Excel Interlop c# MVC 4 -

xslt 1.0 - How to access or retrieve mets content of an item from another item? -