Skip to content

Commit 473758f

Browse files
committed
Using switch case when possible
1 parent 1752f23 commit 473758f

File tree

3 files changed

+15
-27
lines changed

3 files changed

+15
-27
lines changed

src/net45/Default/WampSharp.WebSocket4Net/WAMP2/V2/Fluent/WebSocket4NetActivator.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,12 @@ public IControlledWampConnection<TMessage> Activate<TMessage>(IWampBinding<TMess
4242

4343
private IControlledWampConnection<TMessage> GetConnectionFactory<TMessage>(IWampBinding<TMessage> binding)
4444
{
45-
46-
if (binding is IWampTextBinding<TMessage> textBinding)
47-
{
48-
return CreateTextConnection(textBinding);
49-
}
50-
51-
52-
if (binding is IWampBinaryBinding<TMessage> binaryBinding)
45+
switch (binding)
5346
{
54-
return CreateBinaryConnection(binaryBinding);
47+
case IWampTextBinding<TMessage> textBinding:
48+
return CreateTextConnection(textBinding);
49+
case IWampBinaryBinding<TMessage> binaryBinding:
50+
return CreateBinaryConnection(binaryBinding);
5551
}
5652

5753
throw new Exception();

src/net45/Extensions/WampSharp.WebSockets/WAMP2/V2/Fluent/WebSocketActivator.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,12 @@ public IControlledWampConnection<TMessage> Activate<TMessage>(IWampBinding<TMess
3333

3434
private IControlledWampConnection<TMessage> GetConnectionFactory<TMessage>(IWampBinding<TMessage> binding)
3535
{
36-
37-
if (binding is IWampTextBinding<TMessage> textBinding)
38-
{
39-
return CreateTextConnection(textBinding);
40-
}
41-
42-
43-
if (binding is IWampBinaryBinding<TMessage> binaryBinding)
36+
switch (binding)
4437
{
45-
return CreateBinaryConnection(binaryBinding);
38+
case IWampTextBinding<TMessage> textBinding:
39+
return CreateTextConnection(textBinding);
40+
case IWampBinaryBinding<TMessage> binaryBinding:
41+
return CreateBinaryConnection(binaryBinding);
4642
}
4743

4844
throw new Exception();

src/net45/WampSharp/WAMP2/V2/Transports/TextBinaryTransport.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,12 @@ protected abstract IWampConnection<TMessage> CreateTextConnection<TMessage>
106106

107107
public IWampConnectionListener<TMessage> GetListener<TMessage>(IWampBinding<TMessage> binding)
108108
{
109-
110-
if (binding is IWampTextBinding<TMessage> textBinding)
111-
{
112-
return GetListener(textBinding);
113-
}
114-
115-
116-
if (binding is IWampBinaryBinding<TMessage> binaryBinding)
109+
switch (binding)
117110
{
118-
return GetListener(binaryBinding);
111+
case IWampTextBinding<TMessage> textBinding:
112+
return GetListener(textBinding);
113+
case IWampBinaryBinding<TMessage> binaryBinding:
114+
return GetListener(binaryBinding);
119115
}
120116

121117
throw new ArgumentException("WebSockets can only deal with binary/text transports", nameof(binding));

0 commit comments

Comments
 (0)