You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the result of the body of the property is null, then the body of the property is called each time.
This could be fixed using a slightly different implementation:
// begin - fields added by the post-compile stepprivatestaticLazy<Settings>_settings=newLazy<Settings>(()=>__Settings);publicstaticSettingsSettings{get{return_settings.Value;}}// end// Property is made private and name changed somehowprivatestaticSettings__Settings{get{using(varfs=File.Open("settings.xml",FileMode.Open)){varserializer=newXmlSerializer(typeof(Settings));return(Settings)serializer.Deserialize(fs);}}}
The text was updated successfully, but these errors were encountered:
Ah yes. This is a problem for reference types. For value types i wrap the value in a container class I think (it's been a while since I wrote this). I could do the same for reference types but Lazy doesn't have the behavior I want. I want it to:
Guarantee that the function is called exactly once.
Retry should an exception be thrown (Lazy will save and rethrow the exception if one occurs on the first time.)
This is a really cool project.
If the result of the body of the property is null, then the body of the property is called each time.
This could be fixed using a slightly different implementation:
The text was updated successfully, but these errors were encountered: