Click here to Skip to main content
15,891,372 members
Home / Discussions / C#
   

C#

 
QuestionSubscribe to property changes using Reactive Extensions Pin
Kenneth Haugland29-Jan-16 2:18
mvaKenneth Haugland29-Jan-16 2:18 
AnswerRe: Subscribe to property changes using Reactive Extensions Pin
Pete O'Hanlon29-Jan-16 3:25
mvePete O'Hanlon29-Jan-16 3:25 
GeneralRe: Subscribe to property changes using Reactive Extensions Pin
Kenneth Haugland29-Jan-16 4:47
mvaKenneth Haugland29-Jan-16 4:47 
GeneralRe: Subscribe to property changes using Reactive Extensions Pin
Richard Deeming29-Jan-16 5:03
mveRichard Deeming29-Jan-16 5:03 
GeneralRe: Subscribe to property changes using Reactive Extensions Pin
Kenneth Haugland29-Jan-16 5:22
mvaKenneth Haugland29-Jan-16 5:22 
AnswerRe: Subscribe to property changes using Reactive Extensions Pin
Richard Deeming29-Jan-16 3:31
mveRichard Deeming29-Jan-16 3:31 
GeneralRe: Subscribe to property changes using Reactive Extensions Pin
Kenneth Haugland29-Jan-16 4:56
mvaKenneth Haugland29-Jan-16 4:56 
AnswerRe: Subscribe to property changes using Reactive Extensions Pin
Sascha Lefèvre29-Jan-16 3:49
professionalSascha Lefèvre29-Jan-16 3:49 
You're feeding a PropertyChangedEventHandler into the Observable but AddValueChanged(..) and RemoveValueChanged(..) expect a plain EventHandler. So for the first argument of Observable.FromEvent(..) you have to create a delegate that takes the PropertyChangedEventHandler and returns an EventHandler:
C#
return Observable.FromEvent<EventHandler, EventArgs>(
    propertyChangedHandler =>
    {
        EventHandler handler = (s, e) => propertyChangedHandler(e);
        return handler;
    },
    h => propertyDescriptor.AddValueChanged(target, h),
    h => propertyDescriptor.RemoveValueChanged(target, h))
    .Select(x => propertyExpr.Compile()(target));
Or shorter syntax:
C#
return Observable.FromEvent<EventHandler, EventArgs>(
    propertyChangedHandler => (s, e) => propertyChangedHandler(e),
    h => propertyDescriptor.AddValueChanged(target, h),
    h => propertyDescriptor.RemoveValueChanged(target, h))
    .Select(x => propertyExpr.Compile()(target));

Edit: Too slow..
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

GeneralRe: Subscribe to property changes using Reactive Extensions Pin
Kenneth Haugland29-Jan-16 4:59
mvaKenneth Haugland29-Jan-16 4:59 
GeneralRe: Subscribe to property changes using Reactive Extensions Pin
Sascha Lefèvre29-Jan-16 5:30
professionalSascha Lefèvre29-Jan-16 5:30 
GeneralRe: Subscribe to property changes using Reactive Extensions Pin
Kenneth Haugland29-Jan-16 5:51
mvaKenneth Haugland29-Jan-16 5:51 
QuestionEnable / Disable DNS Client service (c#) Pin
Member 1041097228-Jan-16 22:21
Member 1041097228-Jan-16 22:21 
AnswerRe: Enable / Disable DNS Client service (c#) Pin
Nathan Minier29-Jan-16 2:05
professionalNathan Minier29-Jan-16 2:05 
GeneralRe: Enable / Disable DNS Client service (c#) Pin
Member 1041097229-Jan-16 5:21
Member 1041097229-Jan-16 5:21 
GeneralRe: Enable / Disable DNS Client service (c#) Pin
Nathan Minier29-Jan-16 5:28
professionalNathan Minier29-Jan-16 5:28 
AnswerRe: Enable / Disable DNS Client service (c#) Pin
Eddy Vluggen29-Jan-16 2:19
professionalEddy Vluggen29-Jan-16 2:19 
GeneralRe: Enable / Disable DNS Client service (c#) Pin
Member 1041097229-Jan-16 5:25
Member 1041097229-Jan-16 5:25 
QuestionHow to change utc Date in a normal Date Pin
Member 1191673528-Jan-16 2:20
Member 1191673528-Jan-16 2:20 
AnswerRe: How to change utc Date in a normal Date Pin
Sascha Lefèvre28-Jan-16 3:06
professionalSascha Lefèvre28-Jan-16 3:06 
GeneralRe: How to change utc Date in a normal Date Pin
jschell29-Jan-16 12:26
jschell29-Jan-16 12:26 
AnswerRe: How to change utc Date in a normal Date Pin
Eddy Vluggen28-Jan-16 3:19
professionalEddy Vluggen28-Jan-16 3:19 
AnswerRe: How to change utc Date in a normal Date Pin
Midi_Mick28-Jan-16 14:00
professionalMidi_Mick28-Jan-16 14:00 
AnswerRe: How to change utc Date in a normal Date Pin
John Torjo28-Jan-16 19:54
professionalJohn Torjo28-Jan-16 19:54 
AnswerRe: How to change utc Date in a normal Date Pin
Member 1191673528-Jan-16 20:41
Member 1191673528-Jan-16 20:41 
GeneralRe: How to change utc Date in a normal Date Pin
Richard MacCutchan28-Jan-16 22:38
mveRichard MacCutchan28-Jan-16 22:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.