|
It should now be possible (though it's not implemented) to use lambda expressions in static initializers that get the compiler to do work.
Basically, you should be able to declare delegates as fields on classes like System.Attribute.
Then you could do something like
[CrossCut(Before:(callContext)=> { Debug.WriteLine("Member "+callContext.Name+" calling on employee"); }), After:(callContext)=>{Debug.WriteLine("Member "+callContext.Name+" called on employee");})]
class EmployeeEntity {
public string Name {get; set; }
public string Title {get; set; }
public string Address {get; set; }
}
To add method logging to all your calls. Just as an example.
There is no reason, that with Roslyn this can't be done. The only reason I can think of why it *shouldn't* be done is it could potentially allow DoS attacks against Roslyn's compiler service by hanging the compiler running one of the lambdas in an infinite loop, but Roslyn also *should* be able to handle that.
Edit: I know you can use the .NET COM+ wrapper to do this with "context objects" or whatever they're called, but that's COM+ and it's ugly
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
The Lounge[^]. It seems google likes to celebrate everything ...
... and so in the spirit of inclusivity I wish everyone a Merry Christmas and a Happy New Year. And if you do not celebrate Christmas, then I hope this is a good week for you. And if your calendar does not begin a New Year next week, then I trust next week will also be good for you.
|
|
|
|
|
Thanks, and likewise to you and yours!
|
|
|
|
|
It's much easier to enjoy the favor of both friend and foe, and not give a damn who's who. -- Lon Milo DuQuette
|
|
|
|
|
Merry Christmas to you as well, hope the new year is good to you.
They call me different but the truth is they're all the same!
JaxCoder.com
|
|
|
|
|
From the title I was expecting a post about your new leg braces.
Merry Christmas to all!
I, for one, like Roman Numerals.
|
|
|
|
|
Right back at you!
Also, Peace on Earth and Good Will to Men....
If only....
|
|
|
|
|
And women. And non-binary gendered individuals.
/ravi
|
|
|
|
|
Of Couse! And all living beings.
Even Dogs with Red Eyebrows! (Never trust a dog with Red Eyebrows - Terry Pratchett)
|
|
|
|
|
Slow Eddie wrote: And all living beings. What about pets and plants? And insects?
/ravi
|
|
|
|
|
Richard MacCutchan wrote: I stand corrected Oh, are you using a cane? Corrective shoes?
/ravi
|
|
|
|
|
First, get a leg up on it, then chill, baby: [^]
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
|
|
|
|
|
Man, that's really gonna hurt when you step on it.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Super cool!
They call me different but the truth is they're all the same!
JaxCoder.com
|
|
|
|
|
One of my Christmas gift, my first successful Github pull request to someone I don't know at all!
Commits · tiagorosendo/SqlBulkTools · GitHub (I am superlloyd!)
And also... 2nd Christmas gift, after 9 year of trying and failing I might have made the diet breakthrough I need to stop chronic pain and sickness, yeeha! (I am proclaiming results a bit early though, let's say I am hopeful with some mildly good reason)
|
|
|
|
|
Super Lloyd wrote: chronic pain and sickness I went through that some years ago, but was fortunate to find a partial cure. So nowadays it is discomfort rather than pain.
|
|
|
|
|
Damn, good luck to you too... This can sucks and medicine doesn't help much so far...
|
|
|
|
|
After years of pain and sickness, and then abdominal surgery, it turned out that a week's course of antibiotics cleaned out the bug. I suspect the surgery left me with only a partially functioning digestive system, so better now but not perfect.
|
|
|
|
|
Quote: I need to stop chronic pain Ah! Yes! I know that well. But in my case it is a by-product of advancing age. And there is no cure for that. However, I am glad that you seem to be doing well!
|
|
|
|
|
Ha yeah.. there is no cure for that... But thanks hey!
|
|
|
|
|
It's hell getting old …!
I know from personal experience.
It does, however, beat the alternative.
|
|
|
|
|
Yup!
|
|
|
|
|
It's much easier to enjoy the favor of both friend and foe, and not give a damn who's who. -- Lon Milo DuQuette
|
|
|
|
|
Super Lloyd wrote: I might have made the diet breakthrough I need to stop chronic pain and sickness, yeeha!
Oooh, I hope so.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
Thanks hey!
|
|
|
|