public void VisitProperty <TSourceProperty, TSourceValue>(TSourceProperty srcProperty, ref TSourceContainer srcContainer, ref ChangeTracker propertyChangeTracker)
                where TSourceProperty : IProperty <TSourceContainer, TSourceValue>
            {
                var srcValue = srcProperty.GetValue(ref srcContainer);

                if (TypeConversion.TryConvert <TSourceValue, TDestinationValue>(srcValue, out var dstValue))
                {
                    if (CustomEquality.Equals(dstValue, DstProperty.GetValue(ref DstContainer)))
                    {
                        return;
                    }

                    DstProperty.SetValue(ref DstContainer, dstValue);
                    propertyChangeTracker.IncrementVersion <TDestinationProperty, TDestinationContainer, TDestinationValue>(DstProperty, ref DstContainer);
                    return;
                }

                if (DstProperty.IsContainer)
                {
                    var changeTracker = new ChangeTracker(propertyChangeTracker.VersionStorage);

                    dstValue = DstProperty.GetValue(ref DstContainer);

                    PropertyContainer.Transfer(ref dstValue, ref srcValue, ref changeTracker);

                    DstProperty.SetValue(ref DstContainer, dstValue);

                    if (changeTracker.IsChanged())
                    {
                        propertyChangeTracker.IncrementVersion <TDestinationProperty, TDestinationContainer, TDestinationValue>(DstProperty, ref DstContainer);
                    }
                }
            }
                public void VisitProperty <TDestinationElementProperty, TDestinationElement>(TDestinationElementProperty dstElementProperty, ref TDestinationContainer dstContainer, ref ChangeTracker propertyChangeTracker)
                    where TDestinationElementProperty : ICollectionElementProperty <TDestinationContainer, TDestinationElement>
                {
                    if (TypeConversion.TryConvert <TSourceElement, TDestinationElement>(SrcElementValue, out var dstElementValue))
                    {
                        if (CustomEquality.Equals(dstElementValue, dstElementProperty.GetValue(ref dstContainer)))
                        {
                            return;
                        }

                        dstElementProperty.SetValue(ref dstContainer, dstElementValue);
                        propertyChangeTracker.IncrementVersion <TDestinationElementProperty, TDestinationContainer, TDestinationElement>(dstElementProperty, ref dstContainer);
                        return;
                    }

                    if (dstElementProperty.IsContainer)
                    {
                        var changeTracker = new ChangeTracker(propertyChangeTracker.VersionStorage);

                        dstElementValue = dstElementProperty.GetValue(ref dstContainer);

                        PropertyContainer.Transfer(ref dstElementValue, ref SrcElementValue, ref changeTracker);

                        dstElementProperty.SetValue(ref dstContainer, dstElementValue);

                        if (changeTracker.IsChanged())
                        {
                            propertyChangeTracker.IncrementVersion <TDestinationElementProperty, TDestinationContainer, TDestinationElement>(dstElementProperty, ref dstContainer);
                        }
                    }
                }
Esempio n. 3
0
            public void VisitProperty <TProperty, TDestinationValue>(TProperty property, ref TContainer container, ref ChangeTracker changeTracker)
                where TProperty : IProperty <TContainer, TDestinationValue>
            {
                if (!TypeConversion.TryConvert <TSourceValue, TDestinationValue>(SrcValue, out var dstValue))
                {
                    Result = k_ResultErrorConvert;
                    return;
                }

                if (CustomEquality.Equals(dstValue, property.GetValue(ref container)))
                {
                    return;
                }

                property.SetValue(ref container, dstValue);
                changeTracker.IncrementVersion <TProperty, TContainer, TDestinationValue>(property, ref container);
            }