1616using System . Linq ;
1717using System . Net . Sockets ;
1818using ServiceStack . Model ;
19+ using ServiceStack . Text ;
1920
2021namespace ServiceStack . Redis
2122{
2223 public static class RedisExtensions
2324 {
2425 public static List < RedisEndpoint > ToRedisEndPoints ( this IEnumerable < string > hosts )
2526 {
26- return hosts == null
27- ? new List < RedisEndpoint > ( )
27+ return hosts == null
28+ ? new List < RedisEndpoint > ( )
2829 : hosts . Select ( x => ToRedisEndpoint ( x ) ) . ToList ( ) ;
2930 }
3031
@@ -64,7 +65,7 @@ public static RedisEndpoint ToRedisEndpoint(this string connectionString, int? d
6465 var value = entry . Length > 1 ? entry [ 1 ] . UrlDecode ( ) : null ;
6566 if ( value == null ) continue ;
6667
67- var name = entry [ 0 ] . ToLower ( ) ;
68+ var name = entry [ 0 ] . ToLower ( ) ;
6869 switch ( name )
6970 {
7071 case "db" :
@@ -149,7 +150,7 @@ public static List<string> ToStringList(this byte[][] multiDataList)
149150 public static string [ ] ToStringArray ( this byte [ ] [ ] multiDataList )
150151 {
151152 if ( multiDataList == null )
152- return new string [ 0 ] ;
153+ return TypeConstants . EmptyStringArray ;
153154
154155 var to = new string [ multiDataList . Length ] ;
155156 for ( int i = 0 ; i < multiDataList . Length ; i ++ )
@@ -162,7 +163,7 @@ public static string[] ToStringArray(this byte[][] multiDataList)
162163 public static Dictionary < string , string > ToStringDictionary ( this byte [ ] [ ] multiDataList )
163164 {
164165 if ( multiDataList == null )
165- return new Dictionary < string , string > ( ) ;
166+ return TypeConstants . EmptyStringDictionary ;
166167
167168 var map = new Dictionary < string , string > ( ) ;
168169
@@ -190,20 +191,20 @@ private static byte[] FastToUtf8Bytes(string strVal)
190191 {
191192 var bytes = new byte [ strVal . Length ] ;
192193 for ( var i = 0 ; i < strVal . Length ; i ++ )
193- bytes [ i ] = ( byte ) strVal [ i ] ;
194+ bytes [ i ] = ( byte ) strVal [ i ] ;
194195
195196 return bytes ;
196197 }
197198
198- public static byte [ ] [ ] ToMultiByteArray ( this string [ ] args )
199- {
200- var byteArgs = new byte [ args . Length ] [ ] ;
201- for ( var i = 0 ; i < args . Length ; ++ i )
202- byteArgs [ i ] = args [ i ] . ToUtf8Bytes ( ) ;
203- return byteArgs ;
204- }
199+ public static byte [ ] [ ] ToMultiByteArray ( this string [ ] args )
200+ {
201+ var byteArgs = new byte [ args . Length ] [ ] ;
202+ for ( var i = 0 ; i < args . Length ; ++ i )
203+ byteArgs [ i ] = args [ i ] . ToUtf8Bytes ( ) ;
204+ return byteArgs ;
205+ }
205206
206- public static byte [ ] [ ] PrependByteArray ( this byte [ ] [ ] args , byte [ ] valueToPrepend )
207+ public static byte [ ] [ ] PrependByteArray ( this byte [ ] [ ] args , byte [ ] valueToPrepend )
207208 {
208209 var newArgs = new byte [ args . Length + 1 ] [ ] ;
209210 newArgs [ 0 ] = valueToPrepend ;
@@ -213,7 +214,7 @@ public static byte[][] PrependByteArray(this byte[][] args, byte[] valueToPrepe
213214
214215 return newArgs ;
215216 }
216- public static byte [ ] [ ] PrependInt ( this byte [ ] [ ] args , int valueToPrepend )
217+ public static byte [ ] [ ] PrependInt ( this byte [ ] [ ] args , int valueToPrepend )
217218 {
218219 return args . PrependByteArray ( valueToPrepend . ToUtf8Bytes ( ) ) ;
219220 }
0 commit comments