【发布时间】:2018-08-09 02:51:00
【问题描述】:
我有一个名为 Elements 的 json 数据,它有一个属性字段。现在我想将这些属性添加到一个类中,并且该类需要动态生成。
这是我的 json 数据的结构。
"Elements": [
{
"$type": "PCL.DatePicker, PCL",
"Type": "DatePicker",
"SelectedDate": "2017-02-23T00:00:00",
"LabelText": "Date:",
"Property": "Date1",
"Visibile": true
},
{
"$type": "PCL.FormEntryField, PCL",
"Type": "Entry",
"Text": "",
"LabelText": "Full Name:",
"Property": "FullName",
"Visibile": true
},
{
"$type": "PCL.Picker, PCL",
"Type": "Picker",
"DefaultIndex": 0,
"Values": [ "English", "Hindi", "French", "Chinese", "Arabi" ],
"LabelText": "Language",
"Property": "Language",
"Visibile": true
},
{
"$type": "PCL.FormSwitch, PCL",
"Type": "Switch",
"DefaultValue": true,
"Value": false,
"Text": null,
"Property": "Happy",
"LabelText": "Are You Happy?",
"Visibile": true
},
{
"$type": "PCL.TimePicker, PCL",
"Type": "TimePicker",
"SelectedTime": "12:30:00",
"LabelText": "Time:",
"Property": "TIme",
"Visibile": true
}
]
可以这样做吗?
【问题讨论】:
-
那么您已经有一些 C# 代码已经在运行,并且您想在运行时创建一个新类以放入单独的 DLL 中?
-
这对我来说似乎有点 X Y'ish
-
@MichaelRandall - 我同意。我确实在运行时生成并使用了类,但从未永久存储它们。由于先前决定的限制无法改变,因此有充分的理由这样做,但我仍然不想。知道这里需要解决什么实际问题将非常有用,因为似乎不太可能将一个经过充分分析和研究以得出需要该解决方案的结论的问题留下这样的问题。
-
@MichaelRandall 没有证据不是没有证据
-
@MickyD 这是美国东部标准时间下午 3:31 的深刻声明,但是你得到了积分
标签: c# visual-studio-2017