OSDN Git Service

パターンマッチングを使用する (IDE0019)
authorKimura Youichi <kim.upsilon@bucyou.net>
Tue, 29 May 2018 01:35:52 +0000 (10:35 +0900)
committerKimura Youichi <kim.upsilon@bucyou.net>
Tue, 29 May 2018 01:40:54 +0000 (10:40 +0900)
OpenTween/Models/MediaInfo.cs
OpenTween/OTPictureBox.cs
OpenTween/TabsDialog.cs
OpenTween/TweetThumbnail.cs

index b942850..0fea3f1 100644 (file)
@@ -46,12 +46,7 @@ namespace OpenTween.Models
         }
 
         public override bool Equals(object obj)
-        {
-            var info = obj as MediaInfo;
-            return info != null &&
-                info.Url == this.Url &&
-                info.VideoUrl == this.VideoUrl;
-        }
+            => obj is MediaInfo info && info.Url == this.Url && info.VideoUrl == this.VideoUrl;
 
         public override int GetHashCode()
         {
index bd3c8f3..57e9b62 100644 (file)
@@ -150,8 +150,7 @@ namespace OpenTween
 
         private void DrawPlayableMark(PaintEventArgs pe)
         {
-            var thumb = this.Tag as ThumbnailInfo;
-            if (thumb == null || !thumb.IsPlayable) return;
+            if (!(this.Tag is ThumbnailInfo thumb && thumb.IsPlayable)) return;
             if (base.Image == base.InitialImage || base.Image == base.ErrorImage) return;
 
             var overlayImage = Properties.Resources.PlayableOverlayImage;
index 57e9f23..1f17f63 100644 (file)
@@ -109,15 +109,7 @@ namespace OpenTween
         }
 
         public TabModel SelectedTab
-        {
-            get
-            {
-                var item = this.TabList.SelectedItem as TabListItem;
-                if (item == null) return null;
-
-                return item.Tab;
-            }
-        }
+            => this.TabList.SelectedItem is TabListItem item ? item.Tab : null;
 
         public TabModel[] SelectedTabs
         {
index 7c372b5..d985d6e 100644 (file)
@@ -243,11 +243,8 @@ namespace OpenTween
 
         private void pictureBox_DoubleClick(object sender, EventArgs e)
         {
-            var thumb = ((PictureBox)sender).Tag as ThumbnailInfo;
-
-            if (thumb == null) return;
-
-            this.OpenImage(thumb);
+            if (((PictureBox)sender).Tag is ThumbnailInfo thumb)
+                this.OpenImage(thumb);
         }
 
         private void contextMenuStrip_Opening(object sender, CancelEventArgs e)