【发布时间】:2023-12-25 06:09:01
【问题描述】:
假设我有 3 个 A、B 和 C 类。
所有类都属于不同的程序集,例如:
A 类属于程序集 ASSEMBLY_A, B 类属于程序集 ASSEMBLY_B, C类属于程序集ASSEMBLY_C
另外,ASSEMBLY_A 引用了 ASSEMBLY_B, ASSEMBLY_C 引用 ASSEMBLY_B, ASSEMBLY_B 不引用任何程序集 A/B。
即:ASSEMBLY_A ------> ASSEMBLY_B
A 类有一个 IList 自定义集合 C 类有一个 IList 自定义集合
class DataTypeA
{
propertyA1 -> string type
propertyA2 -> int type
propertyA3 -> bool type
}
class DataTypeC
{
propertyC1 -> string type
propertyC2 -> int type
propertyC3 -> bool type
}
注意propertyA1等价于propertyC1,propertyA2等价于propertyC2,propertyA3等价于propertyC3。
所以我想在 ASSEMBLY_B 中有一个辅助方法来执行以下操作:
1) 将 A 类的 IList 转换为 C 类的 IList。 2) 将 Class C 的 IList 转换为 Class A 的 IList。
如何做到这一点?
【问题讨论】:
-
你能不能简单地在 ASSEMBLY_B 中创建类并去掉 DataTypeA 和 DataTypeC 来代替 DataTypeB 如果它们和你说的一样等价吗?