I want to implement some lazy initialization of a property of type StyleBackground like this:
protected StyleBackground image;
public StyleBackground Image
{
get
{
if (image.value == default)
image = LoadImage();
return image;
}
}
What should I check to find out whether “image” is already set? Is image.value the right thing? Or perhaps image.keyword would be better? Like
image.keyword == StyleKeyword.Undefined
Addition. Found out - after setting the image.value, the image.keyword remains untouched (StyleKeyword.Undefined by default). So, image.keyword is not the property to check whether StyleBackground is set or not.