EditorReuseAttribute 的真正用途是什么?

发布于 2024-07-22 06:23:36 字数 22 浏览 5 评论 0原文

我找不到使用此属性的任何想法?

I can't find any idea of the way to use this attribute?

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

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

发布评论

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

评论(3

眉黛浅 2024-07-29 06:23:36

MSDN表示确实是表示一个属性编辑器可以重复使用,而不需要每次都重新创建。

这是性能上的胜利,特别是如果您的编辑器需要在启动时做大量工作,而这是可以避免的。 除非您确实遇到性能问题,否则我不会担心。

MSDN indicates it is indeed to indicate that a property editor can be reused without needing to recreate each time.

This is a performance win, especially if your editor needs to do significant work on start up which can be avoided. Unless you are actually having performance issues then I wouldn't worry about it.

蒗幽 2024-07-29 06:23:36

想象一下您有这样的场景:

class Complex
{
   public OtherComplex1 Property1 { get; set; }
   public OtherComplex2 Property2 { get; set; }
   public OtherComplex2 Property3 { get; set; }
   .....
   public OtherComplexN PropertyN { get; set; }

}

您的每个属性都有自己的类型设计器,它显示一些属性等。

比如说,您有两个不同的 Complex 类实例 + 某个其他任意类的实例。

现在,当您像这样在对象之间切换时 - 复杂实例 1 -> 其他-> 复杂实例 2 - 一切都会正常工作,但如果你这样做:

复杂实例 1 -> 对于复杂实例 2,您会注意到属性没有被刷新。

这是属性网格的默认行为,它尝试优化数据刷新操作的数量。 除非您想烘焙大量逻辑以使设计人员保持更新,否则我建议将编辑器重用属性设置为 false 来标记您的复杂类型 - 在这种情况下,每当选择更改为不同的实例时,属性网格仍会刷新您的设计师。

imagine you have scenario like this:

class Complex
{
   public OtherComplex1 Property1 { get; set; }
   public OtherComplex2 Property2 { get; set; }
   public OtherComplex2 Property3 { get; set; }
   .....
   public OtherComplexN PropertyN { get; set; }

}

each of your properties has its own type designer, which displays some properties, etc.

say, you have two different instances of the Complex class + instance of some other arbitrary class.

now, when you toggle between your objects like this - complex instance 1 -> other -> complex instance 2 - everything will work fine, but if you do something like this:

complex instance 1 -> complex instance 2, you'd notice that properties are not beeing refreshed.

that is default behavior of property grid, which tries to optimize number of data refresh operations. unless you want to bake a lot of logic in order to keep your designers updated, i'd suggest marking your complexTypes with editor reuse attribute set to false - in this case, whenever selection changes to a different instance, property grid would still refresh your designers.

橪书 2024-07-29 06:23:36

如果您不知道它的作用,为什么需要使用它? 您当前是否有任何正在使用它的代码可以作为示例发布?

听起来它允许您定义属性的属性编辑器可以重复使用而无需重新启动。 我不太确定为什么这会有用。

If you don't know what it does, why do you need to use it? Do you have any code that is using it currently that you could post as an example?

It sounds like it allows you to define that a property editor for your property can be reused without restarting. I am not particularly sure why this would be useful.

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