public async Task GetData(Tree tree) { DGObjectRepository repository = DGObjectRepository.Instance( "SHML12", tree.RefDomainName, tree.Name); List <DGObject> objList = await repository.GetAllAsync(); //DGObject objHelper = // ObjectHelper.CreateDGObjectFromSubclassName(tree.Name); //Type t = objHelper.GetType(); ////C# //Type ct = typeof(List<int>); //Type gt = ct.GetGenericTypeDefinition(); ////Make another constructed type ////The List<string> in this case //Type ct2 = gt.MakeGenericType(t); //object list= Activator.CreateInstance(ct2, true);//根据类型创建实例 //BindingFlags flag = BindingFlags.Instance | BindingFlags.Public; //MethodInfo methodinfo = ct2.GetMethod("AddRange", flag); //foreach (DGObject obj in objList) //{ // methodinfo.Invoke(list, new object[] { }); //} MyDataGrid.DGObjectDataGrid.ItemsSource = objList; nowTree = tree; }
async Task FindDetail() { List <DGObject> addedObjs = new List <DGObject>(); List <DGObject> removedObjs = new List <DGObject>(); DGObject selectOne = MyDataGrid.DGObjectDataGrid.SelectedItem as DGObject; DGObjectRepository repository = DGObjectRepository.Instance( "SHML12", nowTree.RefDomainName, nowTree.Name); DGObject obj = await repository.Retrieve(selectOne.id); addedObjs.Add(obj); if (lastOne != null) { removedObjs.Add(lastOne); } lastOne = selectOne; string layerName = "Default"; //DataView dataView = MyDataGrid.DGObjectDataGrid.ItemsSource // as DataView; //if (dataView == null) // return; //DataTable dataTable = dataView.Table; //DataSet dataSet = dataTable.DataSet; //if (dataSet == null) // return; //if (!_prj.dataSetIndex.ContainsKey(dataSet)) // return; //DGObjects objs = _prj.dataSetIndex[dataSet]; //string layerName = objs.definition.GISLayerName; //IList addedItems = e.AddedItems; //IList removedItems = e.RemovedItems; //foreach (DataRowView drv in addedItems) //{ // DataRow dr = drv.Row; // if (objs.rowView2Obj.ContainsKey(dr)) // { // DGObject obj = objs.rowView2Obj[dr]; // addedObjs.Add(obj); // } //} //foreach (DataRowView drv in removedItems) //{ // DataRow dr = drv.Row; // if (objs.rowView2Obj.ContainsKey(dr)) // { // DGObject obj = objs.rowView2Obj[dr]; // removedObjs.Add(obj); // } //} if (objSelectionChangedTrigger != null) { Dictionary <string, IEnumerable <DGObject> > addedObjsDict = null; Dictionary <string, IEnumerable <DGObject> > removedObjsDict = null; if (addedObjs.Count > 0) { addedObjsDict = new Dictionary <string, IEnumerable <DGObject> >(); addedObjsDict[layerName] = addedObjs; } if (removedObjs.Count > 0) { removedObjsDict = new Dictionary <string, IEnumerable <DGObject> >(); removedObjsDict[layerName] = removedObjs; } ObjSelectionChangedEventArgs args = new ObjSelectionChangedEventArgs(); args.addedObjs = addedObjsDict; args.removedObjs = removedObjsDict; objSelectionChangedListener(this, args); } }