//public string ConversionJson(Gis_Data<Gis_Dk> gisData) //{ // if (string.IsNullOrEmpty(JsonStr)) return string.Empty; // Gis_Data<Gis_Dk> gisData = JsonConvert.DeserializeObject<Gis_Data<Gis_Dk>>(JsonStr); // if (gisData.DkList.Count == 0) return string.Empty; ////手工录入方式 // IGBXM<GBDK> gisEntity = this.Conversion(gisData); // return JsonConvert.SerializeObject(gisEntity); //} /// <summary> /// Mis对象转换成Gis对象 /// </summary> /// <param name="SourceXM"></param> /// <returns></returns> public IGBXM<GBDK> Conversion(IGBXM<Gis_Dk> SourceXM) { IGBXM<GBDK> result = new GBXM<GBDK>(); foreach (PropertyInfo pi in typeof(IGBXM<GBDK>).GetProperties()) { switch (pi.Name.ToLower()) { case "dklist": List<Gis_Dk> dklist = (List<Gis_Dk>)SourceXM.GetType().GetProperty(pi.Name.ToString()).GetValue(SourceXM, null); List<GBDK> newdklist = new List<GBDK>(); foreach (Gis_Dk d in dklist) { newdklist.Add(ConversionDK(d)); } pi.SetValue(result, newdklist, null); break; default: pi.SetValue(result, SourceXM.GetType().GetProperty(pi.Name.ToString()).GetValue(SourceXM, null), null); break; } } return result; }
//public string ConversionJson(Gis_Data<Gis_Dk> gisData) //{ // if (string.IsNullOrEmpty(JsonStr)) return string.Empty; // Gis_Data<Gis_Dk> gisData = JsonConvert.DeserializeObject<Gis_Data<Gis_Dk>>(JsonStr); // if (gisData.DkList.Count == 0) return string.Empty; ////手工录入方式 // IGBXM<GBDK> gisEntity = this.Conversion(gisData); // return JsonConvert.SerializeObject(gisEntity); //} /// <summary> /// Mis对象转换成Gis对象 /// </summary> /// <param name="SourceXM"></param> /// <returns></returns> public IGBXM <GBDK> Conversion(IGBXM <Gis_Dk> SourceXM) { IGBXM <GBDK> result = new GBXM <GBDK>(); foreach (PropertyInfo pi in typeof(IGBXM <GBDK>).GetProperties()) { switch (pi.Name.ToLower()) { case "dklist": List <Gis_Dk> dklist = (List <Gis_Dk>)SourceXM.GetType().GetProperty(pi.Name.ToString()).GetValue(SourceXM, null); List <GBDK> newdklist = new List <GBDK>(); foreach (Gis_Dk d in dklist) { newdklist.Add(ConversionDK(d)); } pi.SetValue(result, newdklist, null); break; default: pi.SetValue(result, SourceXM.GetType().GetProperty(pi.Name.ToString()).GetValue(SourceXM, null), null); break; } } return(result); }