Ejemplo n.º 1
0
        /// <summary>
        /// To support the AppContext's set switch through the config file for .NET Core;
        /// .Net Framework supports it internally through the configuration file by 'AppContextSwitchOverrides' element under 'runtime' section
        /// </summary>
        internal static void ApplyContextSwitches(IAppContextSwitchOverridesSection appContextSwitches)
        {
            string methodName = MethodBase.GetCurrentMethod().Name;

            SqlClientEventSource.Log.TryTraceEvent("<sc.{0}.{1}|INFO> Entry point.", TypeName, methodName);
            if (appContextSwitches != null)
            {
                ApplySwitchValues(appContextSwitches.Value?.Split('=', ';'));
            }

            SqlClientEventSource.Log.TryTraceEvent("<sc.{0}.{1}|INFO> Exit point.", TypeName, methodName);
        }
        static LocalAppContextSwitches()
        {
            IAppContextSwitchOverridesSection appContextSwitch = AppConfigManager.FetchConfigurationSection <AppContextSwitchOverridesSection>(AppContextSwitchOverridesSection.Name);

            try
            {
                SqlAppContextSwitchManager.ApplyContextSwitches(appContextSwitch);
            }
            catch (Exception e)
            {
                // Don't throw an exception for an invalid config file
                SqlClientEventSource.Log.TryTraceEvent("<sc.{0}.{1}|INFO>: {2}", TypeName, MethodBase.GetCurrentMethod().Name, e);
            }
        }