예제 #1
0
        ConfigurationData GetConfigFromFileName(string filepath, HttpContext context)
        {
            if (filepath == "")
            {
                return((ConfigurationData)fileToConfig [WebConfigurationSettings.MachineConfigPath]);
            }

            string dir = UrlUtils.GetDirectory(filepath);

            if (HttpRuntime.AppDomainAppVirtualPath.Length > dir.Length)
            {
                return((ConfigurationData)fileToConfig [WebConfigurationSettings.MachineConfigPath]);
            }

            ConfigurationData data = (ConfigurationData)fileToConfig [dir];

            if (data != null)
            {
                return(data);
            }

            string realpath = null;

            try {
                realpath = context.Request.MapPath(dir);
            } catch {
                realpath = context.Request.MapPath(HttpRuntime.AppDomainAppVirtualPath);
            }

            if (realpath == null || realpath.Length == 0)
            {
                realpath = HttpRuntime.AppDomainAppPath;
            }

            string lower   = Path.Combine(realpath, "web.config");
            bool   isLower = File.Exists(lower);
            string wcfile  = null;

            if (!isLower)
            {
                string upper   = Path.Combine(realpath, "Web.config");
                bool   isUpper = File.Exists(upper);
                if (isUpper)
                {
                    wcfile = upper;
                }
            }
            else
            {
                wcfile = lower;
            }

            string tempDir = dir;

            if (tempDir.Length > 1)
            {
                tempDir = tempDir.Substring(0, tempDir.Length - 1);
            }
            if (tempDir == HttpRuntime.AppDomainAppVirtualPath)
            {
                tempDir  = "";
                realpath = HttpRuntime.AppDomainAppPath;
            }
            ConfigurationData parent = GetConfigFromFileName(tempDir, context);

            if (wcfile == null)
            {
                data               = new ConfigurationData(parent, null, realpath);
                data.DirName       = dir;
                fileToConfig [dir] = data;
            }

            if (data == null)
            {
                data         = new ConfigurationData(parent, wcfile);
                data.DirName = dir;
                data.LoadFromFile(wcfile);
                fileToConfig [dir] = data;
            }

            return(data);
        }
예제 #2
0
 public ConfigurationData(ConfigurationData parent, string filename)
 {
     this.parent   = (parent == this) ? null : parent;
     this.fileName = filename;
     factories     = new Hashtable();
 }
예제 #3
0
 public Location(ConfigurationData parent, string path, bool allowOverride)
 {
     this.parent        = parent;
     this.allowOverride = allowOverride;
     this.path          = (path == null || path == "") ? "*" : path;
 }