public void InitializeWithSoftListRefresh([CanBeNull] string defaultRootFolder = null) { using (new ProfileSection("Initialize with soft list refresh")) { // Add check that this isn't an initial initialization if (Instances == null) { Initialize(defaultRootFolder); } using (WebServerManager.WebServerContext context = WebServerManager.CreateContext()) { IEnumerable <Site> sites = GetOperableSites(context, defaultRootFolder); // The trick is in reused PartiallyCachedInstances. We use site ID as identificator that cached instance may be reused. If we can't fetch instance from cache, we create new. PartiallyCachedInstances = sites .Select(site => PartiallyCachedInstances.FirstOrDefault(cachedInst => cachedInst.ID == site.Id) ?? GetPartiallyCachedInstance(site)) .Where(IsSitecore) .Where(IsNotHidden) .ToArray(); Instances = PartiallyCachedInstances.Select(x => GetInstance(x.ID)).ToArray(); } } }
private IEnumerable <Instance> GetInstances() { using (new ProfileSection("Get instances")) { var array = PartiallyCachedInstances.Select(x => GetInstance(x.ID)).ToArray(); return(ProfileSection.Result(array)); } }