使用反射将业务对象绑定到 ASP.NET 表单控件

发布于 2024-12-06 07:12:27 字数 206 浏览 5 评论 0原文

这看起来是一种非常有用的方法,可以简化 ASP.NET 控件与通用业务对象的数据绑定。我还没有在成熟的实时项目中使用它,所以

我不确定他们的性能指标有多准确。我突然想到我会在从 Page 对象派生的新类中实现这两个方法“BindControlsToObject”和“BindObjectToControls”,但无论您真正喜欢什么。

我如何才能准确地了解他们的表现?

This looks like a really useful way to simplify databinding ASP.NET controls to a generic business object. I've yet to use this in a fully fledged live project and so

I'm not sure how accurate their performance metrics are. Off the top of my head I think I would implement these two methods 'BindControlsToObject' and 'BindObjectToControls' in a new class derived from the Page object, but whatever takes your fancy really.

How I can accurate their performance?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清泪尽 2024-12-13 07:12:27

如果性能是您关心的问题之一,那么不要使用反射。至少不是在每个页面调用时,因此您可以考虑按需缓存或在应用程序启动时缓存。

您可以在不使用反射的情况下绑定到列表或对象,这将使您能够在标记中使用 Eval("..."),这是一种常用的模式,并且其他刚接触您的项目的程序员将提高工作效率。

除此之外,这样做是学习诸如自定义插件系统之类的反射的好方法(在您不能或不想使用 MEF 或 Unity 或类似的东西的情况下)。

If performance is one of your concerns, then do not use reflection. At least not at every page call, so you could think about caching on demand or at application start.

You could bind to a list or an object without using reflection and this would enable you to use Eval("...") in the markup, which is a commonly used pattern and other programmers new to your project would become faster productive.

Besides this, doing this is a great way to learn reflection for something like a custom plugin system ( in the cases you cannot or do not want to use MEF or Unity or something like this ).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文