@@ -231,59 +231,59 @@ public static Configuration GetCurrentConfiguration(this ConfigurationElement co
231231 return ( Configuration ) configProperty . GetValue ( configElement , null ) ;
232232 }
233233
234- #if ! NETSTANDARD2_0
235- private static void ResetConfigurationForMono ( AppDomain appDomain , string configFilePath )
236- {
237- appDomain . SetupInformation . ConfigurationFile = configFilePath ;
238-
239- var configSystem = typeof ( ConfigurationManager )
240- . GetField ( "configSystem" , BindingFlags . Static | BindingFlags . NonPublic )
241- . GetValue ( null ) ;
242-
243- // clear previous state
244- typeof ( ConfigurationManager )
245- . Assembly . GetTypes ( )
246- . Where ( x => x . FullName == "System.Configuration.ClientConfigurationSystem" )
247- . First ( )
248- . GetField ( "cfg" , BindingFlags . Instance | BindingFlags . NonPublic )
249- . SetValue ( configSystem , null ) ;
250- }
251-
252- private static void ResetConfigurationForDotNet ( AppDomain appDomain , string configFilePath )
253- {
254- appDomain . SetData ( "APP_CONFIG_FILE" , configFilePath ) ;
255-
256- // clear previous state
257- BindingFlags flags = BindingFlags . NonPublic | BindingFlags . Static ;
258-
259- typeof ( ConfigurationManager )
260- . GetField ( "s_initState" , flags )
261- . SetValue ( null , 0 ) ;
262-
263- typeof ( ConfigurationManager )
264- . GetField ( "s_configSystem" , flags )
265- . SetValue ( null , null ) ;
266-
267- typeof ( ConfigurationManager )
268- . Assembly . GetTypes ( )
269- . Where ( x => x . FullName == "System.Configuration.ClientConfigPaths" )
270- . First ( )
271- . GetField ( "s_current" , flags )
272- . SetValue ( null , null ) ;
273- }
274-
275- /// <summary>
276- /// Reset application's configuration to a another config file
277- /// </summary>
278- /// <param name="appDomain">the assosiated AppDomain</param>
279- /// <param name="configFilePath">the config file path want to reset to</param>
280- public static void ResetConfiguration ( this AppDomain appDomain , string configFilePath )
281- {
282- if ( Platform . IsMono )
283- ResetConfigurationForMono ( appDomain , configFilePath ) ;
284- else
285- ResetConfigurationForDotNet ( appDomain , configFilePath ) ;
286- }
287- #endif
234+ // #if !NETSTANDARD2_0
235+ // private static void ResetConfigurationForMono(AppDomain appDomain, string configFilePath)
236+ // {
237+ // appDomain.SetupInformation.ConfigurationFile = configFilePath;
238+
239+ // var configSystem = typeof(ConfigurationManager)
240+ // .GetField("configSystem", BindingFlags.Static | BindingFlags.NonPublic)
241+ // .GetValue(null);
242+
243+ // // clear previous state
244+ // typeof(ConfigurationManager)
245+ // .Assembly.GetTypes()
246+ // .Where(x => x.FullName == "System.Configuration.ClientConfigurationSystem")
247+ // .First()
248+ // .GetField("cfg", BindingFlags.Instance | BindingFlags.NonPublic)
249+ // .SetValue(configSystem, null);
250+ // }
251+
252+ // private static void ResetConfigurationForDotNet(AppDomain appDomain, string configFilePath)
253+ // {
254+ // appDomain.SetData("APP_CONFIG_FILE", configFilePath);
255+
256+ // // clear previous state
257+ // BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Static;
258+
259+ // typeof(ConfigurationManager)
260+ // .GetField("s_initState", flags)
261+ // .SetValue(null, 0);
262+
263+ // typeof(ConfigurationManager)
264+ // .GetField("s_configSystem", flags)
265+ // .SetValue(null, null);
266+
267+ // typeof(ConfigurationManager)
268+ // .Assembly.GetTypes()
269+ // .Where(x => x.FullName == "System.Configuration.ClientConfigPaths")
270+ // .First()
271+ // .GetField("s_current", flags)
272+ // .SetValue(null, null);
273+ // }
274+
275+ ///// <summary>
276+ ///// Reset application's configuration to a another config file
277+ ///// </summary>
278+ ///// <param name="appDomain">the assosiated AppDomain</param>
279+ ///// <param name="configFilePath">the config file path want to reset to</param>
280+ // public static void ResetConfiguration(this AppDomain appDomain, string configFilePath)
281+ // {
282+ // if (Platform.IsMono)
283+ // ResetConfigurationForMono(appDomain, configFilePath);
284+ // else
285+ // ResetConfigurationForDotNet(appDomain, configFilePath);
286+ // }
287+ // #endif
288288 }
289289}
0 commit comments