void EnsureInstance ()
{
if (instance_create_failed)
throw new PhotoSourceNotAvailableException ();
lock (this) {
if (instance == null) {
Type type = null;
if (!PhotoSourceInfoManager.Instance.PhotoSourceTypes.TryGetValue (SourceType, out type)) {
instance_create_failed = true;
UpdateAvailability ();
throw new PhotoSourceNotAvailableException ();
}
instance = Activator.CreateInstance (type) as ICacheablePhotoSource;
instance.CacheId = CacheId;
instance.WakeUp ();
instance.AvailabilityChanged += (s, a) => UpdateAvailability ();
}
}
}