Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用FastMember作为反射的替代方法。在源代码中,我看到有一个匿名类型支持的单元测试,但是当我尝试对匿名类型使用 TypeMember.CreateNew() 时,我得到了 NotSupportedException。他们不支持吗?
它们受支持但不支持TypeMember- 您应该使用ObjectAccessor如下方式:
TypeMember
ObjectAccessor
var obj = new {A = 123, B = "def"}; var accessor = ObjectAccessor.Create(obj); Assert.AreEqual(123, accessor["A"]);