Skip to content

Commit 3b79495

Browse files
committed
use TryGetValue
1 parent da82992 commit 3b79495

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/GraphQL.Client.Abstractions.Websocket/GraphQLWebSocketRequest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class GraphQLWebSocketRequest : Dictionary<string, object>, IEquatable<Gr
1818
/// </summary>
1919
public string Id
2020
{
21-
get => ContainsKey(ID_KEY) ? (string)this[ID_KEY] : null;
21+
get => TryGetValue(ID_KEY, out object value) ? (string)value : null;
2222
set => this[ID_KEY] = value;
2323
}
2424

@@ -27,7 +27,7 @@ public string Id
2727
/// </summary>
2828
public string Type
2929
{
30-
get => ContainsKey(TYPE_KEY) ? (string)this[TYPE_KEY] : null;
30+
get => TryGetValue(TYPE_KEY, out object value) ? (string)value : null;
3131
set => this[TYPE_KEY] = value;
3232
}
3333

@@ -36,7 +36,7 @@ public string Type
3636
/// </summary>
3737
public object Payload
3838
{
39-
get => ContainsKey(PAYLOAD_KEY) ? this[PAYLOAD_KEY] : null;
39+
get => TryGetValue(PAYLOAD_KEY, out object value) ? value : null;
4040
set => this[PAYLOAD_KEY] = value;
4141
}
4242

src/GraphQL.Primitives/GraphQLRequest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class GraphQLRequest : Dictionary<string, object>, IEquatable<GraphQLRequ
1818
/// </summary>
1919
public string Query
2020
{
21-
get => ContainsKey(QUERY_KEY) ? (string)this[QUERY_KEY] : null;
21+
get => TryGetValue(QUERY_KEY, out object value) ? (string)value : null;
2222
set => this[QUERY_KEY] = value;
2323
}
2424

@@ -27,7 +27,7 @@ public string Query
2727
/// </summary>
2828
public string? OperationName
2929
{
30-
get => ContainsKey(OPERATION_NAME_KEY) ? (string)this[OPERATION_NAME_KEY] : null;
30+
get => TryGetValue(OPERATION_NAME_KEY, out object value) ? (string)value : null;
3131
set => this[OPERATION_NAME_KEY] = value;
3232
}
3333

@@ -36,7 +36,7 @@ public string? OperationName
3636
/// </summary>
3737
public object? Variables
3838
{
39-
get => ContainsKey(VARIABLES_KEY) ? this[VARIABLES_KEY] : null;
39+
get => TryGetValue(VARIABLES_KEY, out object value) ? value : null;
4040
set => this[VARIABLES_KEY] = value;
4141
}
4242

0 commit comments

Comments
 (0)