private IObservable<object> CreateObservableFromNodes(IEnumerable<InpcNode> subscriptions) { return subscriptions.Select( subscription => Observable.FromEventPattern<PropertyChangedEventHandler, PropertyChangedEventArgs>( ev => subscription.Parent.PropertyChanged += ev, handler => subscription.Parent.PropertyChanged -= handler) .Do(_ => this.mountPoint = new PropertyMountPoint(this.root, this.propertyPath)) .Where(pattern => pattern.EventArgs.PropertyName == subscription.PropertyName)) .Merge(); }
public ObservablePropertyBranch(object root, PropertyPath propertyPath) { Guard.ThrowIfNull(root, nameof(root)); Guard.ThrowIfNull(propertyPath, nameof(propertyPath)); this.root = root; this.propertyPath = propertyPath; this.mountPoint = new PropertyMountPoint(root, propertyPath); var subscriptions = this.GetInpcNodes(); this.Changed = this.CreateObservableFromNodes(subscriptions); }
public ObservablePropertyBranch(object instance, PropertyPath propertyPath) { Guard.ThrowIfNull(instance, nameof(instance)); Guard.ThrowIfNull(propertyPath, nameof(propertyPath)); _instance = instance; _propertyPath = propertyPath; _mountPoint = new PropertyMountPoint(instance, propertyPath); var properties = GetPropertiesThatRaiseNotifications(); Values = CreateUnifiedObservableFromNodes(properties); }