internal static void Construct <TDstContainer, TSrcContainer>( ref TDstContainer dstContainer, ref TSrcContainer srcContainer, VisitResult result, PropertyContainerConstructOptions options = default) { if (RuntimeTypeInfoCache <TDstContainer> .IsAbstractOrInterface() || typeof(TDstContainer) != dstContainer.GetType()) { var propertyBag = PropertyBagResolver.Resolve(dstContainer.GetType()); var action = new ConstructAbstractType <TSrcContainer> { Options = options, Result = result, SrcContainer = srcContainer, DstContainerBoxed = dstContainer }; propertyBag.Cast(ref action); dstContainer = (TDstContainer)action.DstContainerBoxed; } else { var visitor = new TypeConstructionVisitor <TDstContainer>(dstContainer, result, options); Visit(ref srcContainer, ref visitor); dstContainer = visitor.Target; } }
static void DoTransfer <TDestination, TSource>(ref TDestination destination, ref TSource source, ref ChangeTracker changeTracker) { if (RuntimeTypeInfoCache <TSource> .IsAbstractOrInterface() || typeof(TSource) != source.GetType()) { var propertyBag = PropertyBagResolver.Resolve(source.GetType()); var action = new TransferAbstractType <TDestination> { Destination = destination, SourceContainer = source }; propertyBag.Cast(ref action); destination = action.Destination; } else { Visit(ref destination, new TransferVisitor <TSource>(source), ref changeTracker); } }
static void Transfer <TDstContainer, TSrcContainer>( ref TDstContainer dstContainer, ref TSrcContainer srcContainer, VisitResult result) { if (RuntimeTypeInfoCache <TDstContainer> .IsAbstractOrInterface() || typeof(TDstContainer) != dstContainer.GetType()) { var propertyBag = PropertyBagResolver.Resolve(dstContainer.GetType()); var action = new TransferAbstractType <TSrcContainer> { Result = result, SrcContainer = srcContainer, DstContainerBoxed = dstContainer }; propertyBag.Cast(ref action); dstContainer = (TDstContainer)action.DstContainerBoxed; } else { var visitor = new TransferVisitor <TDstContainer>(dstContainer, result); Visit(ref srcContainer, ref visitor); dstContainer = visitor.Target; } }