Commit 2855c627 authored by Nick Craver's avatar Nick Craver

Cleanup: ClientInfo

parent 40ed8d7b
...@@ -50,15 +50,7 @@ public sealed class ClientInfo ...@@ -50,15 +50,7 @@ public sealed class ClientInfo
/// <summary> /// <summary>
/// The host of the client (typically an IP address) /// The host of the client (typically an IP address)
/// </summary> /// </summary>
public string Host public string Host => Format.TryGetHostPort(Address, out string host, out _) ? host : null;
{
get
{
string host;
int port;
return Format.TryGetHostPort(Address, out host, out port) ? host : null;
}
}
/// <summary> /// <summary>
/// idle time of the connection in seconds /// idle time of the connection in seconds
...@@ -83,15 +75,8 @@ public string Host ...@@ -83,15 +75,8 @@ public string Host
/// <summary> /// <summary>
/// The port of the client /// The port of the client
/// </summary> /// </summary>
public int Port public int Port => Format.TryGetHostPort(Address, out _, out int port) ? port : 0;
{
get
{
string host;
int port;
return Format.TryGetHostPort(Address, out host, out port) ? port : 0;
}
}
/// <summary> /// <summary>
/// The raw content from redis /// The raw content from redis
/// </summary> /// </summary>
...@@ -130,7 +115,7 @@ public ClientType ClientType ...@@ -130,7 +115,7 @@ public ClientType ClientType
{ {
if (SubscriptionCount != 0 || PatternSubscriptionCount != 0) return ClientType.PubSub; if (SubscriptionCount != 0 || PatternSubscriptionCount != 0) return ClientType.PubSub;
if ((Flags & ClientFlags.Slave) != 0) return ClientType.Slave; if ((Flags & ClientFlags.Slave) != 0) return ClientType.Slave;
return ClientType.Normal; return ClientType.Normal;
} }
} }
...@@ -144,8 +129,10 @@ internal static ClientInfo[] Parse(string input) ...@@ -144,8 +129,10 @@ internal static ClientInfo[] Parse(string input)
string line; string line;
while ((line = reader.ReadLine()) != null) while ((line = reader.ReadLine()) != null)
{ {
var client = new ClientInfo(); var client = new ClientInfo
client.Raw = line; {
Raw = line
};
string[] tokens = line.Split(StringSplits.Space); string[] tokens = line.Split(StringSplits.Space);
for (int i = 0; i < tokens.Length; i++) for (int i = 0; i < tokens.Length; i++)
{ {
...@@ -189,7 +176,7 @@ internal static ClientInfo[] Parse(string input) ...@@ -189,7 +176,7 @@ internal static ClientInfo[] Parse(string input)
return clients.ToArray(); return clients.ToArray();
} }
static void AddFlag(ref ClientFlags value, string raw, ClientFlags toAdd, char token) private static void AddFlag(ref ClientFlags value, string raw, ClientFlags toAdd, char token)
{ {
if (raw.IndexOf(token) >= 0) value |= toAdd; if (raw.IndexOf(token) >= 0) value |= toAdd;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment