|
| 1 | +#nullable enable |
| 2 | + |
1 | 3 | using System; |
2 | 4 | using System.Net.Http; |
3 | 5 | using System.Text.Json; |
@@ -46,20 +48,36 @@ public static async Task<string> FetchDomSerializer() |
46 | 48 | } |
47 | 49 | } |
48 | 50 |
|
49 | | - public static async Task<string> PostSnapshot(DomObject snapshot, string pkg, object options = null) |
| 51 | + public static async Task<string> PostSnapshot(DomObject snapshot, string pkg, Dictionary<string, object>? options =null) |
50 | 52 | { |
51 | 53 | try |
52 | 54 | { |
53 | | - object snapshotObject = new |
| 55 | + // object snapshotObject = new |
| 56 | + // { |
| 57 | + // dom = snapshot.Dom, |
| 58 | + // name = snapshot.Name, |
| 59 | + // url = snapshot.Url |
| 60 | + // }; |
| 61 | + |
| 62 | + // var jsonObject = new |
| 63 | + // { |
| 64 | + // snapshot = options != null ? new { dom = snapshot.Dom, name = snapshot.Name, url = snapshot.Url, options } : snapshotObject, |
| 65 | + // testType = pkg |
| 66 | + // }; |
| 67 | + |
| 68 | + // var json = JsonSerializer.Serialize(jsonObject); |
| 69 | + |
| 70 | + var snapshotData = new SnapshotData |
54 | 71 | { |
55 | 72 | dom = snapshot.Dom, |
56 | 73 | name = snapshot.Name, |
57 | | - url = snapshot.Url |
| 74 | + url = snapshot.Url, |
| 75 | + options = options ?? new Dictionary<string, object>() |
58 | 76 | }; |
59 | 77 |
|
60 | 78 | var jsonObject = new |
61 | 79 | { |
62 | | - snapshot = options != null ? new { dom = snapshot.Dom, name = snapshot.Name, url = snapshot.Url, options } : snapshotObject, |
| 80 | + snapshot = snapshotData, |
63 | 81 | testType = pkg |
64 | 82 | }; |
65 | 83 |
|
@@ -95,5 +113,13 @@ public class DomObject |
95 | 113 | public string Url { get; set; } = string.Empty; |
96 | 114 | public string Name { get; set; } = string.Empty; |
97 | 115 | } |
| 116 | + |
| 117 | + public class SnapshotData |
| 118 | + { |
| 119 | + public DomContent? dom { get; set; } |
| 120 | + public string? name { get; set; } |
| 121 | + public string? url { get; set; } |
| 122 | + public Dictionary<string, object>? options { get; set; } // Nullable for handling cases with or without options |
| 123 | + } |
98 | 124 | } |
99 | 125 | } |
0 commit comments