From: Kimura Youichi Date: Tue, 29 May 2018 01:35:52 +0000 (+0900) Subject: パターンマッチングを使用する (IDE0019) X-Git-Tag: OpenTween_v1.4.2~4^2~7 X-Git-Url: http://git.osdn.net/view?p=opentween%2Fopen-tween.git;a=commitdiff_plain;h=de796a48a0e87a10c2da1a292472224c724dd93e;hp=5f115593643876b15d61eab1f784af9f5a74dc88 パターンマッチングを使用する (IDE0019) --- diff --git a/OpenTween/Models/MediaInfo.cs b/OpenTween/Models/MediaInfo.cs index b9428506..0fea3f18 100644 --- a/OpenTween/Models/MediaInfo.cs +++ b/OpenTween/Models/MediaInfo.cs @@ -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() { diff --git a/OpenTween/OTPictureBox.cs b/OpenTween/OTPictureBox.cs index bd3c8f3c..57e9b62a 100644 --- a/OpenTween/OTPictureBox.cs +++ b/OpenTween/OTPictureBox.cs @@ -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; diff --git a/OpenTween/TabsDialog.cs b/OpenTween/TabsDialog.cs index 57e9f23f..1f17f63b 100644 --- a/OpenTween/TabsDialog.cs +++ b/OpenTween/TabsDialog.cs @@ -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 { diff --git a/OpenTween/TweetThumbnail.cs b/OpenTween/TweetThumbnail.cs index 7c372b57..d985d6e8 100644 --- a/OpenTween/TweetThumbnail.cs +++ b/OpenTween/TweetThumbnail.cs @@ -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)