Пример #1
0
 public SetOfPolymorphic(Business.SetOfPolymorphic source)
 {
     Id = source.Id;
     if (source.PolymorphicBaseClasses != null)
     {
         PolymorphicBaseClasses = source.PolymorphicBaseClasses.Select(x => PolymorphicBaseClass.GetMostConcrete(x)).ToArray();
     }
 }
Пример #2
0
        public void CoreTestFillMapPolymorph()
        {
            var source = PolymorphicSubClass.Create(5);
            var manual = new DTO.PolymorphicSubClass(source);

            var dto = new DTO.PolymorphicSubClass();

            Mapper.Fill(source, dto);
            Assert.Equal(dto, manual);

            dto = new DTO.PolymorphicSubClass();
            Mapper.Fill <PolymorphicBaseClass, DTO.PolymorphicBaseClass>(source, dto);
            Assert.Equal(dto, manual);

            dto = new DTO.PolymorphicSubClass();
            Mapper.Fill <PolymorphicBaseClass, object>(source, dto);
            Assert.Equal(dto, manual);

            var dto2 = new DTO.PolymorphicBaseClass();

            Mapper.Fill <PolymorphicBaseClass, object>(source, dto2);
            var manual2 = new DTO.PolymorphicBaseClass
            {
                Id = source.Id,
                // AString is still filled according to the subclass mapping
                AString = source.AString.ToUpper()
            };

            Assert.Equal(dto2, manual2);

            var dto3 = new DTO.PolymorphicSubSubClass();

            Mapper.Fill(source, dto3);
            dto = new DTO.PolymorphicSubClass()
            {
                Id = dto3.Id, AString = dto3.AString, Name = dto3.Name
            };
            Assert.Equal(dto, manual);
        }
Пример #3
0
 public MappedObjectGeneric(Business.MappedObjectGeneric <Business.PolymorphicBaseClass> source)
 {
     Id              = source.Id;
     AString         = source.AString;
     GenericProperty = (T)(object)PolymorphicBaseClass.GetMostConcrete(source.GenericProperty);
 }