SIM.Adapters.WebServer.WebServerManager.CreateContext C# (CSharp) Method

CreateContext() private method

private CreateContext ( [ debugLocation, object callingClass = null ) : WebServerContext
debugLocation [
callingClass object
return WebServerContext
        public static WebServerContext CreateContext([CanBeNull] string debugLocation, object callingClass = null)
        {
            return new WebServerContext(debugLocation, callingClass);
        }

Usage Example

        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();
                }
            }
        }
All Usage Examples Of SIM.Adapters.WebServer.WebServerManager::CreateContext