public async Task Set(DGObjects objs) { List <DGObject> dGObjects = await RepositoryForClient.RetrieveObjs(objs); string domain = objs.parent.name; string objtype = objs.definition.Type; //获取对应属性数据 iS3Property property = new iS3Property(); Type objType = iS3Property.GetType(objs.parent.name, objs.definition.Type); Type _t = property.GetType(); MethodInfo mi = _t.GetMethod("Convert").MakeGenericMethod(objType); DGObjectsHolder.ItemsSource = mi.Invoke(property, new object[] { dGObjects }) as IEnumerable; }
private void Button_Click(object sender, RoutedEventArgs e) { List <PropertyDef> propertyDefs = new List <PropertyDef>(); PropertyDef def = JsonConvert.DeserializeObject <PropertyDef>(JsonConvert.SerializeObject((sender as Button).DataContext)); Type objType = iS3Property.GetType(_domain, def.type.Name); if (objType != null) { iS3Property iS3Property = new iS3Property(); Type _t = iS3Property.GetType(); MethodInfo mi = _t.GetMethod("GetProperty").MakeGenericMethod(objType); propertyDefs = mi.Invoke(iS3Property, new object[] { Activator.CreateInstance(objType) }) as List <PropertyDef>; CommonPropertyWin commonPropertyWin = new CommonPropertyWin(_domain, _objType); commonPropertyWin.Title = (sender as MenuItem).Tag.ToString(); commonPropertyWin.Show(); } }