public static RedisMasterRoleSlaveInfo Parse(RedisArray array) { if (!ReferenceEquals(array, null)) { var list = array.Value; if (list != null) { var count = list.Count; if (count > 0) { var result = new RedisMasterRoleSlaveInfo(); var item = list[0]; if (!ReferenceEquals(item, null) && item.Type == RedisResultType.Bytes) { result.IPAddress = ((RedisBytes)item).Value.ToUTF8String(); } if (count > 1) { item = list[1]; if (!ReferenceEquals(item, null) && item.Type == RedisResultType.Bytes) { var port = ((RedisBytes)item).Value.ToUTF8String(); if (!port.IsEmpty()) { int i; if (port.TryParse(out i)) { result.Port = i; } } } if (count > 2) { item = list[2]; if (!ReferenceEquals(item, null) && item.Type == RedisResultType.Bytes) { var offset = ((RedisBytes)item).Value.ToUTF8String(); if (!offset.IsEmpty()) { long l; if (offset.TryParse(out l)) { result.ReplicationOffset = l; } } } } } return(result); } } } return(null); }
protected override void ParseInfo(RedisArray array) { if (!ReferenceEquals(array, null)) { var list = array.Value; if (list != null) { var count = list.Count; if (count > 1) { var item = list[1]; if (!ReferenceEquals(item, null) && item.Type == RedisResultType.Integer) { ReplicationOffset = ((RedisInteger)item).Value; } if (count > 2) { var slaves = new List <RedisMasterRoleSlaveInfo>(count - 2); for (var i = 2; i < count; i++) { var slaveInfo = RedisMasterRoleSlaveInfo.Parse((RedisArray)list[i]); if (slaveInfo != null) { slaves.Add(slaveInfo); } } if (slaves.Count > 0) { Slaves = slaves.ToArray(); } } } } } }