Ejemplo n.º 1
0
        public void InitializeWithSoftListRefresh([CanBeNull] string defaultRootFolder = null)
        {
            SitecoreEnvironmentHelper.RefreshEnvironments();

            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?.Values.FirstOrDefault(cachedInst => cachedInst.ID == site.Id) ??
                                                            GetPartiallyCachedInstance(site))
                                               .Where(IsSitecoreOrSitecoreEnvironmentMember)
                                               .Where(IsNotHidden).ToDictionary(value => value.Name);

                    Instances = PartiallyCachedInstances?.Values.Select(x => GetInstance(x.ID)).ToArray();
                }
            }
        }
Ejemplo n.º 2
0
        public void Initialize([CanBeNull] string defaultRootFolder = null)
        {
            SitecoreEnvironmentHelper.RefreshEnvironments();

            using (WebServerManager.WebServerContext context = WebServerManager.CreateContext())
            {
                ProfileSection.Argument("defaultRootFolder", defaultRootFolder);

                IEnumerable <Site> sites = GetOperableSites(context, defaultRootFolder);
                PartiallyCachedInstances = GetPartiallyCachedInstances(sites);
                Instances = GetInstances();
            }
        }
Ejemplo n.º 3
0
        public void Initialize([CanBeNull] string defaultRootFolder = null)
        {
            SitecoreEnvironmentHelper.RefreshEnvironments();

            List <Instance> instances = new List <Instance>();

            if (ApplicationManager.IsIisRunning)
            {
                instances.AddRange(GetIISInstances());
            }

            if (ApplicationManager.IsDockerRunning)
            {
                instances.AddRange(GetContainerizedInstances());
            }

            Dictionary <string, Instance> partiallyCachedInstances = instances.ToDictionary(i => i.Name);

            PartiallyCachedInstances = partiallyCachedInstances;

            Instances = instances;
        }