【发布时间】:2010-11-13 00:15:10
【问题描述】:
请在 c# 中有一个类,其主要功能是将类型和对象作为字典返回服务。
是否可以在前端将对象发送到 WCF 服务。
即使用反射从 types.ToString() 中获取对象的类型,并使用类型转换对象。
注意返回字典的类和我的前端在不同的项目中,所以不同的命名空间:
Type repType = typeof(List <>).MakeGenericType(Type.GetType(EntityandTypes[entity]));
object rep = Assembly.GetAssembly(repType).CreateInstance(repType.FullName);
grdResult.ItemsSource =
e.Result.ToList().Cast<typeof(Type.GetType(EntityandTypes[entity]))>();
注意:EntityandTypes 是一个包含 Object 及其类型的字典。
【问题讨论】: