@@ -1515,36 +1515,14 @@ public byte[] BRPopLPush(string fromListId, string toListId, int timeOutSecs)
15151515
15161516 #region Sentinel
15171517
1518- private static Dictionary < string , string > ToDictionary ( object [ ] result )
1519- {
1520- var map = new Dictionary < string , string > ( ) ;
1521-
1522- string key = null ;
1523- for ( var i = 0 ; i < result . Length ; i ++ )
1524- {
1525- var bytes = ( byte [ ] ) result [ i ] ;
1526- if ( i % 2 == 0 )
1527- {
1528- key = bytes . FromUtf8Bytes ( ) ;
1529- }
1530- else
1531- {
1532- var val = bytes . FromUtf8Bytes ( ) ;
1533- map [ key ] = val ;
1534- }
1535- }
1536- return map ;
1537- }
1538-
15391518 public List < Dictionary < string , string > > SentinelMasters ( )
15401519 {
15411520 var args = new List < byte [ ] >
15421521 {
15431522 Commands . Sentinel ,
15441523 Commands . Masters ,
15451524 } ;
1546- var results = SendExpectDeeplyNestedMultiData ( args . ToArray ( ) ) ;
1547- return ToDictionaryList ( results ) ;
1525+ return SendExpectStringDictionaryList ( args . ToArray ( ) ) ;
15481526 }
15491527
15501528 public Dictionary < string , string > SentinelMaster ( string masterName )
@@ -1555,7 +1533,7 @@ public Dictionary<string, string> SentinelMaster(string masterName)
15551533 Commands . Master ,
15561534 masterName . ToUtf8Bytes ( ) ,
15571535 } ;
1558- var results = SendExpectDeeplyNestedMultiData ( args . ToArray ( ) ) ;
1536+ var results = SendExpectComplexResponse ( args . ToArray ( ) ) ;
15591537 return ToDictionary ( results ) ;
15601538 }
15611539
@@ -1567,8 +1545,7 @@ public List<Dictionary<string, string>> SentinelSentinels(string masterName)
15671545 Commands . Sentinels ,
15681546 masterName . ToUtf8Bytes ( ) ,
15691547 } ;
1570- var results = SendExpectDeeplyNestedMultiData ( args . ToArray ( ) ) ;
1571- return ToDictionaryList ( results ) ;
1548+ return SendExpectStringDictionaryList ( args . ToArray ( ) ) ;
15721549 }
15731550
15741551 public List < Dictionary < string , string > > SentinelSlaves ( string masterName )
@@ -1579,33 +1556,7 @@ public List<Dictionary<string, string>> SentinelSlaves(string masterName)
15791556 Commands . Slaves ,
15801557 masterName . ToUtf8Bytes ( ) ,
15811558 } ;
1582- var results = SendExpectDeeplyNestedMultiData ( args . ToArray ( ) ) ;
1583- return ToDictionaryList ( results ) ;
1584- }
1585-
1586- private static List < Dictionary < string , string > > ToDictionaryList ( object [ ] results )
1587- {
1588- var to = new List < Dictionary < string , string > > ( ) ;
1589- foreach ( object result in results )
1590- {
1591- var obArray = result as object [ ] ;
1592- if ( obArray == null )
1593- {
1594- var value = result . ToString ( ) ;
1595- var bytes = result as byte [ ] ;
1596- if ( bytes != null )
1597- value = bytes . FromUtf8Bytes ( ) ;
1598-
1599- log . ErrorFormat ( "[{0}] Expected object[] received {1}: {2}" ,
1600- DateTime . UtcNow . ToString ( "HH:mm:ss.fff" ) , result . GetType ( ) . Name , value ) ;
1601-
1602- continue ;
1603- }
1604-
1605- var item = ToDictionary ( obArray ) ;
1606- to . Add ( item ) ;
1607- }
1608- return to ;
1559+ return SendExpectStringDictionaryList ( args . ToArray ( ) ) ;
16091560 }
16101561
16111562 public List < string > SentinelGetMasterAddrByName ( string masterName )
@@ -1616,7 +1567,6 @@ public List<string> SentinelGetMasterAddrByName(string masterName)
16161567 Commands . GetMasterAddrByName ,
16171568 masterName . ToUtf8Bytes ( ) ,
16181569 } ;
1619-
16201570 return SendExpectMultiData ( args . ToArray ( ) ) . ToStringList ( ) ;
16211571 }
16221572
0 commit comments