c# - XamlWriter.Save foreach 对象中的属性
问题描述
我正在做这样的事情:
private List<ICards> selectedCards = new List<ICards>();
foreach (var card in selectedCards)
foreach (var item in card.GetType().GetProperties())
{
string save = XamlWriter.Save(item);
tw.WriteLine(item.GetValue(card, null));
}
tw.Close();
}
ICards是接口的地方
interface ICards
{
string CardType { get; set; }
string Name { get; set; }
int AddressIndex { get; set; }
}
和例子:
class CardBizonOc : ICards
{
public string CardType { get; set; }
public string Name { get; set; }
public int AddressIndex { get; set; }
public string Entry1 { get; set; }
public string Entry2 { get; set; }
}
此刻string save = XamlWriter.Save(item);
抛出:You cannot serialize the type "System.Reflection.RuntimePropertyInfo".
我应该如何将物体拉出来card
才能做到?
解决方案
推荐阅读
- javascript - 在 Vue.js 的列表中隐藏特定元素
- python - Tensorflow 似乎在 CPU 上运行,尽管使用的是 GPU 内存
- python - 如何在 django admin 中创建“仅创建”不可编辑字段
- java - 即使实体中没有任何变化,也更新对 DB 的请求
- android - 如何处理片段和视图分页器之间的回栈?
- python - 无法将 cv2 导入 Docker [python]
- swift - 当 coreData 值发生变化时,如何更新我的其他视图?
- core-data - 如何在核心数据结果上运行一个简单的函数
- python - 如何在 Raspberry Pi 上从 Apache 运行 Python 脚本?
- database - 用于电子商务应用程序时如何保持 mongoDB 的一致性?