Quick question - is there any 'prettier' way to determine if a variable was lazily initialized than:
var paramType = param.GetType();
if (paramType.FullName.Contains("System.Lazy"))
{
...
}
I know it's not something really recommended to be checked, but there is a particular need to differentiate it.
Try this:
if (paramType.IsGenericType && paramType.GetGenericTypeDefinition() == typeof(Lazy<>))
It should return true
if param
is a Lazy<T>
(and paramType
is param.GetType()
).