Remove casts where possible

This commit is contained in:
David Fowler 2016-11-02 22:17:03 -07:00
parent 7db1eb8f25
commit 0e690d636f
4 changed files with 6 additions and 6 deletions

View File

@ -127,7 +127,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis
private Task SubscribeAsync(string channel, Connection connection)
{
var redisConnection = connection.Metadata.GetOrAdd("redis", k =>
var redisConnection = connection.Metadata.GetOrAdd("redis", _ =>
{
var logger = _loggerFactory.CreateLogger("REDIS_" + connection.ConnectionId);
// TODO: Async

View File

@ -19,7 +19,7 @@ namespace Microsoft.AspNetCore.SignalR
public override Task AddGroupAsync(Connection connection, string groupName)
{
var groups = connection.Metadata.GetOrAdd("groups", k => new HashSet<string>());
var groups = connection.Metadata.GetOrAdd("groups", _ => new HashSet<string>());
lock (groups)
{
@ -63,7 +63,7 @@ namespace Microsoft.AspNetCore.SignalR
continue;
}
var invocationAdapter = _registry.GetInvocationAdapter((string)connection.Metadata["formatType"]);
var invocationAdapter = _registry.GetInvocationAdapter(connection.Metadata.Get<string>("formatType"));
tasks.Add(invocationAdapter.WriteInvocationDescriptorAsync(message, connection.Channel.GetStream()));
}
@ -75,7 +75,7 @@ namespace Microsoft.AspNetCore.SignalR
{
var connection = _connections[connectionId];
var invocationAdapter = _registry.GetInvocationAdapter((string)connection.Metadata["formatType"]);
var invocationAdapter = _registry.GetInvocationAdapter(connection.Metadata.Get<string>("formatType"));
var message = new InvocationDescriptor
{

View File

@ -36,7 +36,7 @@ namespace Microsoft.AspNetCore.SignalR
await Task.Yield();
var stream = connection.Channel.GetStream();
var invocationAdapter = _registry.GetInvocationAdapter((string)connection.Metadata["formatType"]);
var invocationAdapter = _registry.GetInvocationAdapter(connection.Metadata.Get<string>("formatType"));
while (true)
{

View File

@ -116,7 +116,7 @@ namespace Microsoft.AspNetCore.Sockets
else
{
// Get the endpoint task from connection state
endpointTask = (Task)state.Connection.Metadata["endpoint"];
endpointTask = state.Connection.Metadata.Get<Task>("endpoint");
}
var resultTask = await Task.WhenAny(endpointTask, transportTask);