Пример #1
0
                public void VisitCollectionProperty <TDstProperty, TDstValue>(
                    TDstProperty dstProperty,
                    ref TDstContainer dstContainer,
                    ref ChangeTracker changeTracker)
                    where TDstProperty : ICollectionProperty <TDstContainer, TDstValue>
                {
                    if (dstProperty.IsReadOnly)
                    {
                        return;
                    }

                    var dstValue = dstProperty.GetValue(ref dstContainer);

                    if (!RuntimeTypeInfoCache <TSrcValue> .IsValueType() && null == SrcValue)
                    {
                        dstProperty.SetValue(ref dstContainer, default);
                    }
                    else if (RuntimeTypeInfoCache <TSrcValue> .IsValueType() || null != dstValue)
                    {
                        var srcCount = SrcProperty.GetCount(ref SrcContainer);
                        var dstCount = dstProperty.GetCount(ref dstContainer);

                        if (srcCount != dstCount)
                        {
                            dstProperty.SetCount(ref dstContainer, srcCount);
                        }

                        for (var i = 0; i < srcCount; i++)
                        {
                            var action = new SrcCollectionElementGetter <TDstProperty, TDstValue>
                            {
                                Result       = Result,
                                DstProperty  = dstProperty,
                                DstContainer = dstContainer,
                                Index        = i
                            };

                            SrcProperty.GetPropertyAtIndex(ref SrcContainer, i, ref changeTracker, ref action);

                            dstContainer = action.DstContainer;
                        }
                    }
                    else
                    {
                        Result.AddLog($"PropertyContainer.Transfer ContainerType=[{typeof(TDstContainer)}] PropertyName=[{dstProperty.GetName()}] could not be transferred.");
                    }
                }