Tom
Global key events listener (when app window is minimalised or out of focus)
Hi! I'm making an Avalonia UI app and I want to listen to keyboard events even when app window is minimalised or I'm doing smth else in other app. Do you know a "good" way to do that? As far as I know it's not possible to do it through Avalonia itself and additional library is needed. I looked on NuGet, but those I found were not really pupular.
4 replies
✅ Methods (with bodies) in interfaces
Hi!
C# allows interfaces to contain methods already with some implementation (i.e. with body).
As I can easily think about taking advantage of this, but doesn't it deny the main reason interfaces exists - i.e. to abstract things?
If it were your decision whould you use this functionality in your project or stick only to other options (like putting logic inside abstract classes, using services, etc.)?
13 replies
✅ Predicates
Have you ever "add" more than one function to predicate definition:
e.g.
Predicate<T> p = func1;
and then p += func2;
If so in what circumstances?
From my limited experience it does not make much sense, however compiler has nothing against that 😉 Maybe just because Predicate is based on delegate...8 replies
✅ Design of events
Hi!
I have a question about utilization of events. Don't know many real life production examples by myself, but counting on your experience 😉
I've noticed that EventHandler delegate takes two parameters: object sender and EventArgs or other defined type. That means that in subscribers we can't be sure what is the sender and what are its properties/methods. So what's the main purpose (by design) of this "sender" parameter, shall it be used to check what type it is and take actions based on that? I am aware that I can create my own type of event instead of using EventHandler, but anyway I'm curious about the real life usage of the sender object.
35 replies