I am using a library which measure metrics for running code. The usage of the library is something like this.
_Library.Wrap("AnyStringForMetrics", Func<T>);
So whatever I pass into the Func as a lambda will be measured and result of it will be returned.
At the moment, I have method where I want to measure this line where it tries to create or get a user with that id. (newlyCreated will be true if the user was created)
public User GetOrCreate(long id, out bool newlyCreated) {
// some random checks
return UserDatabase.GetOrCreate(id, out newlyCreated);
}
But now, if I try to wrap my code around
public User GetOrCreate(long id, out bool newlyCreated) {
// some random checks
return _Library.Wrap(
"UserGetOrCreate", () => UserDatabase.GetOrCreate(id, out newlyCreated));
}
I will get an exception for using "out" inside lambda expression. How should I resolve this?
If possible please write out a concrete code example... Thanks.