refactor: update syntax

This commit is contained in:
Anna 2021-06-07 01:58:53 -04:00
parent 3ec1acb822
commit 033a9d2339
4 changed files with 7 additions and 8 deletions

View File

@ -4,7 +4,6 @@ using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Net.Sockets; using System.Net.Sockets;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Channels; using System.Threading.Channels;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -261,7 +260,7 @@ namespace XIVChat_Desktop {
Console.WriteLine(inner.StackTrace); Console.WriteLine(inner.StackTrace);
} }
}); });
if (!(ex.InnerException is CryptographicException)) { if (ex.InnerException is not CryptographicException) {
this.app.Disconnect(); this.app.Disconnect();
break; break;
} }

View File

@ -310,7 +310,7 @@ namespace XIVChat_Desktop {
// detect if scroller is at the bottom // detect if scroller is at the bottom
var scroller = this.FindElementByName<ScrollViewer>(this.Tabs, "scroller"); var scroller = this.FindElementByName<ScrollViewer>(this.Tabs, "scroller");
var verticalOffset = scroller!.VerticalOffset; var verticalOffset = scroller!.VerticalOffset;
var wasAtBottom = Math.Abs(verticalOffset - scroller.ScrollableHeight) < .0001; var wasAtBottom = Math.Abs(verticalOffset - scroller.ScrollableHeight) < .1;
// add message to main list // add message to main list
this.Messages.Add(message); this.Messages.Add(message);
@ -358,7 +358,7 @@ namespace XIVChat_Desktop {
} }
private void Input_Submit(object sender, KeyEventArgs e) { private void Input_Submit(object sender, KeyEventArgs e) {
if (!(sender is TextBox textBox)) { if (sender is not TextBox textBox) {
return; return;
} }

View File

@ -6,7 +6,7 @@ using System.Windows.Interop;
namespace XIVChat_Desktop { namespace XIVChat_Desktop {
public static class MaximiseHelper { public static class MaximiseHelper {
public static void FixMaximise(object? sender, EventArgs e) { public static void FixMaximise(object? sender, EventArgs e) {
if (!(sender is Window window)) { if (sender is not Window window) {
return; return;
} }

View File

@ -77,7 +77,7 @@ namespace XIVChat_Desktop {
public static bool IsWhitespace(this char c) { public static bool IsWhitespace(this char c) {
// 2.1 Characters and lines // 2.1 Characters and lines
// A whitespace character is a space(U + 0020), tab(U + 0009), newline(U + 000A), line tabulation (U + 000B), form feed (U + 000C), or carriage return (U + 000D). // A whitespace character is a space(U + 0020), tab(U + 0009), newline(U + 000A), line tabulation (U + 000B), form feed (U + 000C), or carriage return (U + 000D).
return c <= ' ' && (c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r'); return c is <= ' ' and (' ' or '\t' or '\n' or '\v' or '\f' or '\r');
} }
public static string? WorldName(ushort id) { public static string? WorldName(ushort id) {
@ -715,7 +715,7 @@ namespace XIVChat_Desktop {
public class RegexValidator : ValidationRule { public class RegexValidator : ValidationRule {
public override ValidationResult Validate(object value, CultureInfo cultureInfo) { public override ValidationResult Validate(object value, CultureInfo cultureInfo) {
if (!(value is string text)) { if (value is not string text) {
return new ValidationResult(false, "Value is not text."); return new ValidationResult(false, "Value is not text.");
} }
@ -728,7 +728,7 @@ namespace XIVChat_Desktop {
public class StringWrapper : INotifyPropertyChanged { public class StringWrapper : INotifyPropertyChanged {
private string value; private string value;
public String Value { public string Value {
get => this.value; get => this.value;
set { set {
this.value = value; this.value = value;