- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
private static void LoadSendMethodFromConfig()
{
    if (!sendMethod.HasValue)
    {
        sendMethod = SendMethodTypes.Default;
        try
        {
            // read SendKeys value from config file, not case sensitive
            string value = System.Configuration.ConfigurationManager.AppSettings.Get("SendKeys");
            if (string.IsNullOrEmpty(value))
                return;
            if (value.Equals("JournalHook", StringComparison.OrdinalIgnoreCase))
                sendMethod = SendMethodTypes.JournalHook;
            else if (value.Equals("SendInput", StringComparison.OrdinalIgnoreCase))
                sendMethod = SendMethodTypes.SendInput;
        }
        catch { } // ignore any exceptions to keep existing SendKeys behavior
    }
}
                                 
        
            Сорцы дотнета. Игнорируем любые исключения. Возмущение компилятора отключаем атрибутом. Как мило!
Пруф: http://referencesource.microsoft.com/#System.Windows.Forms/ndp/fx/src/winforms/Managed/System/WinForms/SendKeys.cs#323f3884113aa0ae#references
Цимес ещё и в том, что раньше в коде не было строк:
Комментарии (2) RSS
Добавить комментарий