CreateContext() приватный Метод

private CreateContext ( [ debugLocation, object callingClass = null ) : WebServerContext
debugLocation [
callingClass object
Результат WebServerContext
        public virtual void Start()
        {
            Log.Info($"Starting website {ID}");

            if (IsDisabled)
            {
                throw new InvalidOperationException("The {0} website is disabled. Open IIS Manager and remove _disabled suffix from its name in order to enable the website.");
            }

            using (WebServerManager.WebServerContext context = WebServerManager.CreateContext())
            {
                Site site = GetSite(context);
                Assert.IsNotNull(site, "Site is missing");
                ApplicationPool pool = GetPool(context);
                Assert.IsNotNull(pool, nameof(pool));
                if (!IsStarted(pool))
                {
                    pool.Start();
                    context.CommitChanges();
                }
            }

            using (WebServerManager.WebServerContext context = WebServerManager.CreateContext())
            {
                Site site = GetSite(context);
                Assert.IsNotNull(site, "Site is missing");
                if (!IsStarted(site))
                {
                    site.Start();
                    context.CommitChanges();
                }
            }
        }
        public virtual void Stop(bool?force = null)
        {
            Log.Info($"Stop website {Name} ({ID})");

            using (WebServerManager.WebServerContext context = WebServerManager.CreateContext())
            {
                ApplicationPool pool = GetPool(context);

                if (force ?? false)
                {
                    foreach (WorkerProcess workerProcess in pool.WorkerProcesses)
                    {
                        try
                        {
                            Process process = Process.GetProcessById(workerProcess.ProcessId);
                            process.Kill();
                        }
                        catch (Exception ex)
                        {
                            Log.Warn(ex, $"Stop website {Name} ({ID}) failed");
                        }
                    }
                }

                if (IsStarted(pool))
                {
                    pool.Stop();
                    context.CommitChanges();
                }
            }
        }
        public virtual void Stop(bool force = false)
        {
            Log.Info("Stop website {0} ({1})", this.Name, this.ID);

            using (WebServerManager.WebServerContext context = WebServerManager.CreateContext("Website.Stop"))
            {
                ApplicationPool pool = this.GetPool(context);

                if (force)
                {
                    foreach (WorkerProcess workerProcess in pool.WorkerProcesses)
                    {
                        try
                        {
                            Process process = Process.GetProcessById(workerProcess.ProcessId);
                            process.Kill();
                        }
                        catch (Exception ex)
                        {
                            Log.Warn(ex, "Stop website {0} ({1}) failed", this.Name, this.ID);
                        }
                    }
                }

                if (this.IsStarted(pool))
                {
                    pool.Stop();
                    context.CommitChanges();
                }
            }
        }
        public virtual void Start()
        {
            Log.Info("Starting website {0}", this.ID);

            using (WebServerManager.WebServerContext context = WebServerManager.CreateContext("Website.Start"))
            {
                Site site = this.GetSite(context);
                Assert.IsNotNull(site, "Site is missing");
                ApplicationPool pool = this.GetPool(context);
                Assert.IsNotNull(pool, "pool");
                if (!this.IsStarted(pool))
                {
                    pool.Start();
                    context.CommitChanges();
                }
            }

            using (WebServerManager.WebServerContext context = WebServerManager.CreateContext("Website.Start"))
            {
                Site site = this.GetSite(context);
                Assert.IsNotNull(site, "Site is missing");
                if (!IsStarted(site))
                {
                    site.Start();
                    context.CommitChanges();
                }
            }
        }
        public virtual void StopApplicationPool()
        {
            Log.Info($"Stop app pool {Name} ({ID})");

            using (WebServerManager.WebServerContext context = WebServerManager.CreateContext())
            {
                ApplicationPool pool = GetPool(context);
                if (IsStarted(pool))
                {
                    pool.Stop();
                    context.CommitChanges();
                }
            }
        }
        public virtual void Recycle()
        {
            Log.Info($"Recycle the {Name} instance's application pool");

            using (WebServerManager.WebServerContext context = WebServerManager.CreateContext())
            {
                ApplicationPool pool = GetPool(context);
                if (IsStarted(pool))
                {
                    pool.Recycle();
                    context.CommitChanges();
                }
            }
        }
        public virtual void StopApplicationPool()
        {
            Log.Info("Stop app pool {0} ({1})", this.Name, this.ID);

            using (WebServerManager.WebServerContext context = WebServerManager.CreateContext("Website.StopApplicationPool"))
            {
                ApplicationPool pool = this.GetPool(context);
                if (this.IsStarted(pool))
                {
                    pool.Stop();
                    context.CommitChanges();
                }
            }
        }
        public virtual void Recycle()
        {
            Log.Info("Recycle the {0} instance's application pool", this.Name);

            using (WebServerManager.WebServerContext context = WebServerManager.CreateContext("Website.Recycle"))
            {
                ApplicationPool pool = this.GetPool(context);
                if (this.IsStarted(pool))
                {
                    pool.Recycle();
                    context.CommitChanges();
                }
            }
        }
        public virtual void SetAppPoolMode(bool?is40 = null, bool?is32 = null)
        {
            using (WebServerManager.WebServerContext context = WebServerManager.CreateContext())
            {
                ApplicationPool pool = GetPool(context);
                if (is32 != null)
                {
                    pool.Enable32BitAppOnWin64 = (bool)is32;
                }

                if (is40 != null)
                {
                    pool.SetAttributeValue("managedRuntimeVersion", (bool)is40 ? "v4.0" : "v2.0");
                }

                context.CommitChanges();
            }
        }