The IIS web application.
Inheritance: IDisposable
        static void Main(string[] args)
        {
            if (args.Count() != 2)
            {
             Console.WriteLine("******************************************************************************************************");
             Console.WriteLine("Usage");
             Console.WriteLine("PerfTestAppDeployer.exe PhysicalPath AppName");
             Console.WriteLine("Sample Usage");
             Console.WriteLine(@"PerfTestAppDeployer.exe C:\Source\Repos\AppDataCollection\Bin\Debug\APMC\Tests\FunctionalTests\TestApps\Aspx451\App MyAppName");
             Console.WriteLine("Please press enter key.....");
             Console.WriteLine(
                    "******************************************************************************************************");
             Console.Read();             
            }
            else
            {
                string appLocation = args[0];
                string webSiteName = args[1];
                string poolName = "PerfAppPool";
                int port = 9090;

                Console.WriteLine("" + appLocation + " " + webSiteName);

                try
                {
                    ACLTools.GetEveryoneAccessToPath(@appLocation);
                    IisApplicationPool applicationPool = new IisApplicationPool(poolName);
                    IisWebSite iisWebSite = new IisWebSite(webSiteName, @appLocation, port, applicationPool);
                    /*
                    IisWebApplication iisWebApplication = new IisWebApplication(
                        "/" + webAppName,
                        @appLocation,
                        iisWebSite,
                        applicationPool);
                    */

                    Console.WriteLine("Application Deployed to IIS Successfully");
                    Console.WriteLine("ApplicationName:" + webSiteName);
                    Console.WriteLine("PhysicalPath:" + appLocation);
                }
                catch (Exception exception)
                {
                    Console.WriteLine("Failure" + exception);
                }
            }            
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="IisWebApplication"/> class.
        /// </summary>
        /// <param name="appName">
        /// The app name.
        /// </param>
        /// <param name="physicalPath">
        /// The physical Path.
        /// </param>
        /// <param name="site">
        /// The site.
        /// </param>
        /// <param name="pool">
        /// The pool.
        /// </param>
        public IisWebApplication(string appName, string physicalPath, IisWebSite site, IisApplicationPool pool)
        {
            try
            {
                this.Name        = appName;
                this.IisPath     = site.Name + this.Name;
                this.currentPool = pool;
                this.iisSite     = site;

                this.serverManager = new ServerManager();
                string relativePath = Path.Combine(Environment.CurrentDirectory, physicalPath);
                string absolutePath = Path.GetFullPath(relativePath);

                Site targetSite = this.serverManager.Sites[site.Name];
                if (targetSite != null)
                {
                    if (targetSite.Applications[this.Name] != null)
                    {
                        // removing if application already exists - because it can exists with the wrong physical path.
                        this.Remove();

                        // refreshing target site.
                        targetSite = this.serverManager.Sites[site.Name];
                    }

                    this.app = targetSite.Applications.Add(this.Name, absolutePath);
                    this.app.ApplicationPoolName = pool.Name;
                }

                this.serverManager.CommitChanges();

                Trace.TraceInformation(
                    "IISWebApplication {0} created successfully.", appName);
            }
            catch (Exception ex)
            {
                Trace.TraceError("Exception occured while creating application: {0}. The exception thrown was {1}", this.iisSite.Name, ex.Message);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="IisWebApplication"/> class.
        /// </summary>
        /// <param name="appName">
        /// The app name.
        /// </param>
        /// <param name="physicalPath">
        /// The physical Path.
        /// </param>
        /// <param name="site">
        /// The site.
        /// </param>
        /// <param name="pool">
        /// The pool.
        /// </param>
        public IisWebApplication(string appName, string physicalPath, IisWebSite site, IisApplicationPool pool)
        {
            try
            {
                this.Name = appName;
                this.IisPath = site.Name + this.Name;
                this.currentPool = pool;
                this.iisSite = site;

                this.serverManager = new ServerManager();
                string relativePath = Path.Combine(Environment.CurrentDirectory, physicalPath);
                string absolutePath = Path.GetFullPath(relativePath);

                Site targetSite = this.serverManager.Sites[site.Name];
                if (targetSite != null)
                {
                    if (targetSite.Applications[this.Name] != null)
                    {
                        // removing if application already exists - because it can exists with the wrong physical path.
                        this.Remove();

                        // refreshing target site.
                        targetSite = this.serverManager.Sites[site.Name];
                    }

                    this.app = targetSite.Applications.Add(this.Name, absolutePath);
                    this.app.ApplicationPoolName = pool.Name;
                }

                this.serverManager.CommitChanges();

                Trace.TraceInformation(
               "IISWebApplication {0} created successfully.", appName);
            }
            catch (Exception ex)
            {
                Trace.TraceError("Exception occured while creating application: {0}. The exception thrown was {1}", this.iisSite.Name, ex.Message);
            }
        }