internal void UnregisterBinding(BindingRegistration registration) { if (registration.InternalRegistration != null) { if (_bindings.TryGetValue(registration.PropertyName, out List <InternalBindingRegistration> internalRegistrations)) { internalRegistrations.Remove(registration.InternalRegistration); if (internalRegistrations.Count == 0) { _bindings.Remove(registration.PropertyName); } } } else { if (_subPropertyBindings.TryGetValue(registration.PropertyName, out BindingHost subBindingHost)) { subBindingHost.UnregisterBinding(registration.SubRegistration); if (subBindingHost.IsEmpty()) { subBindingHost.Unregister(); _subPropertyBindings.Remove(registration.PropertyName); } } } }
/// <summary> /// Will ensure events aren't triggered when value is set /// </summary> /// <param name="propertyPath"></param> /// <param name="value"></param> internal void SetValue(string[] propertyPath, object value, BindingRegistration bindingRegistrationToSkipNotifying, PropertyInfoAndObject preObtainedSourceProperty = null) { var property = preObtainedSourceProperty ?? GetProperty(propertyPath); if (property != null) { BindingHost bindingHost = null; InternalBindingRegistration internalRegistrationToSkip = null; if (bindingRegistrationToSkipNotifying != null) { internalRegistrationToSkip = bindingRegistrationToSkipNotifying.GetFinalInternalRegistration(); bindingHost = FindBindingHost(propertyPath); if (bindingHost != null) { bindingHost._bindingRegistrationToSkipOnce = internalRegistrationToSkip; } } try { property.PropertyInfo.SetValue(property.Object, value); } finally { if (bindingHost != null && bindingHost._bindingRegistrationToSkipOnce == internalRegistrationToSkip) { bindingHost._bindingRegistrationToSkipOnce = null; } } } }
internal BindingRegistration(BindingHost host, string propertyName, BindingRegistration subRegistration, string[] fullPropertyPath) { BindingHost = host; PropertyName = propertyName; SubRegistration = subRegistration; _fullPropertyPath = fullPropertyPath; }