OSDN Git Service

コレクション初期化子を使用する (IDE0028)
[opentween/open-tween.git] / OpenTween / Growl.cs
index 2be7569..a0e2b8d 100644 (file)
@@ -35,6 +35,7 @@ using System.Drawing.Imaging;
 using System.Windows.Forms;
 using System.ComponentModel;
 using System.Collections;
+using System.Globalization;
 
 namespace OpenTween
 {
@@ -50,7 +51,6 @@ namespace OpenTween
         private object _growlApp;
 
         private object _targetConnector;
-        private object _targetCore;
 
         private string _appName = "";
         bool _initialized = false;
@@ -155,25 +155,24 @@ namespace OpenTween
             try
             {
                 _targetConnector = _connector.CreateInstance("Growl.Connector.GrowlConnector");
-                _targetCore = _core.CreateInstance("Growl.CoreLibrary");
                 Type _t = _connector.GetType("Growl.Connector.NotificationType");
 
                 _growlNTreply = _t.InvokeMember(null,
-                    BindingFlags.CreateInstance, null, null, new object[] { "REPLY", "Reply" });
+                    BindingFlags.CreateInstance, null, null, new object[] { "REPLY", "Reply" }, CultureInfo.InvariantCulture);
 
                 _growlNTdm = _t.InvokeMember(null,
-                    BindingFlags.CreateInstance, null, null, new object[] { "DIRECT_MESSAGE", "DirectMessage" });
+                    BindingFlags.CreateInstance, null, null, new object[] { "DIRECT_MESSAGE", "DirectMessage" }, CultureInfo.InvariantCulture);
 
                 _growlNTnew = _t.InvokeMember(null,
-                    BindingFlags.CreateInstance, null, null, new object[] { "NOTIFY", "新着通知" });
+                    BindingFlags.CreateInstance, null, null, new object[] { "NOTIFY", "新着通知" }, CultureInfo.InvariantCulture);
 
                 _growlNTusevent = _t.InvokeMember(null,
-                    BindingFlags.CreateInstance, null, null, new object[] { "USERSTREAM_EVENT", "UserStream Event" });
+                    BindingFlags.CreateInstance, null, null, new object[] { "USERSTREAM_EVENT", "UserStream Event" }, CultureInfo.InvariantCulture);
 
                 object encryptType =
                         _connector.GetType("Growl.Connector.Cryptography+SymmetricAlgorithmType").InvokeMember(
-                            "PlainText", BindingFlags.GetField, null, null, null);
-                _targetConnector.GetType().InvokeMember("EncryptionAlgorithm", BindingFlags.SetProperty, null, _targetConnector, new object[] { encryptType });
+                            "PlainText", BindingFlags.GetField, null, null, null, CultureInfo.InvariantCulture);
+                _targetConnector.GetType().InvokeMember("EncryptionAlgorithm", BindingFlags.SetProperty, null, _targetConnector, new object[] { encryptType }, CultureInfo.InvariantCulture);
 
                 _growlApp = _connector.CreateInstance(
                     "Growl.Connector.Application", false, BindingFlags.Default, null, new object[] { _appName }, null, null);
@@ -199,7 +198,6 @@ namespace OpenTween
                         "Growl.CoreLibrary.BinaryData").GetConstructor(
                         BindingFlags.Public | BindingFlags.Instance,
                         null, new Type[] { typeof(byte[]) }, null);
-                    TypeConverter tc = new TypeConverter();
                     object bdata = cibd.Invoke(
                         new object[] { IconToByteArray(Path.Combine(Application.StartupPath, "Icons\\MIcon.ico")) });
 
@@ -219,7 +217,6 @@ namespace OpenTween
                         "Growl.CoreLibrary.BinaryData").GetConstructor(
                         BindingFlags.Public | BindingFlags.Instance,
                         null, new Type[] { typeof(byte[]) }, null);
-                    TypeConverter tc = new TypeConverter();
                     object bdata = cibd.Invoke(
                         new object[] { IconToByteArray(Properties.Resources.MIcon) });
 
@@ -237,11 +234,13 @@ namespace OpenTween
 
                 _t = _connector.GetType("Growl.Connector.NotificationType");
 
-                ArrayList arglist = new ArrayList();
-                arglist.Add(_growlNTreply);
-                arglist.Add(_growlNTdm);
-                arglist.Add(_growlNTnew);
-                arglist.Add(_growlNTusevent);
+                var arglist = new ArrayList
+                {
+                    _growlNTreply,
+                    _growlNTdm,
+                    _growlNTnew,
+                    _growlNTusevent,
+                };
 
                 mi.Invoke(_targetConnector, new object[] { _growlApp, arglist.ToArray(_t) });
 
@@ -296,7 +295,8 @@ namespace OpenTween
                                              BindingFlags.Public | BindingFlags.Static | BindingFlags.InvokeMethod,
                                              null,
                                              null,
-                                             new object[] { icon });
+                                             new object[] { icon },
+                                             CultureInfo.InvariantCulture);
                 }
                 else
                 {
@@ -304,11 +304,12 @@ namespace OpenTween
                                              BindingFlags.Public | BindingFlags.Static | BindingFlags.InvokeMethod,
                                              null,
                                              null,
-                                             new object[] { url });
+                                             new object[] { url },
+                                             CultureInfo.InvariantCulture);
                 }
                 object priority =
                         _connector.GetType("Growl.Connector.Priority").InvokeMember(
-                            "Normal", BindingFlags.GetField, null, null, null);
+                            "Normal", BindingFlags.GetField, null, null, null, CultureInfo.InvariantCulture);
                 n = _connector.GetType("Growl.Connector.Notification").InvokeMember(
                         "Notification",
                         BindingFlags.CreateInstance,
@@ -322,7 +323,8 @@ namespace OpenTween
                                       res,
                                       false,
                                       priority,
-                                      "aaa"});
+                                      "aaa"},
+                        CultureInfo.InvariantCulture);
             }
             else
             {
@@ -335,13 +337,15 @@ namespace OpenTween
                                       notificationName,
                                       id,
                                       title,
-                                      text});
+                                      text},
+                        CultureInfo.InvariantCulture);
             }
             //_targetConnector.GetType.InvokeMember("Notify", BindingFlags.InvokeMethod, null, _targetConnector, new object[] {n});
             object cc = _connector.GetType("Growl.Connector.CallbackContext").InvokeMember(
                 null, BindingFlags.CreateInstance, null, _connector,
-                new object[] { "some fake information", notificationName });
-            _targetConnector.GetType().InvokeMember("Notify", BindingFlags.InvokeMethod, null, _targetConnector, new object[] { n, cc });
+                new object[] { "some fake information", notificationName },
+                CultureInfo.InvariantCulture);
+            _targetConnector.GetType().InvokeMember("Notify", BindingFlags.InvokeMethod, null, _targetConnector, new object[] { n, cc }, CultureInfo.InvariantCulture);
         }
 
         private void GrowlCallbackHandler(object response, object callbackData, object state)
@@ -381,8 +385,7 @@ namespace OpenTween
                             return;
                     }
 
-                    if (NotifyClicked != null)
-                        NotifyClicked(this, new NotifyCallbackEventArgs(nt, notifyId));
+                    NotifyClicked?.Invoke(this, new NotifyCallbackEventArgs(nt, notifyId));
                 }
             }
             catch (Exception)