private static UriSectionInternal LoadUsingCustomParser(string appConfigFilePath) { string runtimeDirectory = null; new FileIOPermission(PermissionState.Unrestricted).Assert(); try { runtimeDirectory = RuntimeEnvironment.GetRuntimeDirectory(); } finally { CodeAccessPermission.RevertAssert(); } UriSectionData parentData = UriSectionReader.Read(Path.Combine(Path.Combine(runtimeDirectory, "Config"), "machine.config")); UriSectionData data2 = UriSectionReader.Read(appConfigFilePath, parentData); UriSectionData data3 = null; if (data2 != null) { data3 = data2; } else if (parentData != null) { data3 = parentData; } if (data3 != null) { UriIdnScope?idnScope = data3.IdnScope; UriIdnScope scope = idnScope.HasValue ? idnScope.GetValueOrDefault() : UriIdnScope.None; bool? iriParsing = data3.IriParsing; bool flag = iriParsing.HasValue ? iriParsing.GetValueOrDefault() : false; return(new UriSectionInternal(scope, flag, data3.SchemeSettings.Values)); } return(null); }
private UriSectionInternal(UriIdnScope idnScope, bool iriParsing, IEnumerable<SchemeSettingInternal> schemeSettings) : this() { this.idnScope = idnScope; this.iriParsing = iriParsing; if (schemeSettings != null) { foreach (SchemeSettingInternal internal2 in schemeSettings) { this.schemeSettings.Add(internal2.Name, internal2); } } }
private UriSectionInternal(UriIdnScope idnScope, bool iriParsing, IEnumerable <SchemeSettingInternal> schemeSettings) : this() { this.idnScope = idnScope; this.iriParsing = iriParsing; if (schemeSettings != null) { foreach (SchemeSettingInternal internal2 in schemeSettings) { this.schemeSettings.Add(internal2.Name, internal2); } } }
private UriSectionInternal(UriSection section) : this() { this.idnScope = section.Idn.Enabled; this.iriParsing = section.IriParsing.Enabled; if (section.SchemeSettings != null) { foreach (SchemeSettingElement element in section.SchemeSettings) { SchemeSettingInternal internal2 = new SchemeSettingInternal(element.Name, element.GenericUriParserOptions); this.schemeSettings.Add(internal2.Name, internal2); } } }
private static UriSectionInternal LoadUsingCustomParser(string appConfigFilePath) { // Already have the application config file path in scope. // Get the path of the machine config file. string runtimeDir = null; // Must Assert unrestricted FileIOPermission to get the machine config path. new FileIOPermission(PermissionState.Unrestricted).Assert(); try { runtimeDir = RuntimeEnvironment.GetRuntimeDirectory(); } finally { FileIOPermission.RevertAssert(); } string machineConfigFilePath = Path.Combine(Path.Combine(runtimeDir, "Config"), "machine.config"); UriSectionData machineSettings = UriSectionReader.Read(machineConfigFilePath); // pass machineSettings to ctor: appSettings will use the values of machineSettings as init values. UriSectionData appSettings = UriSectionReader.Read(appConfigFilePath, machineSettings); UriSectionData resultSectionData = null; if (appSettings != null) { resultSectionData = appSettings; } else if (machineSettings != null) { resultSectionData = machineSettings; } if (resultSectionData != null) { UriIdnScope idnScope = resultSectionData.IdnScope ?? IdnElement.EnabledDefaultValue; bool iriParsing = resultSectionData.IriParsing ?? IriParsingElement.EnabledDefaultValue; IEnumerable <SchemeSettingInternal> schemeSettings = resultSectionData.SchemeSettings.Values as IEnumerable <SchemeSettingInternal>; return(new UriSectionInternal(idnScope, iriParsing, schemeSettings)); } return(null); }
private static void InitializeUriConfig() { if (!s_ConfigInitialized) { lock (InitializeLock) { if (!s_ConfigInitialized && !s_ConfigInitializing) { s_ConfigInitializing = true; UriSectionInternal section = UriSectionInternal.GetSection(); if (section != null) { s_IdnScope = section.IdnScope; s_IriParsing = section.IriParsing; SetEscapedDotSlashSettings(section, "http"); SetEscapedDotSlashSettings(section, "https"); } s_ConfigInitialized = true; s_ConfigInitializing = false; } } } }