当会话被包装为属性时,如何直接保护访问会话?
我将每个 ASP.NET 会话变量包装在一个带有 getter 和 getter 的属性中。二传手。有没有办法让访问会话变量在编译期间直接产生错误或警告?
我想“强制”开发人员(包括我自己)通过包装器属性而不是直接访问会话变量。
I have each ASP.NET session variable wrapped in a property with a getter & a setter. Is there a way to make accessing a session variable directly produce an error or a warning during compilation?
I want to 'force' developers, including myself, to access session variables through the wrapper properties instead of directly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用 Resharper,则可以将模式添加到其 模式目录,可以将某些模式识别为错误。不仅如此,您还可以建议使用属性的替换文本。
我相信在你的情况下,搜索模式只需要类似于:
If you're using Resharper, you could add a pattern to its pattern catalog, which can recognize certain patterns as an error. Not only that, but you can also suggest a replacement text that would suggest using a property.
I believe that in your case the search pattern would only need to be something like: