Пример #1
0
        protected override VisitStatus Visit <TProperty, TContainer, TValue>(
            TProperty property,
            ref TContainer container,
            ref TValue value,
            ref ChangeTracker changeTracker)
        {
            if (typeof(TValue).IsClass && null == value)
            {
                return(VisitStatus.Override);
            }

            var propName = property.GetName();

            Add(propName);
            try
            {
                if (m_FullPathToElementsMap.TryGetValue(m_PropertyPathBuilder.ToString(), out var fullPathElements))
                {
                    foreach (var element in fullPathElements)
                    {
                        switch (m_Operation)
                        {
                        case BindingRegistration.None:
                            Connectors.SetData(element, value);
                            break;

                        case BindingRegistration.Register:
                            Connectors.RegisterCallback(element, value);
                            break;

                        case BindingRegistration.Unregister:
                            Connectors.UnregisterCallback(element, value);
                            break;

                        default:
                            throw new ArgumentOutOfRangeException();
                        }
                    }
                }
            }
            finally
            {
                Remove(propName);
            }
            return(VisitStatus.Handled);
        }