NewLife/X

代码整理,使用新的is语法
大石头 authored at 2021-08-02 16:12:51
130c7f1
Tree
1 Parent(s) 66869a8
Summary: 46 changed files with 122 additions and 146 deletions.
Modified +1 -1
Modified +3 -3
Modified +1 -1
Modified +2 -2
Modified +1 -1
Modified +2 -2
Modified +1 -1
Modified +1 -1
Modified +2 -2
Modified +12 -19
Modified +1 -1
Modified +1 -1
Modified +7 -11
Modified +1 -1
Modified +2 -2
Modified +1 -1
Modified +1 -1
Modified +1 -1
Modified +2 -2
Modified +2 -2
Modified +1 -1
Modified +1 -1
Modified +2 -2
Modified +1 -1
Modified +10 -10
Modified +1 -1
Modified +2 -2
Modified +1 -1
Modified +13 -13
Modified +1 -1
Modified +1 -1
Modified +1 -1
Modified +11 -18
Modified +1 -1
Modified +8 -10
Modified +1 -5
Modified +1 -1
Modified +1 -1
Modified +1 -1
Modified +1 -1
Modified +6 -6
Modified +1 -1
Modified +4 -4
Modified +1 -1
Modified +3 -3
Modified +2 -2
Modified +1 -1
diff --git a/NewLife.Core/Caching/Redis.cs b/NewLife.Core/Caching/Redis.cs
index 507b8ae..2a06d93 100644
--- a/NewLife.Core/Caching/Redis.cs
+++ b/NewLife.Core/Caching/Redis.cs
@@ -345,7 +345,7 @@ namespace NewLife.Caching
                 }
                 catch (Exception ex)
                 {
-                    if (ex is SocketException || ex is IOException)
+                    if (ex is SocketException or IOException)
                     {
                         // 销毁连接
                         client.TryDispose();
Modified +3 -3
diff --git a/NewLife.Core/Caching/RedisClient.cs b/NewLife.Core/Caching/RedisClient.cs
index 380e92e..8e13ba2 100644
--- a/NewLife.Core/Caching/RedisClient.cs
+++ b/NewLife.Core/Caching/RedisClient.cs
@@ -294,7 +294,7 @@ namespace NewLife.Caching
                     var str = ReadLine(ms);
                     log?.Append(str);
 
-                    if (header == '+' || header == ':')
+                    if (header is '+' or ':')
                         list.Add(str);
                     else if (header == '-')
                         throw new Exception(str);
@@ -403,7 +403,7 @@ namespace NewLife.Caching
                     var str = ReadLine(ms);
                     log?.Append(str);
 
-                    if (header == '+' || header == ':')
+                    if (header is '+' or ':')
                         list.Add(str);
                     else if (header == '-')
                         throw new Exception(str);
@@ -516,7 +516,7 @@ namespace NewLife.Caching
                 {
                     arr[i] = ReadPacket(ms, log);
                 }
-                else if (header == '+' || header == ':')
+                else if (header is '+' or ':')
                 {
                     arr[i] = ReadLine(ms);
                     log?.Append(arr[i]);
Modified +1 -1
diff --git a/NewLife.Core/Collections/BloomFilter.cs b/NewLife.Core/Collections/BloomFilter.cs
index fc487c4..64dcb9c 100644
--- a/NewLife.Core/Collections/BloomFilter.cs
+++ b/NewLife.Core/Collections/BloomFilter.cs
@@ -28,7 +28,7 @@ namespace NewLife.Collections
         /// <param name="fpp">期望的误判率。小于1</param>
         public BloomFilter(Int64 n, Double fpp)
         {
-            if (fpp <= 0 || fpp >= 1) fpp = 0.0001;
+            if (fpp is <= 0 or >= 1) fpp = 0.0001;
 
             // 根据Guava算法计算位数组大小
             _M = (Int32)(-n * Math.Log(fpp) / (Math.Log(2) * Math.Log(2)));
Modified +2 -2
diff --git a/NewLife.Core/Compression/ZipEntry.cs b/NewLife.Core/Compression/ZipEntry.cs
index c19dc49..eba4d69 100644
--- a/NewLife.Core/Compression/ZipEntry.cs
+++ b/NewLife.Core/Compression/ZipEntry.cs
@@ -149,7 +149,7 @@ namespace NewLife.Compression
             var v = reader.Read<UInt32>();
             if (v != ZipConstants.ZipEntrySignature)
             {
-                if (v != ZipConstants.ZipDirEntrySignature && v != ZipConstants.EndOfCentralDirectorySignature)
+                if (v is not ZipConstants.ZipDirEntrySignature and not ZipConstants.EndOfCentralDirectorySignature)
                     throw new ZipException("0x{0:X8}处签名错误!", stream.Position);
 
                 return null;
@@ -191,7 +191,7 @@ namespace NewLife.Compression
             var v = reader.Read<UInt32>();
             if (v != ZipConstants.ZipDirEntrySignature)
             {
-                if (v != ZipConstants.EndOfCentralDirectorySignature && v != ZipConstants.ZipEntrySignature)
+                if (v is not ZipConstants.EndOfCentralDirectorySignature and not ZipConstants.ZipEntrySignature)
                 {
                     throw new ZipException("0x{0:X8}处签名错误!", stream.Position);
                 }
Modified +1 -1
diff --git a/NewLife.Core/Configuration/IniConfigProvider.cs b/NewLife.Core/Configuration/IniConfigProvider.cs
index 5681abf..e5bcd41 100644
--- a/NewLife.Core/Configuration/IniConfigProvider.cs
+++ b/NewLife.Core/Configuration/IniConfigProvider.cs
@@ -35,7 +35,7 @@ namespace NewLife.Configuration
                 if (str.IsNullOrEmpty()) continue;
 
                 // 读取注释
-                if (str[0] == '#' || str[0] == ';')
+                if (str[0] is '#' or ';')
                 {
                     remark = str.TrimStart('#', ';').Trim();
                     continue;
Modified +2 -2
diff --git a/NewLife.Core/Configuration/XmlConfigProvider.cs b/NewLife.Core/Configuration/XmlConfigProvider.cs
index 00e61dd..9262bbd 100644
--- a/NewLife.Core/Configuration/XmlConfigProvider.cs
+++ b/NewLife.Core/Configuration/XmlConfigProvider.cs
@@ -54,7 +54,7 @@ namespace NewLife.Configuration
             {
                 var remark = "";
                 if (reader.NodeType == XmlNodeType.Comment) remark = reader.Value;
-                while (reader.NodeType == XmlNodeType.Comment || reader.NodeType == XmlNodeType.Whitespace) reader.Skip();
+                while (reader.NodeType is XmlNodeType.Comment or XmlNodeType.Whitespace) reader.Skip();
                 if (reader.NodeType != XmlNodeType.Element) break;
 
                 var name = reader.Name;
@@ -91,7 +91,7 @@ namespace NewLife.Configuration
                 while (reader.NodeType == XmlNodeType.Whitespace) reader.Skip();
 
                 // 遇到下一层节点
-                if (reader.NodeType == XmlNodeType.Element || reader.NodeType == XmlNodeType.Comment)
+                if (reader.NodeType is XmlNodeType.Element or XmlNodeType.Comment)
                     ReadNode(reader, cfg);
                 else if (reader.NodeType == XmlNodeType.Text)
                     cfg.Value = reader.ReadContentAsString();
Modified +1 -1
diff --git a/NewLife.Core/Extension/EnumHelper.cs b/NewLife.Core/Extension/EnumHelper.cs
index c68b52e..c7e7ad1 100644
--- a/NewLife.Core/Extension/EnumHelper.cs
+++ b/NewLife.Core/Extension/EnumHelper.cs
@@ -30,7 +30,7 @@ namespace NewLife
         /// <returns></returns>
         public static T Set<T>(this Enum source, T flag, Boolean value)
         {
-            if (!(source is T)) throw new ArgumentException("source", "枚举标识判断必须是相同的类型!");
+            if (source is not T) throw new ArgumentException("source", "枚举标识判断必须是相同的类型!");
 
             var s = Convert.ToUInt64(source);
             var f = Convert.ToUInt64(flag);
Modified +1 -1
diff --git a/NewLife.Core/Http/HttpCodec.cs b/NewLife.Core/Http/HttpCodec.cs
index 4dd3e30..32962d8 100644
--- a/NewLife.Core/Http/HttpCodec.cs
+++ b/NewLife.Core/Http/HttpCodec.cs
@@ -52,7 +52,7 @@ namespace NewLife.Http
 
             // 该连接第一包检查是否Http
             var ext = context.Owner as IExtend;
-            if (!(ext["Encoder"] is HttpEncoder))
+            if (ext["Encoder"] is not HttpEncoder)
             {
                 // 第一个请求必须是GET/POST,才执行后续操作
                 if (!isGet && !isPost) return base.Read(context, message);
Modified +2 -2
diff --git a/NewLife.Core/Http/TinyHttpClient.cs b/NewLife.Core/Http/TinyHttpClient.cs
index 7ec00be..4bb7cb0 100644
--- a/NewLife.Core/Http/TinyHttpClient.cs
+++ b/NewLife.Core/Http/TinyHttpClient.cs
@@ -186,7 +186,7 @@ namespace NewLife.Http
                 rs = ParseResponse(rs);
 
                 // 跳转
-                if (StatusCode == 301 || StatusCode == 302)
+                if (StatusCode is 301 or 302)
                 {
                     if (Headers.TryGetValue("Location", out var location) && !location.IsNullOrEmpty())
                     {
@@ -374,7 +374,7 @@ namespace NewLife.Http
                 rs = ParseResponse(rs);
 
                 // 跳转
-                if (StatusCode == 301 || StatusCode == 302)
+                if (StatusCode is 301 or 302)
                 {
                     if (Headers.TryGetValue("Location", out var location) && !location.IsNullOrEmpty())
                     {
Modified +12 -19
diff --git a/NewLife.Core/IO/EncodingHelper.cs b/NewLife.Core/IO/EncodingHelper.cs
index 7c7d9f2..2941f23 100644
--- a/NewLife.Core/IO/EncodingHelper.cs
+++ b/NewLife.Core/IO/EncodingHelper.cs
@@ -305,17 +305,10 @@ namespace NewLife.IO
         /// <returns></returns>
         static Boolean IsCommonASCII(Byte bt)
         {
-            if (bt == 0x0A // 回车
-                || bt == 0x0D // 换行
-                || bt == 0x09 // 制表符
-                || (bt >= 0x20 && bt <= 0x2F) // 符号
-                || (bt >= 0x30 && bt <= 0x39) // 数字
-                || (bt >= 0x3A && bt <= 0x40) // 符号
-                || (bt >= 0x41 && bt <= 0x5A) // 大写字母
-                || (bt >= 0x5B && bt <= 0x60) // 符号
-                || (bt >= 0x61 && bt <= 0x7A) // 小写字母
-                || (bt >= 0x7B && bt <= 0x7E) // 符号
-                )
+            if (bt is 0x0A // 回车
+                or 0x0D // 换行
+                or 0x09 // 制表符
+                or >= 0x20 and <= 0x2F or >= 0x30 and <= 0x39 or >= 0x3A and <= 0x40 or >= 0x41 and <= 0x5A or >= 0x5B and <= 0x60 or >= 0x61 and <= 0x7A or >= 0x7B and <= 0x7E)
                 return true;
             else
                 return false;
@@ -333,16 +326,16 @@ namespace NewLife.IO
                 var second = buf[pos + 1];
                 if (first == 0xC2)
                 {
-                    if (second == 0x81 || second == 0x8D || second == 0x8F || second == 0x90 || second == 0x9D || second >= 0xA0 && second <= 0xBF)
+                    if (second is 0x81 or 0x8D or 0x8F or 0x90 or 0x9D or >= 0xA0 and <= 0xBF)
                         return 2;
                 }
                 else if (first == 0xC3)
                 {
-                    if (second >= 0x80 && second <= 0xBF) return 2;
+                    if (second is >= 0x80 and <= 0xBF) return 2;
                 }
                 else if (first == 0xC5)
                 {
-                    if (second == 0x92 || second == 0x93 || second == 0xA0 || second == 0xA1 || second == 0xB8 || second == 0xBD || second == 0xBE)
+                    if (second is 0x92 or 0x93 or 0xA0 or 0xA1 or 0xB8 or 0xBD or 0xBE)
                         return 2;
                 }
                 else if (first == 0xC6)
@@ -351,20 +344,20 @@ namespace NewLife.IO
                 }
                 else if (first == 0xCB)
                 {
-                    if (second == 0x86 || second == 0x9C) return 2;
+                    if (second is 0x86 or 0x9C) return 2;
                 }
                 else if (buf.Length >= pos + 2 && first == 0xE2)
                 {
                     var three = buf[pos + 2];
                     if (second == 0x80)
                     {
-                        if (three == 0x93 || three == 0x94 || three == 0x98 || three == 0x99 || three == 0x9A)
+                        if (three is 0x93 or 0x94 or 0x98 or 0x99 or 0x9A)
                             return 3;
-                        if (three == 0x9C || three == 0x9D || three == 0x9E)
+                        if (three is 0x9C or 0x9D or 0x9E)
                             return 3;
-                        if (three == 0xA0 || three == 0xA1 || three == 0xA2)
+                        if (three is 0xA0 or 0xA1 or 0xA2)
                             return 3;
-                        if (three == 0xA6 || three == 0xB0 || three == 0xB9 || three == 0xBA)
+                        if (three is 0xA6 or 0xB0 or 0xB9 or 0xBA)
                             return 3;
                     }
                     else if (second == 0x82 && three == 0xAC || second == 0x84 && three == 0xA2)
Modified +1 -1
diff --git a/NewLife.Core/Log/LevelLog.cs b/NewLife.Core/Log/LevelLog.cs
index 9c5e373..75c85a5 100644
--- a/NewLife.Core/Log/LevelLog.cs
+++ b/NewLife.Core/Log/LevelLog.cs
@@ -15,7 +15,7 @@ namespace NewLife.Log
         {
             foreach (LogLevel item in Enum.GetValues(typeof(LogLevel)))
             {
-                if (item > LogLevel.All && item < LogLevel.Off)
+                if (item is > LogLevel.All and < LogLevel.Off)
                 {
                     _logs[item] = new TextFileLog(logPath, false, fileFormat) { Level = item };
                 }
Modified +1 -1
diff --git a/NewLife.Core/Net/NetUri.cs b/NewLife.Core/Net/NetUri.cs
index cb279df..1bb1223 100644
--- a/NewLife.Core/Net/NetUri.cs
+++ b/NewLife.Core/Net/NetUri.cs
@@ -221,7 +221,7 @@ namespace NewLife.Net
                 var hostAddresses = Dns.GetHostAddresses(hostname);
                 if (hostAddresses == null || hostAddresses.Length <= 0) return null;
 
-                return hostAddresses.Where(d => d.AddressFamily == AddressFamily.InterNetwork || d.AddressFamily == AddressFamily.InterNetworkV6).ToArray();
+                return hostAddresses.Where(d => d.AddressFamily is AddressFamily.InterNetwork or AddressFamily.InterNetworkV6).ToArray();
             }
             catch (SocketException ex)
             {
Modified +7 -11
diff --git a/NewLife.Core/Net/SocketHelper.cs b/NewLife.Core/Net/SocketHelper.cs
index 1691e5d..b0162c9 100644
--- a/NewLife.Core/Net/SocketHelper.cs
+++ b/NewLife.Core/Net/SocketHelper.cs
@@ -1,12 +1,12 @@
 using System;
-using NewLife.Reflection;
 using System.IO;
 using System.Net;
 using System.Net.Sockets;
 using System.Reflection;
+using System.Runtime.InteropServices;
 using System.Text;
 using System.Threading.Tasks;
-using System.Runtime.InteropServices;
+using NewLife.Reflection;
 
 namespace NewLife.Net
 {
@@ -199,11 +199,7 @@ namespace NewLife.Net
         /// <summary>Socket是否未被关闭</summary>
         /// <param name="se"></param>
         /// <returns></returns>
-        internal static Boolean IsNotClosed(this SocketAsyncEventArgs se)
-        {
-            return se.SocketError == SocketError.OperationAborted || se.SocketError == SocketError.Interrupted || se.SocketError == SocketError.NotSocket;
-
-        }
+        internal static Boolean IsNotClosed(this SocketAsyncEventArgs se) => se.SocketError is SocketError.OperationAborted or SocketError.Interrupted or SocketError.NotSocket;
 
         /// <summary>根据异步事件获取可输出异常,屏蔽常见异常</summary>
         /// <param name="se"></param>
@@ -212,10 +208,10 @@ namespace NewLife.Net
         {
             if (se == null) return null;
 
-            if (se.SocketError == SocketError.ConnectionReset ||
-                se.SocketError == SocketError.OperationAborted ||
-                se.SocketError == SocketError.Interrupted ||
-                se.SocketError == SocketError.NotSocket)
+            if (se.SocketError is SocketError.ConnectionReset or
+                SocketError.OperationAborted or
+                SocketError.Interrupted or
+                SocketError.NotSocket)
                 return null;
 
             var ex = se.ConnectByNameError;
Modified +1 -1
diff --git a/NewLife.Core/Net/TcpConnectionInformation2.cs b/NewLife.Core/Net/TcpConnectionInformation2.cs
index 77553b0..bb4ecac 100644
--- a/NewLife.Core/Net/TcpConnectionInformation2.cs
+++ b/NewLife.Core/Net/TcpConnectionInformation2.cs
@@ -112,7 +112,7 @@ namespace NewLife.Net
                 AF_INET,
                 TCP_TABLE_CLASS.TCP_TABLE_OWNER_PID_ALL,
                 0);
-            if (ret != 0 && ret != 122) // 122 insufficient buffer size
+            if (ret is not 0 and not 122) // 122 insufficient buffer size
                 throw new Exception("bad ret on check " + ret);
             var buffTable = Marshal.AllocHGlobal(buffSize);
 
Modified +2 -2
diff --git a/NewLife.Core/Net/UdpServer.cs b/NewLife.Core/Net/UdpServer.cs
index eb59db4..a46aa26 100644
--- a/NewLife.Core/Net/UdpServer.cs
+++ b/NewLife.Core/Net/UdpServer.cs
@@ -238,8 +238,8 @@ namespace NewLife.Net
 
             // Udp服务器不能关闭自己,但是要关闭会话
             // Udp客户端一般不关闭自己
-            if (se.SocketError != SocketError.ConnectionReset &&
-                se.SocketError != SocketError.ConnectionAborted
+            if (se.SocketError is not SocketError.ConnectionReset and
+                not SocketError.ConnectionAborted
                 ) return true;
 
             // 关闭相应会话
Modified +1 -1
diff --git a/NewLife.Core/Reflection/OrcasNamer.cs b/NewLife.Core/Reflection/OrcasNamer.cs
index fd86b53..0096217 100644
--- a/NewLife.Core/Reflection/OrcasNamer.cs
+++ b/NewLife.Core/Reflection/OrcasNamer.cs
@@ -136,7 +136,7 @@ namespace NewLife.Reflection
             }
             WriteParameters(method.GetParameters(), writer);
             // add ~ for conversion operators
-            if ((name == "op_Implicit") || (name == "op_Explicit"))
+            if (name is "op_Implicit" or "op_Explicit")
             {
                 writer.Write("~");
                 WriteType(method.ReturnType, writer);
Modified +1 -1
diff --git a/NewLife.Core/Reflection/ScriptEngine.cs b/NewLife.Core/Reflection/ScriptEngine.cs
index 94fa55f..d925a95 100644
--- a/NewLife.Core/Reflection/ScriptEngine.cs
+++ b/NewLife.Core/Reflection/ScriptEngine.cs
@@ -257,7 +257,7 @@ namespace NewLife.Reflection
                 {
                     // 如果不是;和}结尾,则增加分号
                     var last = code[code.Length - 1];
-                    if (last != ';' && last != '}') code += ";";
+                    if (last is not ';' and not '}') code += ";";
                 }
                 code = $"\t\tstatic void Main()\r\n\t\t{{\r\n\t\t\t{code}\r\n\t\t}}";
             }
Modified +1 -1
diff --git a/NewLife.Core/Remoting/ApiClient.cs b/NewLife.Core/Remoting/ApiClient.cs
index 5083fb9..ab41066 100644
--- a/NewLife.Core/Remoting/ApiClient.cs
+++ b/NewLife.Core/Remoting/ApiClient.cs
@@ -279,7 +279,7 @@ namespace NewLife.Remoting
             if (!enc.Decode(rs, out _, out var code, out var data)) throw new InvalidOperationException();
 
             // 是否成功
-            if (code != 0 && code != 200) throw new ApiException(code, data.ToStr()?.Trim('\"')) { Source = invoker + "/" + action };
+            if (code is not 0 and not 200) throw new ApiException(code, data.ToStr()?.Trim('\"')) { Source = invoker + "/" + action };
 
             if (data == null) return default;
             if (resultType == typeof(Packet)) return (TResult)(Object)data;
Modified +2 -2
diff --git a/NewLife.Core/Remoting/ApiHelper.cs b/NewLife.Core/Remoting/ApiHelper.cs
index 1b19b6d..032c55d 100644
--- a/NewLife.Core/Remoting/ApiHelper.cs
+++ b/NewLife.Core/Remoting/ApiHelper.cs
@@ -234,7 +234,7 @@ namespace NewLife.Remoting
                     break;
                 }
             }
-            if (code != 0 && code != 200)
+            if (code is not 0 and not 200)
             {
                 var message = "";
                 foreach (var item in MessageNames)
@@ -259,7 +259,7 @@ namespace NewLife.Remoting
             // 反序列化
             if (data == null) return default;
 
-            if (!(data is IDictionary<String, Object>) && !(data is IList<Object>)) throw new InvalidDataException("未识别响应数据");
+            if (data is not IDictionary<String, Object> and not IList<Object>) throw new InvalidDataException("未识别响应数据");
 
             return JsonHelper.Convert<TResult>(data);
         }
Modified +2 -2
diff --git a/NewLife.Core/Remoting/ApiHttpClient.cs b/NewLife.Core/Remoting/ApiHttpClient.cs
index e7dfd14..9314d13 100644
--- a/NewLife.Core/Remoting/ApiHttpClient.cs
+++ b/NewLife.Core/Remoting/ApiHttpClient.cs
@@ -216,7 +216,7 @@ namespace NewLife.Remoting
                         ex.Source = _currentService?.Address + "/" + action;
                         throw;
                     }
-                    else if (ex is HttpRequestException || ex is TaskCanceledException)
+                    else if (ex is HttpRequestException or TaskCanceledException)
                     {
                         if (filter != null) await filter.OnError(_currentService?.Client, ex, this);
                         if (++i >= svrs.Count) throw;
@@ -389,7 +389,7 @@ namespace NewLife.Remoting
             var ex = error;
             while (ex is AggregateException age) ex = age.InnerException;
 
-            if (ex is HttpRequestException || ex is TaskCanceledException)
+            if (ex is HttpRequestException or TaskCanceledException)
             {
                 // 网络异常时,自动切换到其它节点
                 _idxServer++;
Modified +1 -1
diff --git a/NewLife.Core/Serialization/Binary/Binary.cs b/NewLife.Core/Serialization/Binary/Binary.cs
index 04b6f1e..8c54280 100644
--- a/NewLife.Core/Serialization/Binary/Binary.cs
+++ b/NewLife.Core/Serialization/Binary/Binary.cs
@@ -383,7 +383,7 @@ namespace NewLife.Serialization
         public virtual void EnableTrace()
         {
             var stream = Stream;
-            if (stream == null || stream is TraceStream) return;
+            if (stream is null or TraceStream) return;
 
             Stream = new TraceStream(stream) { Encoding = Encoding, IsLittleEndian = IsLittleEndian };
         }
Modified +1 -1
diff --git a/NewLife.Core/Serialization/Binary/FieldSizeAttribute.cs b/NewLife.Core/Serialization/Binary/FieldSizeAttribute.cs
index 4c5896d..0b895ff 100644
--- a/NewLife.Core/Serialization/Binary/FieldSizeAttribute.cs
+++ b/NewLife.Core/Serialization/Binary/FieldSizeAttribute.cs
@@ -80,7 +80,7 @@ namespace NewLife.Serialization
 
             // 目标字段必须是整型
             var tc = Type.GetTypeCode(type);
-            if (tc >= TypeCode.SByte && tc <= TypeCode.UInt64) return mi;
+            if (tc is >= TypeCode.SByte and <= TypeCode.UInt64) return mi;
 
             return null;
         }
Modified +2 -2
diff --git a/NewLife.Core/Serialization/Json/IJsonHost.cs b/NewLife.Core/Serialization/Json/IJsonHost.cs
index 596b20e..90c1c97 100644
--- a/NewLife.Core/Serialization/Json/IJsonHost.cs
+++ b/NewLife.Core/Serialization/Json/IJsonHost.cs
@@ -114,13 +114,13 @@ namespace NewLife.Serialization
                             sb.Append("\r\n");
                             sb.Append(' ', indentation * 2);
                         }
-                        else if (ch == '[' || ch == '{')
+                        else if (ch is '[' or '{')
                         {
                             sb.Append(ch);
                             sb.Append("\r\n");
                             sb.Append(' ', ++indentation * 2);
                         }
-                        else if (ch == ']' || ch == '}')
+                        else if (ch is ']' or '}')
                         {
                             sb.Append("\r\n");
                             sb.Append(' ', --indentation * 2);
Modified +1 -1
diff --git a/NewLife.Core/Serialization/Json/JsonReader.cs b/NewLife.Core/Serialization/Json/JsonReader.cs
index cbeaefe..e394c96 100644
--- a/NewLife.Core/Serialization/Json/JsonReader.cs
+++ b/NewLife.Core/Serialization/Json/JsonReader.cs
@@ -318,7 +318,7 @@ namespace NewLife.Serialization
         private DateTime CreateDateTime(Object value)
         {
             if (value is DateTime) return (DateTime)value;
-            if (value is Int64 || value is Int32)
+            if (value is Int64 or Int32)
             {
                 var dt = value.ToDateTime();
                 if (UseUTCDateTime) dt = dt.ToUniversalTime();
Modified +10 -10
diff --git a/NewLife.Core/Serialization/Json/JsonWriter.cs b/NewLife.Core/Serialization/Json/JsonWriter.cs
index c389bfe..8745813 100644
--- a/NewLife.Core/Serialization/Json/JsonWriter.cs
+++ b/NewLife.Core/Serialization/Json/JsonWriter.cs
@@ -95,10 +95,10 @@ namespace NewLife.Serialization
 
         private void WriteValue(Object obj)
         {
-            if (obj == null || obj is DBNull)
+            if (obj is null or DBNull)
                 _Builder.Append("null");
 
-            else if (obj is String || obj is Char)
+            else if (obj is String or Char)
                 WriteString(obj + "");
 
             else if (obj is Guid)
@@ -108,11 +108,11 @@ namespace NewLife.Serialization
                 _Builder.Append((obj + "").ToLower());
 
             else if (
-                obj is Int32 || obj is Int64 || obj is Double ||
-                obj is Decimal || obj is Single ||
-                obj is Byte || obj is Int16 ||
-                obj is SByte || obj is UInt16 ||
-                obj is UInt32 || obj is UInt64
+                obj is Int32 or Int64 or Double or
+                Decimal or Single or
+                Byte or Int16 or
+                SByte or UInt16 or
+                UInt32 or UInt64
             )
                 _Builder.Append(((IConvertible)obj).ToString(NumberFormatInfo.InvariantInfo));
 
@@ -534,7 +534,7 @@ namespace NewLife.Serialization
             {
                 var c = str[index];
 
-                if (c != '\t' && c != '\n' && c != '\r' && c != '\"' && c != '\\')// && c != ':' && c!=',')
+                if (c is not '\t' and not '\n' and not '\r' and not '\"' and not '\\')// && c != ':' && c!=',')
                 {
                     if (idx == -1) idx = index;
 
@@ -586,11 +586,11 @@ namespace NewLife.Serialization
         private static IDictionary<TypeCode, Object> _def;
         private static Boolean IsNull(Object obj)
         {
-            if (obj == null || obj is DBNull) return true;
+            if (obj is null or DBNull) return true;
 
             var code = obj.GetType().GetTypeCode();
             if (code == TypeCode.Object) return false;
-            if (code == TypeCode.Empty || code == TypeCode.DBNull) return true;
+            if (code is TypeCode.Empty or TypeCode.DBNull) return true;
 
             var dic = _def;
             if (dic == null)
Modified +1 -1
diff --git a/NewLife.Core/Serialization/Xml/Xml.cs b/NewLife.Core/Serialization/Xml/Xml.cs
index c359eb4..01111ad 100644
--- a/NewLife.Core/Serialization/Xml/Xml.cs
+++ b/NewLife.Core/Serialization/Xml/Xml.cs
@@ -286,7 +286,7 @@ namespace NewLife.Serialization
             else
                 reader.ReadStartElement();
 
-            while (reader.NodeType == XmlNodeType.Comment || reader.NodeType == XmlNodeType.Whitespace) reader.Skip();
+            while (reader.NodeType is XmlNodeType.Comment or XmlNodeType.Whitespace) reader.Skip();
         }
 
         /// <summary>读取结束</summary>
Modified +2 -2
diff --git a/NewLife.Core/Serialization/Xml/XmlParser.cs b/NewLife.Core/Serialization/Xml/XmlParser.cs
index dc4917c..f218995 100644
--- a/NewLife.Core/Serialization/Xml/XmlParser.cs
+++ b/NewLife.Core/Serialization/Xml/XmlParser.cs
@@ -52,7 +52,7 @@ namespace NewLife.Serialization
 
             while (true)
             {
-                while (reader.NodeType == XmlNodeType.Comment || reader.NodeType == XmlNodeType.Whitespace) reader.Skip();
+                while (reader.NodeType is XmlNodeType.Comment or XmlNodeType.Whitespace) reader.Skip();
                 if (reader.NodeType != XmlNodeType.Element) break;
 
                 var name = reader.Name;
@@ -72,7 +72,7 @@ namespace NewLife.Serialization
 
                 // 遇到下一层节点
                 Object val = null;
-                if (reader.NodeType == XmlNodeType.Element || reader.NodeType == XmlNodeType.Comment)
+                if (reader.NodeType is XmlNodeType.Element or XmlNodeType.Comment)
                     val = ParseObject();
                 else if (reader.NodeType == XmlNodeType.Text)
                     val = reader.ReadContentAsString();
Modified +1 -1
diff --git a/NewLife.Core/Threading/Cron.cs b/NewLife.Core/Threading/Cron.cs
index 9fc26a3..448a75e 100644
--- a/NewLife.Core/Threading/Cron.cs
+++ b/NewLife.Core/Threading/Cron.cs
@@ -137,7 +137,7 @@ namespace NewLife.Threading
 
             // 连续范围
             var s = start;
-            if (value == "*" || value == "?")
+            if (value is "*" or "?")
                 s = 0;
             else if ((p = value.IndexOf('-')) > 0)
             {
Modified +13 -13
diff --git a/Test/BigInteger.cs b/Test/BigInteger.cs
index 41bc267..9dbe3ca 100644
--- a/Test/BigInteger.cs
+++ b/Test/BigInteger.cs
@@ -298,9 +298,9 @@ public class BigInteger
                 {
                         int posVal = value[i];
 
-                        if(posVal >= '0' && posVal <= '9')
+                        if(posVal is >= '0' and <= '9')
                                 posVal -= '0';
-                        else if(posVal >= 'A' && posVal <= 'Z')
+                        else if(posVal is >= 'A' and <= 'Z')
                                 posVal = (posVal - 'A') + 10;
                         else
                                 posVal = 9999999;       // arbitrary large
@@ -1475,7 +1475,7 @@ public class BigInteger
 
         public string ToString(int radix)
         {
-                if(radix < 2 || radix > 36)
+                if(radix is < 2 or > 36)
                         throw (new ArgumentException("Radix must be >= 2 and <= 36"));
 
                 string charSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
@@ -1840,9 +1840,9 @@ public class BigInteger
                 if(thisVal.dataLength == 1)
                 {
                         // test small numbers
-                        if(thisVal.data[0] == 0 || thisVal.data[0] == 1)
+                        if(thisVal.data[0] is 0 or 1)
                                 return false;
-                        else if(thisVal.data[0] == 2 || thisVal.data[0] == 3)
+                        else if(thisVal.data[0] is 2 or 3)
                                 return true;
                 }
 
@@ -1930,9 +1930,9 @@ public class BigInteger
                 if(thisVal.dataLength == 1)
                 {
                         // test small numbers
-                        if(thisVal.data[0] == 0 || thisVal.data[0] == 1)
+                        if(thisVal.data[0] is 0 or 1)
                                 return false;
-                        else if(thisVal.data[0] == 2 || thisVal.data[0] == 3)
+                        else if(thisVal.data[0] is 2 or 3)
                                 return true;
                 }
 
@@ -2055,9 +2055,9 @@ public class BigInteger
                 if(thisVal.dataLength == 1)
                 {
                         // test small numbers
-                        if(thisVal.data[0] == 0 || thisVal.data[0] == 1)
+                        if(thisVal.data[0] is 0 or 1)
                                 return false;
-                        else if(thisVal.data[0] == 2 || thisVal.data[0] == 3)
+                        else if(thisVal.data[0] is 2 or 3)
                                 return true;
                 }
 
@@ -2144,9 +2144,9 @@ public class BigInteger
                 if(thisVal.dataLength == 1)
                 {
                         // test small numbers
-                        if(thisVal.data[0] == 0 || thisVal.data[0] == 1)
+                        if(thisVal.data[0] is 0 or 1)
                                 return false;
-                        else if(thisVal.data[0] == 2 || thisVal.data[0] == 3)
+                        else if(thisVal.data[0] is 2 or 3)
                                 return true;
                 }
 
@@ -2365,9 +2365,9 @@ public class BigInteger
                 if(thisVal.dataLength == 1)
                 {
                         // test small numbers
-                        if(thisVal.data[0] == 0 || thisVal.data[0] == 1)
+                        if(thisVal.data[0] is 0 or 1)
                                 return false;
-                        else if(thisVal.data[0] == 2 || thisVal.data[0] == 3)
+                        else if(thisVal.data[0] is 2 or 3)
                                 return true;
                 }
 
Modified +1 -1
diff --git a/XCode/Cache/DbCache.cs b/XCode/Cache/DbCache.cs
index 46c3158..6a1a778 100644
--- a/XCode/Cache/DbCache.cs
+++ b/XCode/Cache/DbCache.cs
@@ -36,7 +36,7 @@ namespace NewLife.Caching
         public DbCache(IEntityFactory factory = null, String keyName = null, String timeName = null)
         {
             if (factory == null) factory = MyDbCache.Meta.Factory;
-            if (!(factory.Default is IDbCache)) throw new XCodeException("实体类[{0}]需要实现[{1}]接口", factory.EntityType.FullName, typeof(IDbCache).FullName);
+            if (factory.Default is not IDbCache) throw new XCodeException("实体类[{0}]需要实现[{1}]接口", factory.EntityType.FullName, typeof(IDbCache).FullName);
 
             var name = factory.EntityType.Name;
 
Modified +1 -1
diff --git a/XCode/DataAccessLayer/Common/DbBase.cs b/XCode/DataAccessLayer/Common/DbBase.cs
index b9479cb..fb34238 100644
--- a/XCode/DataAccessLayer/Common/DbBase.cs
+++ b/XCode/DataAccessLayer/Common/DbBase.cs
@@ -909,7 +909,7 @@ namespace XCode.DataAccessLayer
                     // 可空类型
                     type = Nullable.GetUnderlyingType(type) ?? type;
 
-                    if (value != null && !(value is IList)) value = value.ChangeType(type);
+                    if (value is not null and not IList) value = value.ChangeType(type);
                 }
 
                 // 写入数据类型
Modified +1 -1
diff --git a/XCode/DataAccessLayer/DAL_Setting.cs b/XCode/DataAccessLayer/DAL_Setting.cs
index 07d7734..d0a96cf 100644
--- a/XCode/DataAccessLayer/DAL_Setting.cs
+++ b/XCode/DataAccessLayer/DAL_Setting.cs
@@ -81,7 +81,7 @@ namespace XCode.DataAccessLayer
         {
             get
             {
-                if (DbType == DatabaseType.MySql || DbType == DatabaseType.Oracle || DbType == DatabaseType.SQLite) return true;
+                if (DbType is DatabaseType.MySql or DatabaseType.Oracle or DatabaseType.SQLite) return true;
 
                 //#if !__CORE__
                 // SqlServer对批处理有BUG,将在3.0中修复
Modified +11 -18
diff --git a/XCode/DataAccessLayer/Database/MySql.cs b/XCode/DataAccessLayer/Database/MySql.cs
index 26496dc..1aa0322 100644
--- a/XCode/DataAccessLayer/Database/MySql.cs
+++ b/XCode/DataAccessLayer/Database/MySql.cs
@@ -11,7 +11,7 @@ using NewLife.Data;
 
 namespace XCode.DataAccessLayer
 {
-    class MySql : RemoteDb
+    internal class MySql : RemoteDb
     {
         #region 属性
         /// <summary>返回数据库类型。</summary>
@@ -39,11 +39,12 @@ namespace XCode.DataAccessLayer
             }
         }
 
-        const String Server_Key = "Server";
-        const String CharSet = "CharSet";
+        private const String Server_Key = "Server";
+        private const String CharSet = "CharSet";
+
         //const String AllowZeroDatetime = "Allow Zero Datetime";
-        const String MaxPoolSize = "MaxPoolSize";
-        const String Sslmode = "Sslmode";
+        private const String MaxPoolSize = "MaxPoolSize";
+        private const String Sslmode = "Sslmode";
         protected override void OnSetConnectionString(ConnectionStringBuilder builder)
         {
             base.OnSetConnectionString(builder);
@@ -147,14 +148,8 @@ namespace XCode.DataAccessLayer
         #endregion
 
         #region 数据库特性
-        protected override String ReservedWordsStr
-        {
-            get
-            {
-                return "ACCESSIBLE,ADD,ALL,ALTER,ANALYZE,AND,AS,ASC,ASENSITIVE,BEFORE,BETWEEN,BIGINT,BINARY,BLOB,BOTH,BY,CALL,CASCADE,CASE,CHANGE,CHAR,CHARACTER,CHECK,COLLATE,COLUMN,CONDITION,CONNECTION,CONSTRAINT,CONTINUE,CONTRIBUTORS,CONVERT,CREATE,CROSS,CURRENT_DATE,CURRENT_TIME,CURRENT_TIMESTAMP,CURRENT_USER,CURSOR,DATABASE,DATABASES,DAY_HOUR,DAY_MICROSECOND,DAY_MINUTE,DAY_SECOND,DEC,DECIMAL,DECLARE,DEFAULT,DELAYED,DELETE,DESC,DESCRIBE,DETERMINISTIC,DISTINCT,DISTINCTROW,DIV,DOUBLE,DROP,DUAL,EACH,ELSE,ELSEIF,ENCLOSED,ESCAPED,EXISTS,EXIT,EXPLAIN,FALSE,FETCH,FLOAT,FLOAT4,FLOAT8,FOR,FORCE,FOREIGN,FROM,FULLTEXT,GRANT,GROUP,HAVING,HIGH_PRIORITY,HOUR_MICROSECOND,HOUR_MINUTE,HOUR_SECOND,IF,IGNORE,IN,INDEX,INFILE,INNER,INOUT,INSENSITIVE,INSERT,INT,INT1,INT2,INT3,INT4,INT8,INTEGER,INTERVAL,INTO,IS,ITERATE,JOIN,KEY,KEYS,KILL,LEADING,LEAVE,LEFT,LIKE,LIMIT,LINEAR,LINES,LOAD,LOCALTIME,LOCALTIMESTAMP,LOCK,LONG,LONGBLOB,LONGTEXT,LOOP,LOW_PRIORITY,MATCH,MEDIUMBLOB,MEDIUMINT,MEDIUMTEXT,MIDDLEINT,MINUTE_MICROSECOND,MINUTE_SECOND,MOD,MODIFIES,NATURAL,NOT,NO_WRITE_TO_BINLOG,NULL,NUMERIC,ON,OPTIMIZE,OPTION,OPTIONALLY,OR,ORDER,OUT,OUTER,OUTFILE,PRECISION,PRIMARY,PROCEDURE,PURGE,RANGE,READ,READS,READ_ONLY,READ_WRITE,REAL,REFERENCES,REGEXP,RELEASE,RENAME,REPEAT,REPLACE,REQUIRE,RESTRICT,RETURN,REVOKE,RIGHT,RLIKE,SCHEMA,SCHEMAS,SECOND_MICROSECOND,SELECT,SENSITIVE,SEPARATOR,SET,SHOW,SMALLINT,SPATIAL,SPECIFIC,SQL,SQLEXCEPTION,SQLSTATE,SQLWARNING,SQL_BIG_RESULT,SQL_CALC_FOUND_ROWS,SQL_SMALL_RESULT,SSL,STARTING,STRAIGHT_JOIN,TABLE,TERMINATED,THEN,TINYBLOB,TINYINT,TINYTEXT,TO,TRAILING,TRIGGER,TRUE,UNDO,UNION,UNIQUE,UNLOCK,UNSIGNED,UPDATE,UPGRADE,USAGE,USE,USING,UTC_DATE,UTC_TIME,UTC_TIMESTAMP,VALUES,VARBINARY,VARCHAR,VARCHARACTER,VARYING,WHEN,WHERE,WHILE,WITH,WRITE,X509,XOR,YEAR_MONTH,ZEROFILL," +
+        protected override String ReservedWordsStr => "ACCESSIBLE,ADD,ALL,ALTER,ANALYZE,AND,AS,ASC,ASENSITIVE,BEFORE,BETWEEN,BIGINT,BINARY,BLOB,BOTH,BY,CALL,CASCADE,CASE,CHANGE,CHAR,CHARACTER,CHECK,COLLATE,COLUMN,CONDITION,CONNECTION,CONSTRAINT,CONTINUE,CONTRIBUTORS,CONVERT,CREATE,CROSS,CURRENT_DATE,CURRENT_TIME,CURRENT_TIMESTAMP,CURRENT_USER,CURSOR,DATABASE,DATABASES,DAY_HOUR,DAY_MICROSECOND,DAY_MINUTE,DAY_SECOND,DEC,DECIMAL,DECLARE,DEFAULT,DELAYED,DELETE,DESC,DESCRIBE,DETERMINISTIC,DISTINCT,DISTINCTROW,DIV,DOUBLE,DROP,DUAL,EACH,ELSE,ELSEIF,ENCLOSED,ESCAPED,EXISTS,EXIT,EXPLAIN,FALSE,FETCH,FLOAT,FLOAT4,FLOAT8,FOR,FORCE,FOREIGN,FROM,FULLTEXT,GRANT,GROUP,HAVING,HIGH_PRIORITY,HOUR_MICROSECOND,HOUR_MINUTE,HOUR_SECOND,IF,IGNORE,IN,INDEX,INFILE,INNER,INOUT,INSENSITIVE,INSERT,INT,INT1,INT2,INT3,INT4,INT8,INTEGER,INTERVAL,INTO,IS,ITERATE,JOIN,KEY,KEYS,KILL,LEADING,LEAVE,LEFT,LIKE,LIMIT,LINEAR,LINES,LOAD,LOCALTIME,LOCALTIMESTAMP,LOCK,LONG,LONGBLOB,LONGTEXT,LOOP,LOW_PRIORITY,MATCH,MEDIUMBLOB,MEDIUMINT,MEDIUMTEXT,MIDDLEINT,MINUTE_MICROSECOND,MINUTE_SECOND,MOD,MODIFIES,NATURAL,NOT,NO_WRITE_TO_BINLOG,NULL,NUMERIC,ON,OPTIMIZE,OPTION,OPTIONALLY,OR,ORDER,OUT,OUTER,OUTFILE,PRECISION,PRIMARY,PROCEDURE,PURGE,RANGE,READ,READS,READ_ONLY,READ_WRITE,REAL,REFERENCES,REGEXP,RELEASE,RENAME,REPEAT,REPLACE,REQUIRE,RESTRICT,RETURN,REVOKE,RIGHT,RLIKE,SCHEMA,SCHEMAS,SECOND_MICROSECOND,SELECT,SENSITIVE,SEPARATOR,SET,SHOW,SMALLINT,SPATIAL,SPECIFIC,SQL,SQLEXCEPTION,SQLSTATE,SQLWARNING,SQL_BIG_RESULT,SQL_CALC_FOUND_ROWS,SQL_SMALL_RESULT,SSL,STARTING,STRAIGHT_JOIN,TABLE,TERMINATED,THEN,TINYBLOB,TINYINT,TINYTEXT,TO,TRAILING,TRIGGER,TRUE,UNDO,UNION,UNIQUE,UNLOCK,UNSIGNED,UPDATE,UPGRADE,USAGE,USE,USING,UTC_DATE,UTC_TIME,UTC_TIMESTAMP,VALUES,VARBINARY,VARCHAR,VARCHARACTER,VARYING,WHEN,WHERE,WHILE,WITH,WRITE,X509,XOR,YEAR_MONTH,ZEROFILL," +
                     "LOG,User,Role,Admin,Rank,Member";
-            }
-        }
 
         /// <summary>格式化关键字</summary>
         /// <param name="keyWord">关键字</param>
@@ -451,7 +446,7 @@ namespace XCode.DataAccessLayer
     }
 
     /// <summary>MySql元数据</summary>
-    class MySqlMetaData : RemoteDbMetaData
+    internal class MySqlMetaData : RemoteDbMetaData
     {
         public MySqlMetaData() => Types = _DataTypes;
 
@@ -544,7 +539,7 @@ namespace XCode.DataAccessLayer
                         }
 
                         // MySql中没有布尔型,这里处理YN枚举作为布尔型
-                        if (field.RawType == "enum('N','Y')" || field.RawType == "enum('Y','N')") field.DataType = typeof(Boolean);
+                        if (field.RawType is "enum('N','Y')" or "enum('Y','N')") field.DataType = typeof(Boolean);
 
                         field.Fix();
 
@@ -669,11 +664,9 @@ namespace XCode.DataAccessLayer
 
         public override String AlterColumnSQL(IDataColumn field, IDataColumn oldfield) => $"Alter Table {FormatName(field.Table)} Modify Column {FieldClause(field, false)}";
 
-        public override String AddColumnDescriptionSQL(IDataColumn field)
-        {
+        public override String AddColumnDescriptionSQL(IDataColumn field) =>
             // 返回String.Empty表示已经在别的SQL中处理
-            return String.Empty;
-        }
+            String.Empty;
         #endregion
     }
 }
Modified +1 -1
diff --git a/XCode/DataAccessLayer/Database/PostgreSQL.cs b/XCode/DataAccessLayer/Database/PostgreSQL.cs
index fb30317..2babd89 100644
--- a/XCode/DataAccessLayer/Database/PostgreSQL.cs
+++ b/XCode/DataAccessLayer/Database/PostgreSQL.cs
@@ -375,7 +375,7 @@ namespace XCode.DataAccessLayer
             if (field.RawType == "enum")
             {
                 // PostgreSQL中没有布尔型,这里处理YN枚举作为布尔型
-                if (field.RawType == "enum('N','Y')" || field.RawType == "enum('Y','N')")
+                if (field.RawType is "enum('N','Y')" or "enum('Y','N')")
                 {
                     field.DataType = typeof(Boolean);
                     //// 处理默认值
Modified +8 -10
diff --git a/XCode/DataAccessLayer/Model/ModelHelper.cs b/XCode/DataAccessLayer/Model/ModelHelper.cs
index fa7b1d8..997a300 100644
--- a/XCode/DataAccessLayer/Model/ModelHelper.cs
+++ b/XCode/DataAccessLayer/Model/ModelHelper.cs
@@ -101,7 +101,7 @@ namespace XCode.DataAccessLayer
             return name.EqualIgnoreCase(column.ColumnName, column.Name);
         }
 
-        static Boolean EqualIgnoreCase(this String[] src, String[] des)
+        private static Boolean EqualIgnoreCase(this String[] src, String[] des)
         {
             if (src == null || src.Length == 0) return des == null || des.Length == 0;
             if (des == null || des.Length == 0) return false;
@@ -424,7 +424,7 @@ namespace XCode.DataAccessLayer
                     value.SetValue(pi, v.ChangeType(pi.PropertyType));
             }
             var pi1 = pis.FirstOrDefault(e => e.Name == "Name");
-            var pi2 = pis.FirstOrDefault(e => e.Name == "TableName" || e.Name == "ColumnName");
+            var pi2 = pis.FirstOrDefault(e => e.Name is "TableName" or "ColumnName");
             if (pi1 != null && pi2 != null)
             {
                 // 写入的时候省略了相同的TableName/ColumnName
@@ -455,7 +455,7 @@ namespace XCode.DataAccessLayer
             // 剩余特性作为扩展属性
             if (reader.MoveToFirstAttribute())
             {
-                if (value is IDataTable || value is IDataColumn)
+                if (value is IDataTable or IDataColumn)
                 {
                     var dic = (value is IDataTable) ? (value as IDataTable).Properties : (value as IDataColumn).Properties;
                     do
@@ -527,7 +527,7 @@ namespace XCode.DataAccessLayer
                     // 改为区分大小写,避免linux环境下 mysql 数据库存在
                     if (pi.Name == "Name")
                         name = (String)obj;
-                    else if (pi.Name == "TableName" || pi.Name == "ColumnName")
+                    else if (pi.Name is "TableName" or "ColumnName")
                     {
                         if (name == (String)obj) continue;
                         if (/*ignoreNameCase &&*/ name.EqualIgnoreCase((String)obj)) continue;
@@ -589,11 +589,9 @@ namespace XCode.DataAccessLayer
             }
         }
 
-        static readonly ConcurrentDictionary<Type, Object> cache = new();
-        static Object GetDefault(Type type)
-        {
-            return cache.GetOrAdd(type, item => item.CreateInstance());
-        }
+        private static readonly ConcurrentDictionary<Type, Object> cache = new();
+
+        private static Object GetDefault(Type type) => cache.GetOrAdd(type, item => item.CreateInstance());
         #endregion
 
         #region 修正连接
@@ -601,7 +599,7 @@ namespace XCode.DataAccessLayer
         /// <param name="dc"></param>
         /// <param name="oridc"></param>
         /// <returns></returns>
-        static IDataColumn FixDefaultByType(this IDataColumn dc, IDataColumn oridc)
+        private static IDataColumn FixDefaultByType(this IDataColumn dc, IDataColumn oridc)
         {
             if (dc?.DataType == null) return dc;
 
Modified +1 -5
diff --git a/XCode/DataAccessLayer/Model/XTable.cs b/XCode/DataAccessLayer/Model/XTable.cs
index f3c1f83..929acea 100644
--- a/XCode/DataAccessLayer/Model/XTable.cs
+++ b/XCode/DataAccessLayer/Model/XTable.cs
@@ -166,11 +166,7 @@ namespace XCode.DataAccessLayer
 
         /// <summary>初始化</summary>
         /// <param name="name">名称</param>
-        public XTable(String name)
-            : this()
-        {
-            TableName = name;
-        }
+        public XTable(String name) : this() => TableName = name;
         #endregion
 
         #region 方法
Modified +1 -1
diff --git a/XCode/Entity/DataRowEntityAccessor.cs b/XCode/Entity/DataRowEntityAccessor.cs
index 0ecc3d5..f047354 100644
--- a/XCode/Entity/DataRowEntityAccessor.cs
+++ b/XCode/Entity/DataRowEntityAccessor.cs
@@ -219,7 +219,7 @@ namespace XCode
             }
             else if (type == typeof(Guid))
             {
-                if (!(value is Guid))
+                if (value is not Guid)
                 {
                     if (value is Byte[] buf)
                         value = new Guid(buf);
Modified +1 -1
diff --git a/XCode/Entity/EntityExtension.cs b/XCode/Entity/EntityExtension.cs
index 1ab885b..735b7e2 100644
--- a/XCode/Entity/EntityExtension.cs
+++ b/XCode/Entity/EntityExtension.cs
@@ -638,7 +638,7 @@ namespace XCode
             if (columns == null)
             {
                 var dbt = session.Dal.DbType;
-                if (dbt == DatabaseType.SqlServer || dbt == DatabaseType.Oracle)
+                if (dbt is DatabaseType.SqlServer or DatabaseType.Oracle)
                     columns = fact.Fields.Select(e => e.Field).Where(e => !e.Identity || e.PrimaryKey).ToArray();
                 else if (dbt == DatabaseType.MySql)
                     columns = fact.Fields.Select(e => e.Field).ToArray(); //只有标识键的情况下会导致重复执行insert方法 目前只测试了Mysql库
Modified +1 -1
diff --git a/XCode/Entity/IEntityPersistence.cs b/XCode/Entity/IEntityPersistence.cs
index daf5b4c..141567f 100644
--- a/XCode/Entity/IEntityPersistence.cs
+++ b/XCode/Entity/IEntityPersistence.cs
@@ -702,7 +702,7 @@ namespace XCode
             //// 是否使用参数化
             //if (Setting.Current.UserParameter) return true;
 
-            if (fi.Length > 0 && fi.Length < 4000) return false;
+            if (fi.Length is > 0 and < 4000) return false;
 
             // 虽然是大字段,但数据量不大时不用参数
             if (fi.Type == typeof(String))
Modified +1 -1
diff --git a/XCode/Membership/LogProvider.cs b/XCode/Membership/LogProvider.cs
index 959cebb..86c774d 100644
--- a/XCode/Membership/LogProvider.cs
+++ b/XCode/Membership/LogProvider.cs
@@ -163,7 +163,7 @@ namespace XCode.Membership
 
                 var v = entity[fi.Name];
                 // 空字符串不写日志
-                if (action == "添加" || action == "删除" || action == "Insert" || action == "Delete")
+                if (action is "添加" or "删除" or "Insert" or "Delete")
                 {
                     if (v + "" == "") continue;
                     if (v is Boolean b && !b) continue;
Modified +6 -6
diff --git "a/XCode/Membership/\345\234\260\345\214\272.Biz.cs" "b/XCode/Membership/\345\234\260\345\214\272.Biz.cs"
index 370c32d..fab48ef 100644
--- "a/XCode/Membership/\345\234\260\345\214\272.Biz.cs"
+++ "b/XCode/Membership/\345\234\260\345\214\272.Biz.cs"
@@ -291,7 +291,7 @@ namespace XCode.Membership
         /// <returns>实体列表</returns>
         public static IList<Area> FindAllByParentID(Int32 parentid)
         {
-            if (parentid < 0 || parentid > 99_99_99) return new List<Area>();
+            if (parentid is < 0 or > 99_99_99) return new List<Area>();
 
             // 实体缓存
             var rs = Meta.Cache.FindAll(e => e.ParentID == parentid);
@@ -336,8 +336,8 @@ namespace XCode.Membership
                 if (key.ToLong() > 0)
                 {
                     var exp2 = new WhereExpression();
-                    if (key.Length == 6 || key.Length == 9) exp2 |= _.ID == key;
-                    if (key.Length == 2 || key.Length == 3) exp2 |= _.TelCode == key;
+                    if (key.Length is 6 or 9) exp2 |= _.ID == key;
+                    if (key.Length is 2 or 3) exp2 |= _.TelCode == key;
                     if (key.Length == 6) exp2 |= _.ZipCode == key;
 
                     exp &= exp2;
@@ -478,7 +478,7 @@ namespace XCode.Membership
             if (id > 999999)
             {
                 // 四级地址是9位数字
-                if (parentid < 100000 || parentid > 999999) return null;
+                if (parentid is < 100000 or > 999999) return null;
                 if (id < 100000000) return null;
                 if (id > 999999999) return null;
             }
@@ -787,7 +787,7 @@ namespace XCode.Membership
             var count = 0;
             foreach (var r in list)
             {
-                if (r.ID < 10_00_00 || r.ID > 99_99_99) continue;
+                if (r.ID is < 10_00_00 or > 99_99_99) continue;
 
                 //var r2 = FindByID(r.ID);
                 var r2 = rs.FirstOrDefault(e => e.ID == r.ID);
@@ -879,7 +879,7 @@ namespace XCode.Membership
             var count = 0;
             foreach (var r in list)
             {
-                if (r.ID < 10_00_00_000 || r.ID > 99_99_99_999) continue;
+                if (r.ID is < 10_00_00_000 or > 99_99_99_999) continue;
 
                 //var r2 = FindByID(r.ID);
                 var r2 = rs.FirstOrDefault(e => e.ID == r.ID);
Modified +1 -1
diff --git "a/XCode/Membership/\345\255\227\345\205\270\345\217\202\346\225\260.Biz.cs" "b/XCode/Membership/\345\255\227\345\205\270\345\217\202\346\225\260.Biz.cs"
index ef44e79..8c7e86e 100644
--- "a/XCode/Membership/\345\255\227\345\205\270\345\217\202\346\225\260.Biz.cs"
+++ "b/XCode/Membership/\345\255\227\345\205\270\345\217\202\346\225\260.Biz.cs"
@@ -198,7 +198,7 @@ namespace XCode.Membership
                 case ParameterKinds.Boolean: return str.ToBoolean();
                 case ParameterKinds.Int:
                     var v = str.ToLong();
-                    return (v >= Int32.MaxValue || v <= Int32.MinValue) ? (Object)v : (Int32)v;
+                    return (v is >= Int32.MaxValue or <= Int32.MinValue) ? (Object)v : (Int32)v;
                 case ParameterKinds.Double: return str.ToDouble();
                 case ParameterKinds.DateTime: return str.ToDateTime();
                 case ParameterKinds.String: return str;
Modified +4 -4
diff --git a/XCode/Shards/TimeShardPolicy.cs b/XCode/Shards/TimeShardPolicy.cs
index 6705c2b..651c36f 100644
--- a/XCode/Shards/TimeShardPolicy.cs
+++ b/XCode/Shards/TimeShardPolicy.cs
@@ -152,8 +152,8 @@ namespace XCode.Shards
 
             if (fi.Type == typeof(DateTime))
             {
-                var sf = exps.FirstOrDefault(e => e.Action == ">" || e.Action == ">=");
-                var ef = exps.FirstOrDefault(e => e.Action == "<" || e.Action == "<=");
+                var sf = exps.FirstOrDefault(e => e.Action is ">" or ">=");
+                var ef = exps.FirstOrDefault(e => e.Action is "<" or "<=");
                 if (sf != null)
                 {
                     var start = sf.Value.ToDateTime();
@@ -173,8 +173,8 @@ namespace XCode.Shards
             }
             else if (fi.Type == typeof(Int64))
             {
-                var sf = exps.FirstOrDefault(e => e.Action == ">" || e.Action == ">=");
-                var ef = exps.FirstOrDefault(e => e.Action == "<" || e.Action == "<=");
+                var sf = exps.FirstOrDefault(e => e.Action is ">" or ">=");
+                var ef = exps.FirstOrDefault(e => e.Action is "<" or "<=");
                 if (sf != null)
                 {
                     var id = sf.Value.ToLong();
Modified +1 -1
diff --git a/XUnitTest.Core/Caching/MemoryCacheTests.cs b/XUnitTest.Core/Caching/MemoryCacheTests.cs
index 6986a3e..4f776f7 100644
--- a/XUnitTest.Core/Caching/MemoryCacheTests.cs
+++ b/XUnitTest.Core/Caching/MemoryCacheTests.cs
@@ -41,7 +41,7 @@ namespace XUnitTest.Caching
             // 过期时间
             ic.SetExpire(key, TimeSpan.FromSeconds(1));
             var ts = ic.GetExpire(key);
-            Assert.True(ts.TotalSeconds > 0 && ts.TotalSeconds < 2, "过期时间");
+            Assert.True(ts.TotalSeconds is > 0 and < 2, "过期时间");
 
             var rs = ic.Remove(key2);
             Assert.Equal(1, rs);
Modified +3 -3
diff --git a/XUnitTest.Core/Caching/RedisTest.cs b/XUnitTest.Core/Caching/RedisTest.cs
index 6529087..52aebfb 100644
--- a/XUnitTest.Core/Caching/RedisTest.cs
+++ b/XUnitTest.Core/Caching/RedisTest.cs
@@ -74,7 +74,7 @@ namespace XUnitTest.Caching
             // 过期时间
             ic.SetExpire(key, TimeSpan.FromSeconds(1));
             var ts = ic.GetExpire(key);
-            Assert.True(ts.TotalSeconds > 0 && ts.TotalSeconds < 2, "过期时间 " + ts);
+            Assert.True(ts.TotalSeconds is > 0 and < 2, "过期时间 " + ts);
 
             var rs = ic.Remove(key2);
             if (ic.AutoPipeline > 0) rs = (Int32)ic.StopPipeline(true)[0];
@@ -290,7 +290,7 @@ namespace XUnitTest.Caching
             // 过期时间
             ic.SetExpire(key, TimeSpan.FromSeconds(1));
             var ts = ic.GetExpire(key);
-            Assert.True(ts.TotalSeconds > 0 && ts.TotalSeconds < 2, "过期时间");
+            Assert.True(ts.TotalSeconds is > 0 and < 2, "过期时间");
 
             var rs = ic.Remove(key2);
             if (ic.AutoPipeline > 0) rs = (Int32)ic.StopPipeline(true)[0];
@@ -506,7 +506,7 @@ namespace XUnitTest.Caching
             // 过期时间
             ic.SetExpire(key, TimeSpan.FromSeconds(1));
             var ts = ic.GetExpire(key);
-            Assert.True(ts.TotalSeconds > 0 && ts.TotalSeconds < 2, "过期时间");
+            Assert.True(ts.TotalSeconds is > 0 and < 2, "过期时间");
 
             var rs = ic.Remove(key2);
             if (ic.AutoPipeline > 0) rs = (Int32)ic.StopPipeline(true)[0];
Modified +2 -2
diff --git a/XUnitTest.Core/IO/CsvDbTests.cs b/XUnitTest.Core/IO/CsvDbTests.cs
index f48e9d6..3dab081 100644
--- a/XUnitTest.Core/IO/CsvDbTests.cs
+++ b/XUnitTest.Core/IO/CsvDbTests.cs
@@ -120,8 +120,8 @@ namespace XUnitTest.IO
             }
 
             // 高级查找
-            var list3 = db.FindAll(e => e.Code >= 100 && e.Code < 1000);
-            var list4 = list.Where(e => e.Code >= 100 && e.Code < 1000).ToList();
+            var list3 = db.FindAll(e => e.Code is >= 100 and < 1000);
+            var list4 = list.Where(e => e.Code is >= 100 and < 1000).ToList();
             Assert.Equal(list4.Select(e => e.Code), list3.Select(e => e.Code));
         }