Dispose() public méthode

public Dispose ( ) : void
Résultat void
Exemple #1
0
        public static void CreateIISWebSite(string siteName, string siteAddress, string physicalPath)
        {
            ServerManager iisManager = new ServerManager();
            Site site = iisManager.Sites[siteName];
            if (site != null)
            {
                iisManager.Sites.Remove(iisManager.Sites[siteName]);
                iisManager.CommitChanges();
            }

            iisManager.Sites.Add(siteName, "http", string.Concat("*:80:", siteAddress), physicalPath);
            iisManager.CommitChanges();
            iisManager.Dispose();
        }
        private static ServerManager CreateServerManager(string sitename)
        {
            // 既存のサイトが出来るまで待機というかループ
            var serverManager = new ServerManager();
            var sc = serverManager.Sites[sitename];
            while (sc == null)
            {
                Thread.Sleep(TimeSpan.FromSeconds(100));
                serverManager.Dispose();
                serverManager = new ServerManager();
                sc = serverManager.Sites[sitename];
            }

            return serverManager;
        }
        /// <summary>
        /// Deletes the IIS application.
        /// </summary>
        /// <param name="applicationName">Name of the application.</param>
        public static void DeleteIISApplication(string applicationName)
        {
            using (ServerManager serverManager = new ServerManager())
            {
                var defaultSite = serverManager.Sites[TestConfig.DefaultWebsiteName];
                Application newApplication = defaultSite.Applications["/{0}".FormatWith(applicationName)];

                // Remove
                if (newApplication != null)
                {
                    defaultSite.Applications.Remove(newApplication);
                    serverManager.CommitChanges();
                }

                serverManager.Dispose();
            }
        }
Exemple #4
0
        public static void CreateIISApplication(string appName, string physicalPath, string appPool)
        {
            ServerManager iisManager = new ServerManager();
            Site defaultSite = iisManager.Sites["Default Web Site"];
            Microsoft.Web.Administration.Application app = defaultSite.Applications[String.Format("/{0}", appName)];

            //Remove application if it already exists
            if (app != null)
            {
                defaultSite.Applications.Remove(app);
                iisManager.CommitChanges();
            }

            defaultSite.Applications.Add(String.Format("/{0}", appName), physicalPath);
            SetApplicationPool(appName, appPool);
            iisManager.CommitChanges();
            iisManager.Dispose();
        }
Exemple #5
0
        /// <summary>
        /// Creates the IIS application.
        /// </summary>
        /// <param name="applicationName">Name of the application.</param>
        /// <param name="physicalPath">The physical path.</param>
        public static void CreateIISApplication(string applicationName, string physicalPath)
        {
            using (ServerManager serverManager = new ServerManager())
            {
                var defaultSite = serverManager.Sites[TestConfig.DefaultWebsiteName];
                Application newApplication = defaultSite.Applications["/{0}".FormatWith(applicationName)];

                // Remove if exists?!
                if (newApplication != null)
                {
                    defaultSite.Applications.Remove(newApplication);
                    serverManager.CommitChanges();
                }

                defaultSite = serverManager.Sites[TestConfig.DefaultWebsiteName];
                newApplication = defaultSite.Applications.Add("/{0}".FormatWith(applicationName), physicalPath);

                newApplication.ApplicationPoolName = TestConfig.TestApplicationPool;

                serverManager.CommitChanges();
                serverManager.Dispose();
            }
        }
Exemple #6
0
        public static void SetApplicationPool(string appName, string appPool)
        {
            ServerManager iisManager = new ServerManager();
            Site defaultSite = iisManager.Sites["Default Web Site"];
            Microsoft.Web.Administration.Application app = defaultSite.Applications[String.Format("/{0}", appName)];

            if (app != null)
            {
                app.ApplicationPoolName = appPool;
                iisManager.CommitChanges();
                iisManager.Dispose();
            }
        }
        /// <summary>
        /// 应用程序池是否存在
        /// </summary>
        /// <param name="appPoolName"></param>
        /// <returns></returns>
        public static bool DoesExistAppPool(string appPoolName)
        {
            ServerManager manager = new ServerManager();

            ApplicationPool pool;

            pool = null;
            try
            {
                pool = manager.ApplicationPools[appPoolName];
            }
            catch
            {
            }
            manager.Dispose();
            return pool != null;
        }