@@ -50,20 +50,17 @@ public partial class RedisNativeClient
5050 internal long deactivatedAtTicks ;
5151 public DateTime ? DeactivatedAt
5252 {
53- get
54- {
55- return deactivatedAtTicks != 0
56- ? new DateTime ( Interlocked . Read ( ref deactivatedAtTicks ) , DateTimeKind . Utc )
57- : ( DateTime ? ) null ;
58- }
53+ get => deactivatedAtTicks != 0
54+ ? new DateTime ( Interlocked . Read ( ref deactivatedAtTicks ) , DateTimeKind . Utc )
55+ : ( DateTime ? ) null ;
5956 set
6057 {
61- var ticksValue = value == null ? 0 : value . Value . Ticks ;
58+ var ticksValue = value ? . Ticks ?? 0 ;
6259 Interlocked . Exchange ( ref deactivatedAtTicks , ticksValue ) ;
6360 }
6461 }
6562
66- public bool HadExceptions { get { return deactivatedAtTicks > 0 ; } }
63+ public bool HadExceptions => deactivatedAtTicks > 0 ;
6764
6865 protected Socket socket ;
6966 protected BufferedStream Bstream ;
@@ -81,14 +78,8 @@ public DateTime? DeactivatedAt
8178 private int active ;
8279 internal bool Active
8380 {
84- get
85- {
86- return Interlocked . CompareExchange ( ref active , 0 , 0 ) == YES ;
87- }
88- set
89- {
90- Interlocked . Exchange ( ref active , value ? YES : NO ) ;
91- }
81+ get => Interlocked . CompareExchange ( ref active , 0 , 0 ) == YES ;
82+ set => Interlocked . Exchange ( ref active , value ? YES : NO ) ;
9283 }
9384
9485 internal IHandleClientDispose ClientManager { get ; set ; }
@@ -109,8 +100,8 @@ internal bool Active
109100 private TimeSpan retryTimeout ;
110101 public int RetryTimeout
111102 {
112- get { return ( int ) retryTimeout . TotalMilliseconds ; }
113- set { retryTimeout = TimeSpan . FromMilliseconds ( value ) ; }
103+ get => ( int ) retryTimeout . TotalMilliseconds ;
104+ set => retryTimeout = TimeSpan . FromMilliseconds ( value ) ;
114105 }
115106 public int RetryCount { get ; set ; }
116107 public int SendTimeout { get ; set ; }
@@ -123,10 +114,7 @@ public int RetryTimeout
123114
124115 internal IRedisTransactionBase Transaction
125116 {
126- get
127- {
128- return transaction ;
129- }
117+ get => transaction ;
130118 set
131119 {
132120 if ( value != null )
@@ -137,10 +125,7 @@ internal IRedisTransactionBase Transaction
137125
138126 internal IRedisPipelineShared Pipeline
139127 {
140- get
141- {
142- return pipeline ;
143- }
128+ get => pipeline ;
144129 set
145130 {
146131 if ( value != null )
@@ -205,10 +190,7 @@ public RedisNativeClient()
205190 long db ;
206191 public long Db
207192 {
208- get
209- {
210- return db ;
211- }
193+ get => db ;
212194
213195 set
214196 {
@@ -227,13 +209,7 @@ public void ChangeDb(long db)
227209 SendExpectSuccess ( Commands . Select , db . ToUtf8Bytes ( ) ) ;
228210 }
229211
230- public long DbSize
231- {
232- get
233- {
234- return SendExpectLong ( Commands . DbSize ) ;
235- }
236- }
212+ public long DbSize => SendExpectLong ( Commands . DbSize ) ;
237213
238214 public DateTime LastSave
239215 {
@@ -268,8 +244,7 @@ public string ServerVersion
268244 {
269245 get
270246 {
271- string version ;
272- this . Info . TryGetValue ( "redis_version" , out version ) ;
247+ this . Info . TryGetValue ( "redis_version" , out var version ) ;
273248 return version ;
274249 }
275250 }
@@ -286,8 +261,7 @@ public RedisData RawCommand(params object[] cmdWithArgs)
286261 continue ;
287262 }
288263
289- var bytes = arg as byte [ ] ;
290- if ( bytes != null )
264+ if ( arg is byte [ ] bytes )
291265 {
292266 byteArgs . Add ( bytes ) ;
293267 }
@@ -1436,8 +1410,7 @@ public byte[][] BLPop(string[] listIds, int timeOutSecs)
14361410 {
14371411 if ( listIds == null )
14381412 throw new ArgumentNullException ( "listIds" ) ;
1439- var args = new List < byte [ ] > ( ) ;
1440- args . Add ( Commands . BLPop ) ;
1413+ var args = new List < byte [ ] > { Commands . BLPop } ;
14411414 args . AddRange ( listIds . Select ( listId => listId . ToUtf8Bytes ( ) ) ) ;
14421415 args . Add ( timeOutSecs . ToUtf8Bytes ( ) ) ;
14431416 return SendExpectMultiData ( args . ToArray ( ) ) ;
@@ -1471,8 +1444,7 @@ public byte[][] BRPop(string[] listIds, int timeOutSecs)
14711444 {
14721445 if ( listIds == null )
14731446 throw new ArgumentNullException ( "listIds" ) ;
1474- var args = new List < byte [ ] > ( ) ;
1475- args . Add ( Commands . BRPop ) ;
1447+ var args = new List < byte [ ] > { Commands . BRPop } ;
14761448 args . AddRange ( listIds . Select ( listId => listId . ToUtf8Bytes ( ) ) ) ;
14771449 args . Add ( timeOutSecs . ToUtf8Bytes ( ) ) ;
14781450 return SendExpectMultiData ( args . ToArray ( ) ) ;
@@ -1497,19 +1469,19 @@ public byte[][] BRPopValue(string[] listIds, int timeOutSecs)
14971469 public byte [ ] RPopLPush ( string fromListId , string toListId )
14981470 {
14991471 if ( fromListId == null )
1500- throw new ArgumentNullException ( " fromListId" ) ;
1472+ throw new ArgumentNullException ( nameof ( fromListId ) ) ;
15011473 if ( toListId == null )
1502- throw new ArgumentNullException ( " toListId" ) ;
1474+ throw new ArgumentNullException ( nameof ( toListId ) ) ;
15031475
15041476 return SendExpectData ( Commands . RPopLPush , fromListId . ToUtf8Bytes ( ) , toListId . ToUtf8Bytes ( ) ) ;
15051477 }
15061478
15071479 public byte [ ] BRPopLPush ( string fromListId , string toListId , int timeOutSecs )
15081480 {
15091481 if ( fromListId == null )
1510- throw new ArgumentNullException ( " fromListId" ) ;
1482+ throw new ArgumentNullException ( nameof ( fromListId ) ) ;
15111483 if ( toListId == null )
1512- throw new ArgumentNullException ( " toListId" ) ;
1484+ throw new ArgumentNullException ( nameof ( toListId ) ) ;
15131485
15141486 byte [ ] [ ] result = SendExpectMultiData ( Commands . BRPopLPush , fromListId . ToUtf8Bytes ( ) , toListId . ToUtf8Bytes ( ) , timeOutSecs . ToUtf8Bytes ( ) ) ;
15151487 return result . Length == 0 ? null : result [ 1 ] ;
@@ -1981,9 +1953,9 @@ public long ZRemRangeByLex(string setId, string min, string max)
19811953 private static void AssertHashIdAndKey ( object hashId , byte [ ] key )
19821954 {
19831955 if ( hashId == null )
1984- throw new ArgumentNullException ( " hashId" ) ;
1956+ throw new ArgumentNullException ( nameof ( hashId ) ) ;
19851957 if ( key == null )
1986- throw new ArgumentNullException ( " key" ) ;
1958+ throw new ArgumentNullException ( nameof ( key ) ) ;
19871959 }
19881960
19891961 public long HSet ( string hashId , byte [ ] key , byte [ ] value )
@@ -2008,7 +1980,7 @@ public long HSetNX(string hashId, byte[] key, byte[] value)
20081980 public void HMSet ( string hashId , byte [ ] [ ] keys , byte [ ] [ ] values )
20091981 {
20101982 if ( hashId == null )
2011- throw new ArgumentNullException ( " hashId" ) ;
1983+ throw new ArgumentNullException ( nameof ( hashId ) ) ;
20121984
20131985 var cmdArgs = MergeCommandWithKeysAndValues ( Commands . HMSet , hashId . ToUtf8Bytes ( ) , keys , values ) ;
20141986
@@ -2051,9 +2023,9 @@ public byte[] HGet(byte[] hashId, byte[] key)
20512023 public byte [ ] [ ] HMGet ( string hashId , params byte [ ] [ ] keys )
20522024 {
20532025 if ( hashId == null )
2054- throw new ArgumentNullException ( " hashId" ) ;
2026+ throw new ArgumentNullException ( nameof ( hashId ) ) ;
20552027 if ( keys . Length == 0 )
2056- throw new ArgumentNullException ( " keys" ) ;
2028+ throw new ArgumentNullException ( nameof ( keys ) ) ;
20572029
20582030 var cmdArgs = MergeCommandWithArgs ( Commands . HMGet , hashId . ToUtf8Bytes ( ) , keys ) ;
20592031
@@ -2075,11 +2047,11 @@ public long HDel(byte[] hashId, byte[] key)
20752047 public long HDel ( string hashId , byte [ ] [ ] keys )
20762048 {
20772049 if ( hashId == null )
2078- throw new ArgumentNullException ( " hashId" ) ;
2050+ throw new ArgumentNullException ( nameof ( hashId ) ) ;
20792051 if ( keys == null )
2080- throw new ArgumentNullException ( " keys" ) ;
2052+ throw new ArgumentNullException ( nameof ( keys ) ) ;
20812053 if ( keys . Length == 0 )
2082- throw new ArgumentException ( " keys" ) ;
2054+ throw new ArgumentException ( nameof ( keys ) ) ;
20832055
20842056 var cmdWithArgs = MergeCommandWithArgs ( Commands . HDel , hashId . ToUtf8Bytes ( ) , keys ) ;
20852057 return SendExpectLong ( cmdWithArgs ) ;
@@ -2094,31 +2066,31 @@ public long HExists(string hashId, byte[] key)
20942066 public long HLen ( string hashId )
20952067 {
20962068 if ( string . IsNullOrEmpty ( hashId ) )
2097- throw new ArgumentNullException ( " hashId" ) ;
2069+ throw new ArgumentNullException ( nameof ( hashId ) ) ;
20982070
20992071 return SendExpectLong ( Commands . HLen , hashId . ToUtf8Bytes ( ) ) ;
21002072 }
21012073
21022074 public byte [ ] [ ] HKeys ( string hashId )
21032075 {
21042076 if ( hashId == null )
2105- throw new ArgumentNullException ( " hashId" ) ;
2077+ throw new ArgumentNullException ( nameof ( hashId ) ) ;
21062078
21072079 return SendExpectMultiData ( Commands . HKeys , hashId . ToUtf8Bytes ( ) ) ;
21082080 }
21092081
21102082 public byte [ ] [ ] HVals ( string hashId )
21112083 {
21122084 if ( hashId == null )
2113- throw new ArgumentNullException ( " hashId" ) ;
2085+ throw new ArgumentNullException ( nameof ( hashId ) ) ;
21142086
21152087 return SendExpectMultiData ( Commands . HVals , hashId . ToUtf8Bytes ( ) ) ;
21162088 }
21172089
21182090 public byte [ ] [ ] HGetAll ( string hashId )
21192091 {
21202092 if ( hashId == null )
2121- throw new ArgumentNullException ( " hashId" ) ;
2093+ throw new ArgumentNullException ( nameof ( hashId ) ) ;
21222094
21232095 return SendExpectMultiData ( Commands . HGetAll , hashId . ToUtf8Bytes ( ) ) ;
21242096 }
@@ -2141,7 +2113,7 @@ public virtual IRedisSubscription CreateSubscription()
21412113 public byte [ ] [ ] Subscribe ( params string [ ] toChannels )
21422114 {
21432115 if ( toChannels . Length == 0 )
2144- throw new ArgumentNullException ( " toChannels" ) ;
2116+ throw new ArgumentNullException ( nameof ( toChannels ) ) ;
21452117
21462118 var cmdWithArgs = MergeCommandWithArgs ( Commands . Subscribe , toChannels ) ;
21472119 return SendExpectMultiData ( cmdWithArgs ) ;
@@ -2156,7 +2128,7 @@ public byte[][] UnSubscribe(params string[] fromChannels)
21562128 public byte [ ] [ ] PSubscribe ( params string [ ] toChannelsMatchingPatterns )
21572129 {
21582130 if ( toChannelsMatchingPatterns . Length == 0 )
2159- throw new ArgumentNullException ( " toChannelsMatchingPatterns" ) ;
2131+ throw new ArgumentNullException ( nameof ( toChannelsMatchingPatterns ) ) ;
21602132
21612133 var cmdWithArgs = MergeCommandWithArgs ( Commands . PSubscribe , toChannelsMatchingPatterns ) ;
21622134 return SendExpectMultiData ( cmdWithArgs ) ;
@@ -2181,17 +2153,17 @@ public RedisPipelineCommand CreatePipelineCommand()
21812153 public long GeoAdd ( string key , double longitude , double latitude , string member )
21822154 {
21832155 if ( key == null )
2184- throw new ArgumentNullException ( " key" ) ;
2156+ throw new ArgumentNullException ( nameof ( key ) ) ;
21852157 if ( member == null )
2186- throw new ArgumentNullException ( " member" ) ;
2158+ throw new ArgumentNullException ( nameof ( member ) ) ;
21872159
21882160 return SendExpectLong ( Commands . GeoAdd , key . ToUtf8Bytes ( ) , longitude . ToUtf8Bytes ( ) , latitude . ToUtf8Bytes ( ) , member . ToUtf8Bytes ( ) ) ;
21892161 }
21902162
21912163 public long GeoAdd ( string key , params RedisGeo [ ] geoPoints )
21922164 {
21932165 if ( key == null )
2194- throw new ArgumentNullException ( " key" ) ;
2166+ throw new ArgumentNullException ( nameof ( key ) ) ;
21952167
21962168 var members = new byte [ geoPoints . Length * 3 ] [ ] ;
21972169 for ( var i = 0 ; i < geoPoints . Length ; i ++ )
@@ -2209,7 +2181,7 @@ public long GeoAdd(string key, params RedisGeo[] geoPoints)
22092181 public double GeoDist ( string key , string fromMember , string toMember , string unit = null )
22102182 {
22112183 if ( key == null )
2212- throw new ArgumentNullException ( " key" ) ;
2184+ throw new ArgumentNullException ( nameof ( key ) ) ;
22132185
22142186 return unit == null
22152187 ? SendExpectDouble ( Commands . GeoDist , key . ToUtf8Bytes ( ) , fromMember . ToUtf8Bytes ( ) , toMember . ToUtf8Bytes ( ) )
@@ -2219,7 +2191,7 @@ public double GeoDist(string key, string fromMember, string toMember, string uni
22192191 public string [ ] GeoHash ( string key , params string [ ] members )
22202192 {
22212193 if ( key == null )
2222- throw new ArgumentNullException ( " key" ) ;
2194+ throw new ArgumentNullException ( nameof ( key ) ) ;
22232195
22242196 var cmdWithArgs = MergeCommandWithArgs ( Commands . GeoHash , key . ToUtf8Bytes ( ) , members . Map ( x => x . ToUtf8Bytes ( ) ) . ToArray ( ) ) ;
22252197 return SendExpectMultiData ( cmdWithArgs ) . ToStringArray ( ) ;
@@ -2228,7 +2200,7 @@ public string[] GeoHash(string key, params string[] members)
22282200 public List < RedisGeo > GeoPos ( string key , params string [ ] members )
22292201 {
22302202 if ( key == null )
2231- throw new ArgumentNullException ( " key" ) ;
2203+ throw new ArgumentNullException ( nameof ( key ) ) ;
22322204
22332205 var cmdWithArgs = MergeCommandWithArgs ( Commands . GeoPos , key . ToUtf8Bytes ( ) , members . Map ( x => x . ToUtf8Bytes ( ) ) . ToArray ( ) ) ;
22342206 var data = SendExpectComplexResponse ( cmdWithArgs ) ;
@@ -2260,7 +2232,7 @@ public List<RedisGeoResult> GeoRadius(string key, double longitude, double latit
22602232 bool withCoords = false , bool withDist = false , bool withHash = false , int ? count = null , bool ? asc = null )
22612233 {
22622234 if ( key == null )
2263- throw new ArgumentNullException ( " key" ) ;
2235+ throw new ArgumentNullException ( nameof ( key ) ) ;
22642236
22652237 var args = new List < byte [ ] >
22662238 {
@@ -2331,7 +2303,7 @@ public List<RedisGeoResult> GeoRadiusByMember(string key, string member, double
23312303 bool withCoords = false , bool withDist = false , bool withHash = false , int ? count = null , bool ? asc = null )
23322304 {
23332305 if ( key == null )
2334- throw new ArgumentNullException ( " key" ) ;
2306+ throw new ArgumentNullException ( nameof ( key ) ) ;
23352307
23362308 var args = new List < byte [ ] >
23372309 {
@@ -2401,10 +2373,7 @@ public List<RedisGeoResult> GeoRadiusByMember(string key, string member, double
24012373
24022374 internal bool IsDisposed { get ; set ; }
24032375
2404- public bool IsManagedClient
2405- {
2406- get { return ClientManager != null ; }
2407- }
2376+ public bool IsManagedClient => ClientManager != null ;
24082377
24092378 public virtual void Dispose ( )
24102379 {
@@ -2458,20 +2427,17 @@ private void SafeConnectionClose()
24582427 try
24592428 {
24602429 // workaround for a .net bug: http://support.microsoft.com/kb/821625
2461- if ( Bstream != null )
2462- Bstream . Close ( ) ;
2430+ Bstream ? . Close ( ) ;
24632431 }
24642432 catch { }
24652433 try
24662434 {
2467- if ( sslStream != null )
2468- sslStream . Close ( ) ;
2435+ sslStream ? . Close ( ) ;
24692436 }
24702437 catch { }
24712438 try
24722439 {
2473- if ( socket != null )
2474- socket . Close ( ) ;
2440+ socket ? . Close ( ) ;
24752441 }
24762442 catch { }
24772443
0 commit comments