public async Task MyMapper_Object_AsyncExtension_Test()
        {
            var dateOfBirth = DateTime.Now;

            Details1 details1 = new Details1 {
                DOB = dateOfBirth, IsDisabled = false
            };

            //Specify MyMapper mapping rules - turn off automapping
            //Details1 and Details3 have different property names - specify mapping rules

            Details3 details3 = await new Mapper().MapAsync(details1);

            Assert.IsTrue(details3.DateOfBirth == dateOfBirth);
            Assert.IsTrue(details3.IsHandicapped == false);

            Fund1 fund1 = new Fund1
            {
                FundId  = 1,
                Name    = "Sun",
                Address = new Address1
                {
                    StreetNo = "10",
                    State    = new State1 {
                        Name = "New York", Abbr = "NY"
                    },
                    Country = new Country1 {
                        Name = "United States of America", Abbr = "USA"
                    }
                }
                ,
                BankIdNo = 1000
            };

            //Using automapping (for classes with the same property names).
            //Fund1 and Fund3 (and their contained classes) have the same property names

            Fund3 fund3 = await new Mapper().MapAsync(fund1);

            Assert.IsTrue(fund3.FundId == fund1.FundId);
            Assert.IsTrue(fund3.Name == fund1.Name);
            Assert.IsTrue(fund3.Address.StreetNo == fund1.Address.StreetNo);
            Assert.IsTrue(fund3.Address.State.Name == fund1.Address.State.Name);
            Assert.IsTrue(fund3.Address.State.Abbr == fund1.Address.State.Abbr);
            Assert.IsTrue(fund3.Address.Country.Name == fund1.Address.Country.Name);
            Assert.IsTrue(fund3.Address.Country.Abbr == fund1.Address.Country.Abbr);
            Assert.IsTrue(fund3.BankIdNo == fund1.BankIdNo);
        }
Beispiel #2
0
 //Same as above - using Async
 public async Task <Fund3> MapAsync(Fund1 fund1)
 {
     return(await fund1.MapAsync <Fund1, Fund3>());
 }
Beispiel #3
0
 //Using automapping (for classes with the same property names).
 //Fund1 and Fund3 (and their contained classes) have the same property names
 public Fund3 Map(Fund1 fund1)
 {
     return(fund1.Map <Fund1, Fund3>());
 }
 public Fund3 Map(Fund1 fund1)
 {
     //Both Classes (Fund1 & Fund3) have properties by the same name. Auto mapping (reflective) can be used.
     return Mapper<Fund1, Fund3>.Map(fund1).Exec();
 }
Beispiel #5
0
 public async Task <Fund3> MapAsync(Fund1 fund1)
 {
     //Both Classes (Fund1 & Fund3) have properties by the same name
     return(await Mapper <Fund1, Fund3> .MapAsync(fund1).Exec());
 }
Beispiel #6
0
 public Fund3 Map(Fund1 fund1)
 {
     //Both Classes (Fund1 & Fund3) have properties by the same name
     return(Mapper <Fund1, Fund3> .Exec <EntityConverter <Fund1, Fund3> >(fund1));
 }