我有几个类定义DebuggerDisplay属性。我想知道是否有一种方法来定义基于另一个一一DebuggerDisplay属性。如果我有以下类:
I have several classes defining the DebuggerDisplay attribute. I want to know if there is a way to define one DebuggerDisplay attribute based on another one. If I have the following classes:
[DebuggerDisplay ("Text = {Text}")] class A { public string Text {get;set;} } [DebuggerDisplay ("Property = {Property}")] class B { public A Property {get; set;} }
我想对A类,因为它是在A级DebuggerDisplay属性定义的B实例看。那相反,我得到了A类的ToString()方法到调试器,一边欣赏B类对象。
I would like to see on instances of B the A class as it is defined on the class A DebuggerDisplay attribute. Instead of that I'm getting the class A ToString() method onto the debugger while viewing class B objects.
推荐答案不知道我是否正确地理解你的问题,但尝试:
Not sure if I understood your problem correctly but try:
[DebuggerDisplay("Property = {Property.Text}")] public class B { public A Property { get; set; } }这将显示A的Text属性。
This will Display the A's Text property.
如果您需要更复杂的控制,你可以使用 DebuggerTypeProxyAttribute
If you need more complex control you can use DebuggerTypeProxyAttribute
更多推荐
在复杂类型链接DebuggerDisplay
发布评论