public PropertyBaseVM GetViewModel(string objectIdStr, string typeFullname, string bindingPath) { var obj = dataService.GetObject(objectIdStr, typeFullname, bindingPath); if (obj is IEnumerable collection) { return(gridService.GetGridViewModelForObject(collection.Cast <object>().AsQueryable(), objectIdStr, typeFullname, bindingPath, new CollectionViewModelParameters())); } else { return(propretyGridService.GetPropertyGrid(objectIdStr, typeFullname, bindingPath)); } }
public PropertyGridVM GetPropertyGrid(string objectId, string typeFullname, string bindingPath) { var obj = dataService.GetObject(objectId, typeFullname, bindingPath); var pg = new PropertyGridVM(); if (obj is ObjectXmlWrapper wrapper) { var complex = Serializer.DeserializeXml(wrapper.Xml); createPropertyGridFromXml(complex, pg); } else if (obj is IEnumerable collection) { //mamy kolekcję var gridVM = gridService.GetGridViewModelForObject(collection?.Cast <object>().AsQueryable(), objectId, typeFullname, bindingPath, new CollectionViewModelParameters()); gridVM.BindingPath = bindingPath; gridVM.PropertyValue = helper.GetValue(collection); gridVM.IsStatic = false; gridVM.MainObjectId = objectId; gridVM.MainObjectTypeFullname = typeFullname; //gridVM.EditUrl = helper.GetEditUrlForCollection(propertyType, "", propertyType);//TODO pg.Properties.Add(gridVM); } else { pg.PropertyValue = obj?.ToString(); pg.MainObjectId = objectId; pg.MainObjectTypeFullname = typeFullname; pg.IsStatic = false; //mamy zwykły obiekt - przechodzimy refleksjami createPropertyGridFromObject_internal(obj, pg, 1, bindingPath); pg.ListUrl = helper.GetEditUrlForCollection(obj.GetType(), null, null); } return(pg); }