System.Collections.ObjectModel.ObservableCollection 仅在 Monotouch 中部分实现?
我正在使用 Silverlight 3 存根来使用 WCF 服务,我需要的一个参数是 System.Collections.ObjectModel.ObservableCollection。 但是,以下代码抛出 NotImplementedException
:
ItemType[] aItemTypes = ...;
ObservableCollection<ItemType> aTypes = null;
if(aItemTypes != null)
{
aTypes = new ObservableCollection<ItemType> (aItemTypes);
}
如果我使用 foreach 循环手动添加所有条目,而不是使用采用可枚举的构造函数,则它可以工作。构造函数丢失或者只是被遗忘是有原因的吗?
I'm consuming WCF services using the Silverlight 3 stubs and one parameter I need is a System.Collections.ObjectModel.ObservableCollection
.
However the following code is throwing a NotImplementedException
:
ItemType[] aItemTypes = ...;
ObservableCollection<ItemType> aTypes = null;
if(aItemTypes != null)
{
aTypes = new ObservableCollection<ItemType> (aItemTypes);
}
If I use a foreach loop to add all entries manually instead of using the constructor that takes an enumerable, it works. Is there a reason why the constructor is missing or was it just forgotten?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当有人实现一个类型但不需要其中的所有内容时,有时会在 Mono 基类库源代码上发生这种情况。在这种情况下,最好为缺失的代码添加存根,因为:
MissingMethodException
,NotImplementedException
更容易诊断;NotImplementedException。
在这种特定情况下,我怀疑需要进行更多测试来查看正在复制的项目是否需要触发事件(添加它们时)。
好消息是这个方法在Mono的GIT master中实现了。我会考虑将其反向移植到 mono-2-10 分支中,以便 MonoTouch 在未来的版本中获得它。
This sometimes occurs on Mono base class library source code when someone implement a type but does not need everything inside it. In such cases it's better to add stubs for the missing code since this:
MissingMethodException
at runtime, aNotImplementedException
is easier to diagnose;NotImplementedException
on existing .NET code.In this specific case I suspect that more tests were needed to see if the items being copied needed to trigger events (whgen adding them) or not.
The good news is that this method is implemented in Mono's GIT master. I'll look into backporting this into mono-2-10 branch so MonoTouch will get it in future releases.