如何以递归方式将字典转换为类和子类?这些是我的课程:
public class UiItem
{
public string id { get; set; }
public string text { get; set; }
public Rect rect { get; set; }
}
public class Rect
{
public int height { get; set; }
public int width { get; set; }
public int y { get; set; }
public int x { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我写了这个,但我不知道如何Rect在类中创建对象UiItem:
public static T GetObject<T>(this Dictionary<string, object> dict)
{
Type type = typeof(T);
var obj = …Run Code Online (Sandbox Code Playgroud)