Replies: 3 comments
-
好吧,我看到了 OnFlux 函数可以被重写 |
Beta Was this translation helpful? Give feedback.
-
Hi @Bian-Sh You are right, making it private prevents the use of these, for my part I was trying to force the thought of using OnFlux to unify the subscriptions in one place and, at the same time, have control of the order, since the basic approach is to do + = in OnEnable and -= in OnDisable I have created a method that unifies it in a single line, that way you reduce the number of lines of code. But I understand that there will also be interest in the use of OnEnable and OnDisable, I can assign them as virtual, but there may be the case that they forget to use base.OnEnable or base.OnSubscription(true), Maybe that is why I leave them private. I would like to know your opinion about it :) |
Beta Was this translation helpful? Give feedback.
-
about this "So I am thinking, can we use Mono Cecil and OOP concepts to quietly insert OnSubscription(true); and OnSubscription(false); during dll compilation?" i'll check it to see if theres a way to do it like an alternative Option |
Beta Was this translation helpful? Give feedback.
-
我看到独占了 OnEnable 和 Ondisable 这两个生命周期,这使得用户没法使用这连个函数了。
当然,如果使用虚函数,允许 Override ,这样如果用户忘记在 Override 的函数中调用 base.OnEnable, 或者调用时机不对,也会导致事件的监听异常。
所以我在想,可不可以使用 Mono Cecil 使用 OOP 思想在编译 dll 时悄悄的插入 OnSubscription(true); 和 OnSubscription(false);
当然这样的话,插件本身就多了一个对 MonoCecil 的依赖。
I noticed that OnEnable and OnDisable are both monopolized, so users cannot use these two functions.
Of course, if virtual functions are used to allow overriding, it may also cause abnormal event listening if the user forgets to call base.OnEnable in the overridden function or calls it at the wrong time.
So I am thinking, can we use Mono Cecil and OOP concepts to quietly insert OnSubscription(true); and OnSubscription(false); during dll compilation?
Of course, this way the plugin itself will have an additional dependency on MonoCecil.
Beta Was this translation helpful? Give feedback.
All reactions