/// <summary> /// When overridden in a derived class, gives the class an opportunity to monitor the current target. /// </summary> protected override void MonitorCurrentTargetOverride() { var currentTarget = CurrentTarget as DependencyObject; if (currentTarget != null) { //var dpd = DependencyPropertyDescriptor.FromProperty(_dependencyProperty, currentTarget.GetType()); //if (dpd != null) //{ // dpd.AddValueChanged(currentTarget, CurrentTarget_PropertyChanged); //} var eventInfo = CurrentTarget.GetType().GetEvent(PropertyName + "Changed"); if (eventInfo != null) { var addMethod = eventInfo.GetAddMethod(); if (addMethod != null) { var pi = addMethod.GetParameters()[0]; var d = Delegate.CreateDelegate(pi.ParameterType, this, GetType().GetMethod("CurrentTarget_PropertyChanged", BindingFlags.Public | BindingFlags.Instance)); addMethod.Invoke(CurrentTarget, new object[] { d }); } } } }
protected override void DiscardCurrentTargetOverride() { CurrentTarget?.GetType().GetEvent(PropertyName + "Changed")?.GetRemoveMethod() .Invoke(CurrentTarget, new object[] { _actualHandler }); }
protected override void MonitorCurrentTargetOverride() { if (CurrentTarget is INotifyPropertyChanged notifyPropertyChanged) { notifyPropertyChanged.PropertyChanged += _weakHandlerWrapper; } _propertyReader = PropertyReaderFactory.Create <object>(CurrentTarget.GetType(), PropertyName); }
protected override void MonitorCurrentTargetOverride() { CurrentTarget?.GetType().GetEvent(PropertyName + "Changed")?.GetAddMethod() .Invoke(CurrentTarget, new object[] { _actualHandler }); _propertyReader = PropertyReaderFactory.Create <object>(CurrentTarget?.GetType(), PropertyName); }
IEnumerable <FieldInfo> GetSerializedScriptableObjectFields() { foreach (var field in CurrentTarget.GetType().GetFields(NodeEditorUtilities.StandardBindingFlags).Where(x => x.FieldType.IsSubclassOf(typeof(ScriptableObject)))) { if (field.IsPublic || field.GetCustomAttributes(typeof(SerializeField), true).Count() > 0) { yield return(field); } } }
/// <summary> /// When overridden in a derived class, gives the class an opportunity to monitor the current target. /// </summary> protected override void MonitorCurrentTargetOverride() { var currentTarget = CurrentTarget as INotifyPropertyChanged; if (currentTarget != null) { currentTarget.PropertyChanged += _weakHandlerWrapper; } _propertyReader = PropertyReaderFactory.Create <object>(CurrentTarget.GetType(), PropertyName); }
/// <summary> /// When overridden in a derived class, gives the class an opportunity to discard the current target. /// </summary> protected override void DiscardCurrentTargetOverride() { if (CurrentTarget != null) { var eventInfo = CurrentTarget.GetType().GetEvent(PropertyName + "Changed"); if (eventInfo != null) { var removeMethod = eventInfo.GetRemoveMethod(); if (removeMethod != null) { removeMethod.Invoke(CurrentTarget, new object[] { _actualHandler }); } } } }
/// <summary> /// When overridden in a derived class, gives the class an opportunity to monitor the current target. /// </summary> protected override void MonitorCurrentTargetOverride() { if (CurrentTarget != null) { var eventInfo = CurrentTarget.GetType().GetEvent(PropertyName + "Changed"); if (eventInfo != null) { var addMethod = eventInfo.GetAddMethod(); if (addMethod != null) { addMethod.Invoke(CurrentTarget, new object[] { _actualHandler }); } } } _propertyReader = PropertyReaderFactory.Create <object>(CurrentTarget.GetType(), PropertyName); }
/// <summary> /// When overridden in a derived class, gives the class an opportunity to discard the current target. /// </summary> protected override void DiscardCurrentTargetOverride() { var currentTarget = CurrentTarget as DependencyObject; if (currentTarget != null) { //var dpd = DependencyPropertyDescriptor.FromProperty(_dependencyProperty, currentTarget.GetType()); //if (dpd != null) //{ // dpd.RemoveValueChanged(currentTarget, CurrentTarget_PropertyChanged); //} var eventInfo = CurrentTarget.GetType().GetEvent(PropertyName + "Changed"); if (eventInfo != null) { var removeMethod = eventInfo.GetRemoveMethod(); if (removeMethod != null) { removeMethod.Invoke(CurrentTarget, new object[] { _actualHandler }); } } } }