public async void OnNavigatedTo(INavigationParameters parameters) { UserPlantUnitService userPlantUnitService = new UserPlantUnitService(); var foo = await userPlantUnitService .GetAsync(ConstantsHelper.Token, ConstantsHelper.AppVersion); // Type A Type B UserPlantUnit = mapper.Map <UserPlantUnit>(foo); #region 若不使用 AutoMapper,則需要使用底下的這麼多程式碼,才能完成相關作業 //UserPlantUnit.result = foo.result; //UserPlantUnit.data = new System.Collections.ObjectModel.ObservableCollection<UserPlantUnitDatum>(); //foreach (var item in foo.data) //{ // UserPlantUnitDatum userPlantUnitDatum = new UserPlantUnitDatum(); // userPlantUnitDatum.CHINESE_PLANT_NAME = item.CHINESE_PLANT_NAME; // userPlantUnitDatum.PLANT = item.PLANT; // userPlantUnitDatum.PLANT_UNITS = new System.Collections.ObjectModel.ObservableCollection<PLANTUNIT>(); // foreach (var item2 in item.PLANT_UNITS) // { // PLANTUNIT pLANTUNIT = new PLANTUNIT(); // pLANTUNIT.CHINESE_UNIT_NAME = item2.CHINESE_UNIT_NAME; // pLANTUNIT.GROUP_ID = item2.GROUP_ID; // pLANTUNIT.PLANT_UNIT = item2.PLANT_UNIT; // userPlantUnitDatum.PLANT_UNITS.Add(pLANTUNIT); // } // UserPlantUnit.data.Add(userPlantUnitDatum); //} #endregion }
public async void OnNavigatedTo(INavigationParameters parameters) { if (parameters.GetNavigationMode() == NavigationMode.Back) { return; } UserPlantUnitService service = new UserPlantUnitService(); var foo = await service.GetAsync(ConstantsHelper.Token, ConstantsHelper.AppVersion); UserPlantUnit = mapper.Map <UserPlantUnit>(foo); }
static async Task Main(string[] args) { UserPlantUnitService service = new UserPlantUnitService(); var foo = await service.GetAsync(ConstantsHelper.Token, ConstantsHelper.AppVersion); PlantUnitSampleService service2 = new PlantUnitSampleService(); var bar = await service2.GetAsync(ConstantsHelper.Token, ConstantsHelper.AppVersion, "CFP", "CFP-SEMI"); SampleResultService service3 = new SampleResultService(); var foobar = await service3.GetAsync(ConstantsHelper.Token, ConstantsHelper.AppVersion , " 9244151"); Console.WriteLine("Hello World!"); Console.WriteLine("Press any key for continuing..."); Console.ReadKey(); }