public override void Validate(object value)
        {
            var data = (string)value;

            if (string.IsNullOrWhiteSpace(data))
            {
                throw new COMException("Invalid application pool name\r\n");
            }

            foreach (var ch in ApplicationPoolCollection.InvalidApplicationPoolNameCharacters())
            {
                if (data.Contains(ch))
                {
                    throw new COMException("Invalid application pool name\r\n");
                }
            }
        }
Ejemplo n.º 2
0
 internal ApplicationPool(ConfigurationElement element, ApplicationPoolCollection parent)
     : base(element, "add", null, parent, null, null)
 {
     Parent = parent;
 }
        private void Initialize()
        {
            if (this.Initialized)
            {
                return;
            }

            this.Initialized = true;
            PreInitialize();
            var machineConfig = Helper.IsRunningOnMono()
                ? "/Library/Frameworks/Mono.framework/Versions/Current/etc/mono/4.5/machine.config"
                : Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.Windows),
                "Microsoft.NET",
                IntPtr.Size == 2 ? "Framework" : "Framework64",
                "v4.0.30319",
                "config",
                "machine.config");
            var machine =
                new Configuration(
                    new FileContext(
                        this,
                        machineConfig,
                        null,
                        null,
                        false,
                        true,
                        true));
            var webConfig = Helper.IsRunningOnMono()
                ? "/Library/Frameworks/Mono.framework/Versions/Current/etc/mono/4.5/web.config"
                : Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.Windows),
                "Microsoft.NET",
                IntPtr.Size == 2 ? "Framework" : "Framework64",
                "v4.0.30319",
                "config",
                "web.config");
            var web =
                new Configuration(
                    new FileContext(
                        this,
                        webConfig,
                        machine.FileContext,
                        null,
                        false,
                        true,
                        true));

            _applicationHost =
                new Configuration(
                    new FileContext(this, this.FileName, web.FileContext, null, true, false, this.ReadOnly));

            this.LoadCache();

            var poolSection = _applicationHost.GetSection("system.applicationHost/applicationPools");

            _applicationPoolDefaults =
                new ApplicationPoolDefaults(poolSection.GetChildElement("applicationPoolDefaults"), poolSection);
            this.ApplicationPoolCollection = new ApplicationPoolCollection(poolSection, this);
            var siteSection = _applicationHost.GetSection("system.applicationHost/sites");

            _siteDefaults        = new SiteDefaults(siteSection.GetChildElement("siteDefaults"), siteSection);
            _applicationDefaults = new ApplicationDefaults(
                siteSection.GetChildElement("applicationDefaults"),
                siteSection);
            _virtualDirectoryDefaults =
                new VirtualDirectoryDefaults(siteSection.GetChildElement("virtualDirectoryDefaults"), siteSection);
            this.SiteCollection = new SiteCollection(siteSection, this);

            PostInitialize();
        }
Ejemplo n.º 4
0
        private void Initialize()
        {
            lock (_locker)
            {
                if (Initialized)
                {
                    return;
                }

                Initialized = true;
                PreInitialize();

                var machine =
                    new Configuration(
                        new FileContext(
                            this,
                            Helper.FileNameMachineConfig,
                            null,
                            null,
                            false,
                            true,
                            true)
                {
                    IgnoreSchemaCheck = true
                });

                _web =
                    new Configuration(
                        new FileContext(
                            this,
                            Helper.FileNameWebConfig,
                            machine.FileContext,
                            null,
                            false,
                            true,
                            false));

                _applicationHost =
                    new Configuration(
                        new FileContext(this, FileName, _web.FileContext, null, true, false, ReadOnly));

                LoadCache();

                var poolSectionName = "system.applicationHost/applicationPools";
                var poolSection     = _applicationHost.GetSection(poolSectionName);
                if (poolSection == null)
                {
                    throw new COMException($"Filename: \\\\?\\{FileName}\r\nError: The configuration section '{poolSectionName}' cannot be read because it is missing a section declaration\r\n\r\n");
                }

                _applicationPoolDefaults =
                    new ApplicationPoolDefaults(poolSection?.GetChildElement("applicationPoolDefaults"), poolSection);
                ApplicationPoolCollection = new ApplicationPoolCollection(poolSection, this);

                var siteSectionName = "system.applicationHost/sites";
                var siteSection     = _applicationHost.GetSection(siteSectionName);
                if (siteSection == null)
                {
                    throw new COMException($"Filename: \\\\?\\{FileName}\r\nError: The configuration section '{siteSectionName}' cannot be read because it is missing a section declaration\r\n\r\n");
                }

                _siteDefaults        = new SiteDefaults(siteSection?.GetChildElement("siteDefaults"), siteSection);
                _applicationDefaults = new ApplicationDefaults(
                    siteSection?.GetChildElement("applicationDefaults"),
                    siteSection);
                _virtualDirectoryDefaults =
                    new VirtualDirectoryDefaults(siteSection?.GetChildElement("virtualDirectoryDefaults"), siteSection);
                SiteCollection = new SiteCollection(siteSection, this);
            }

            // IMPORTANT: out of locking for Jexus web server.
            PostInitialize();
        }