包装类 [英] Wrapper classes

查看:47
本文介绍了包装类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个IList< T>在执行普通List< T>上的实际调用之前,它将使用ReaderWriterLock包装每个调用,这是线程安全的实现。然而问题是,在这种情况下,静态验证器无法看到.Count始终与原始.Count值相同,因此我遇到问题。

这是一个已知问题?如果是这样,什么时候会被解决?

问候,

Matthijs ter Woord

Hi,

I'm trying to create an IList<T> implementation which is threadsafe, in that it will wrap each call with a ReaderWriterLock, before doing the actual call on a normal List<T>. Problem however is that in this case, the static verifier is not able to see that .Count is always same value as the original .Count, and therefore i'm getting problems.

Is this a known problem? If so, when it'll be solved?

Regards,

Matthijs ter Woord

推荐答案

你有在Count属性getter上添加一个更强大的Ensures,它将它与底层Count相关联。希望能有所帮助。
You have to add a stronger Ensures on your Count property getter that relates it to the underlying Count. That hopefully helps.


这篇关于包装类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆