我希望我的班级以这种方式出现:
但是显示为上面的liveSelect
。这是我班的宣言:
public class LiveSelect<TSource, TResult> : ReadOnlyBindingList<TResult>, IList, ICollection, IEnumerable
{
//...
}
ReadOnlyBindingList
实施IBindingList
。我错过了什么?
更新:根据280Z28的回答,我在哪里解决了这个问题:
internal sealed class CollectionDebuggerView<T>
{
readonly ICollection<T> c;
public CollectionDebuggerView(ICollection<T> col)
{
this.c = col;
}
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
public T[] Items
{
get { return c.ToArray(); }
}
}
然后,让我的ReadOnlyBindingList<TResult>
类实现ICollection<T>
并添加一些属性,使它看起来像这样:
[DebuggerDisplay("Count={Count}")]
[DebuggerTypeProxy(typeof(CollectionDebuggerView<>))]
public abstract class ReadOnlyBindingList<TResult> : IBindingList, IList, IEnumerable, IEnumerable<TResult>, ICollection, ICollection<TResult>
{
//...
}
请注意,CollectionDebuggerView
需要接受ReadOnlyBindingList
实现的构造函数(例如ICollection<T>
)。
答案 0 :(得分:1)
基于another Stack Overflow Q/A,似乎我最初建议在索引器属性上尝试[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
属性可能不起作用。
您需要将DebuggerTypeProxyAttribute
添加到您的类中,并配置类型代理以扩展索引器的成员。
例如,请查看Mono中的implementation of List<T>
,其中CollectionDebuggerView<T>
debugger type proxy就是出于此目的。
答案 1 :(得分:0)
如果您从Results View
liveSelect
你应该从someList
答案 2 :(得分:0)
我认为您需要一个integer
来获取{{1}}。