Exemplo n.º 1
0
        internal Application(ConfigurationElement element, ApplicationCollection parent)
            : base(element, "application", null, parent, null, null)
        {
            Parent = parent;

            // IMPORTANT: avoid duplicate application tag.
            ForceCreateEntity();
            if (string.IsNullOrWhiteSpace(Path))
            {
                // IMPORTANT: fix path attribute after initialization.
                Path = "/";
            }

            _collection = new VirtualDirectoryCollection(this);
            if (element == null)
            {
                return;
            }

            foreach (ConfigurationElement node in (ConfigurationElementCollection)element)
            {
                _collection.InternalAdd(new VirtualDirectory(node, _collection));
            }

            Location = this.Site.Name + this.Path;
            foreach (ApplicationPool pool in Server.ApplicationPools)
            {
                if (pool.Name == ApplicationPoolName)
                {
                    pool.ApplicationCount++;
                }
            }
        }
Exemplo n.º 2
0
        internal async Task RemoveApplicationsAsync()
        {
            foreach (Application application in Applications)
            {
                await application.RemoveAsync();
            }

            Applications = new ApplicationCollection(this);
        }
Exemplo n.º 3
0
        internal Application(ConfigurationElement element, ApplicationCollection parent)
            : base(element, "application", null, parent, null, null)
        {
            Parent = parent;
            if (Parent.Parent == null)
            {
                throw new ArgumentException("Site cannot be null", nameof(parent));
            }

            // IMPORTANT: avoid duplicate application tag.
            ForceCreateEntity();
            if (string.IsNullOrWhiteSpace(Path))
            {
                // IMPORTANT: fix path attribute after initialization.
                Path = "/";
            }

            VirtualDirectories = new VirtualDirectoryCollection(this);
            if (element == null)
            {
                return;
            }

            foreach (ConfigurationElement node in (ConfigurationElementCollection)element)
            {
                VirtualDirectories.InternalAdd(new VirtualDirectory(node, VirtualDirectories));
            }

            Location = Site.Name + Path;
            foreach (ApplicationPool pool in Server.ApplicationPools)
            {
                if (pool.Name == ApplicationPoolName)
                {
                    pool.ApplicationCount++;
                }
            }
        }
Exemplo n.º 4
0
        internal async Task <ApplicationCollection> RemoveAsync()
        {
            if (Path == RootPath)
            {
                throw new InvalidOperationException("Root application cannot be removed. Please remove the site.");
            }

            var newApps = new ApplicationCollection(Site);

            foreach (Application item in Parent)
            {
                if (item == this)
                {
                    item.Delete();
                    continue;
                }

                item.Parent = newApps;
                newApps.Add(item);
            }

            newApps.Parent.Applications = newApps;
            return(newApps);
        }
Exemplo n.º 5
0
 internal Application(ApplicationCollection parent)
     : this(null, parent)
 {
 }