-
Notifications
You must be signed in to change notification settings - Fork 3
[CDX-372] Add support for arbitrary redirect data #93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using Newtonsoft.Json; | ||
|
|
||
| /** | ||
|
|
@@ -16,5 +17,21 @@ public class RedirectData | |
|
|
||
| [JsonProperty("match_id")] | ||
| public int MatchId { get; set; } | ||
|
|
||
| [JsonExtensionData] | ||
| private Dictionary<string, object> _additionalData; | ||
|
|
||
| /// <summary> | ||
| /// Indexer for accessing arbitrary metadata keys | ||
| /// </summary> | ||
| public object this[string key] | ||
| { | ||
| get => _additionalData?.TryGetValue(key, out var value) == true ? value : null; | ||
| set | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really need a setter here? RedirectData comes from the API response, users read it, they don't construct it themselves AFAIU 🤔
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's fair. I thought about this for a bit as well. I thought it might be helpful for testing in the future and I wanted to keep it consistent with other attributes of this call. But I agree, it's not necessary 🤔 |
||
| { | ||
| _additionalData ??= new Dictionary<string, object>(); | ||
| _additionalData[key] = value; | ||
| } | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The private field
_additionalDatais not accessible to consumers who might need to enumerate all additional data keys. Consider adding a public method or property to expose the keys or entries, such asIEnumerable<string> GetAdditionalDataKeys()or a read-only view of the dictionary.