Пример #1
0
            public void Invoke <TDstContainer>()
            {
                var visitor = new TransferVisitor <TDstContainer>((TDstContainer)DstContainerBoxed, Result);

                Visit(ref SrcContainer, ref visitor);
                DstContainerBoxed = visitor.Target;
            }
        public static TDestination Transfer <TSource, TDestination>(ref TSource source)
            where TSource : struct, IPropertyContainer
            where TDestination : struct, IStructPropertyContainer <TDestination>
        {
            var visitor = new TransferVisitor(new TDestination());

            Visit(ref source, visitor);
            return((TDestination)visitor.Pop());
        }
Пример #3
0
 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;
     }
 }