コード例 #1
0
        public TOut ToBusinessObject <TOut>() where TOut : BaseBo, new()
        {
            var boResult = new TOut();

            SimplePropertyMapper.Map(this, boResult);
            return(boResult);
        }
コード例 #2
0
        public virtual T ToBusinessObject <T>() where T : class, new()
        {
            var businessObject = new T();

            SimplePropertyMapper.Map(this, businessObject);

            return(businessObject);
        }
コード例 #3
0
ファイル: BaseBo.cs プロジェクト: fenzy/dev-marketplace
        public TEntity ToEntity <TEntity>() where TEntity : class, new()
        {
            var entity = new TEntity();

            SimplePropertyMapper.Map(this, entity);

            return(entity);
        }
コード例 #4
0
        public void CopyPropertiesIfNameTypeAndValueTypeMatches()
        {
            //Arrange
            var source = new SomeSource
            {
                SamePropNameNotPrimitiveValueType = (decimal)1.2
            };
            var target = new SomeTarget();

            //Act
            SimplePropertyMapper.Map(source, target);

            //Assert
            Assert.AreEqual(source.SamePropNameNotPrimitiveValueType, target.SamePropNameNotPrimitiveValueType);
        }
コード例 #5
0
        public void DoNotCopyPropertiesIfNamesMismatch()
        {
            //Arrange
            var source = new SomeSource
            {
                SomeProp1 = "Test String"
            };

            var target = new SomeTarget();

            //Act
            SimplePropertyMapper.Map(source, target);

            //Assert
            Assert.AreNotEqual(source.SomeProp1, target.DbProp1);
        }
コード例 #6
0
        public void DoNotCopyPropertiesIfTypesAreNotPrimitiveOrInTheAllowedTypesList()
        {
            //Arrange
            var source = new SomeSource
            {
                SomeComplexType = (object)("TEST complex type")
            };

            var target = new SomeTarget();

            //Act
            SimplePropertyMapper.Map(source, target);

            //Assert
            Assert.AreNotEqual(source.SomeComplexType, target.SomeComplexType);
        }
コード例 #7
0
        public void DoNotCopyPropertiesIfTypesMismatch()
        {
            //Arrange
            var source = new SomeSource
            {
                SameNameDifferentType = "Test String"
            };

            var target = new SomeTarget();

            //Act
            SimplePropertyMapper.Map(source, target);

            //Assert
            Assert.AreNotEqual(source.SameNameDifferentType, target.SameNameDifferentType);
        }
コード例 #8
0
 public OrganizationViewModel(CompanyBo organization)
     : this()
 {
     SimplePropertyMapper.Map(organization, this);
 }