| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System.Diagnostics.CodeAnalysis; |
| | | 5 | | using System.Text.Json.Serialization.Metadata; |
| | | 6 | | |
| | | 7 | | namespace System.Text.Json.Nodes |
| | | 8 | | { |
| | | 9 | | public partial class JsonValue |
| | | 10 | | { |
| | | 11 | | /// <summary> |
| | | 12 | | /// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value. |
| | | 13 | | /// </summary> |
| | | 14 | | /// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param> |
| | | 15 | | /// <param name="options">Options to control the behavior.</param> |
| | | 16 | | /// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns> |
| | 0 | 17 | | public static JsonValue Create(bool value, JsonNodeOptions? options = null) => new JsonValuePrimitive<bool>(valu |
| | | 18 | | |
| | | 19 | | /// <summary> |
| | | 20 | | /// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value. |
| | | 21 | | /// </summary> |
| | | 22 | | /// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param> |
| | | 23 | | /// <param name="options">Options to control the behavior.</param> |
| | | 24 | | /// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns> |
| | 0 | 25 | | public static JsonValue? Create(bool? value, JsonNodeOptions? options = null) => value.HasValue ? new JsonValueP |
| | | 26 | | |
| | | 27 | | /// <summary> |
| | | 28 | | /// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value. |
| | | 29 | | /// </summary> |
| | | 30 | | /// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param> |
| | | 31 | | /// <param name="options">Options to control the behavior.</param> |
| | | 32 | | /// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns> |
| | 0 | 33 | | public static JsonValue Create(byte value, JsonNodeOptions? options = null) => new JsonValuePrimitive<byte>(valu |
| | | 34 | | |
| | | 35 | | /// <summary> |
| | | 36 | | /// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value. |
| | | 37 | | /// </summary> |
| | | 38 | | /// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param> |
| | | 39 | | /// <param name="options">Options to control the behavior.</param> |
| | | 40 | | /// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns> |
| | 0 | 41 | | public static JsonValue? Create(byte? value, JsonNodeOptions? options = null) => value.HasValue ? new JsonValueP |
| | | 42 | | |
| | | 43 | | /// <summary> |
| | | 44 | | /// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value. |
| | | 45 | | /// </summary> |
| | | 46 | | /// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param> |
| | | 47 | | /// <param name="options">Options to control the behavior.</param> |
| | | 48 | | /// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns> |
| | 0 | 49 | | public static JsonValue Create(char value, JsonNodeOptions? options = null) => new JsonValuePrimitive<char>(valu |
| | | 50 | | |
| | | 51 | | /// <summary> |
| | | 52 | | /// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value. |
| | | 53 | | /// </summary> |
| | | 54 | | /// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param> |
| | | 55 | | /// <param name="options">Options to control the behavior.</param> |
| | | 56 | | /// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns> |
| | 0 | 57 | | public static JsonValue? Create(char? value, JsonNodeOptions? options = null) => value.HasValue ? new JsonValueP |
| | | 58 | | |
| | | 59 | | /// <summary> |
| | | 60 | | /// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value. |
| | | 61 | | /// </summary> |
| | | 62 | | /// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param> |
| | | 63 | | /// <param name="options">Options to control the behavior.</param> |
| | | 64 | | /// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns> |
| | 0 | 65 | | public static JsonValue Create(DateTime value, JsonNodeOptions? options = null) => new JsonValuePrimitive<DateTi |
| | | 66 | | |
| | | 67 | | /// <summary> |
| | | 68 | | /// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value. |
| | | 69 | | /// </summary> |
| | | 70 | | /// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param> |
| | | 71 | | /// <param name="options">Options to control the behavior.</param> |
| | | 72 | | /// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns> |
| | 0 | 73 | | public static JsonValue? Create(DateTime? value, JsonNodeOptions? options = null) => value.HasValue ? new JsonVa |
| | | 74 | | |
| | | 75 | | /// <summary> |
| | | 76 | | /// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value. |
| | | 77 | | /// </summary> |
| | | 78 | | /// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param> |
| | | 79 | | /// <param name="options">Options to control the behavior.</param> |
| | | 80 | | /// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns> |
| | 0 | 81 | | public static JsonValue Create(DateTimeOffset value, JsonNodeOptions? options = null) => new JsonValuePrimitive< |
| | | 82 | | |
| | | 83 | | /// <summary> |
| | | 84 | | /// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value. |
| | | 85 | | /// </summary> |
| | | 86 | | /// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param> |
| | | 87 | | /// <param name="options">Options to control the behavior.</param> |
| | | 88 | | /// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns> |
| | 0 | 89 | | public static JsonValue? Create(DateTimeOffset? value, JsonNodeOptions? options = null) => value.HasValue ? new |
| | | 90 | | |
| | | 91 | | /// <summary> |
| | | 92 | | /// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value. |
| | | 93 | | /// </summary> |
| | | 94 | | /// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param> |
| | | 95 | | /// <param name="options">Options to control the behavior.</param> |
| | | 96 | | /// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns> |
| | 0 | 97 | | public static JsonValue Create(decimal value, JsonNodeOptions? options = null) => new JsonValuePrimitive<decimal |
| | | 98 | | |
| | | 99 | | /// <summary> |
| | | 100 | | /// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value. |
| | | 101 | | /// </summary> |
| | | 102 | | /// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param> |
| | | 103 | | /// <param name="options">Options to control the behavior.</param> |
| | | 104 | | /// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns> |
| | 0 | 105 | | public static JsonValue? Create(decimal? value, JsonNodeOptions? options = null) => value.HasValue ? new JsonVal |
| | | 106 | | |
| | | 107 | | /// <summary> |
| | | 108 | | /// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value. |
| | | 109 | | /// </summary> |
| | | 110 | | /// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param> |
| | | 111 | | /// <param name="options">Options to control the behavior.</param> |
| | | 112 | | /// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns> |
| | 0 | 113 | | public static JsonValue Create(double value, JsonNodeOptions? options = null) => new JsonValuePrimitive<double>( |
| | | 114 | | |
| | | 115 | | /// <summary> |
| | | 116 | | /// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value. |
| | | 117 | | /// </summary> |
| | | 118 | | /// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param> |
| | | 119 | | /// <param name="options">Options to control the behavior.</param> |
| | | 120 | | /// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns> |
| | 0 | 121 | | public static JsonValue? Create(double? value, JsonNodeOptions? options = null) => value.HasValue ? new JsonValu |
| | | 122 | | |
| | | 123 | | /// <summary> |
| | | 124 | | /// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value. |
| | | 125 | | /// </summary> |
| | | 126 | | /// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param> |
| | | 127 | | /// <param name="options">Options to control the behavior.</param> |
| | | 128 | | /// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns> |
| | 0 | 129 | | public static JsonValue Create(Guid value, JsonNodeOptions? options = null) => new JsonValuePrimitive<Guid>(valu |
| | | 130 | | |
| | | 131 | | /// <summary> |
| | | 132 | | /// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value. |
| | | 133 | | /// </summary> |
| | | 134 | | /// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param> |
| | | 135 | | /// <param name="options">Options to control the behavior.</param> |
| | | 136 | | /// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns> |
| | 0 | 137 | | public static JsonValue? Create(Guid? value, JsonNodeOptions? options = null) => value.HasValue ? new JsonValueP |
| | | 138 | | |
| | | 139 | | /// <summary> |
| | | 140 | | /// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value. |
| | | 141 | | /// </summary> |
| | | 142 | | /// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param> |
| | | 143 | | /// <param name="options">Options to control the behavior.</param> |
| | | 144 | | /// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns> |
| | 0 | 145 | | public static JsonValue Create(short value, JsonNodeOptions? options = null) => new JsonValuePrimitive<short>(va |
| | | 146 | | |
| | | 147 | | /// <summary> |
| | | 148 | | /// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value. |
| | | 149 | | /// </summary> |
| | | 150 | | /// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param> |
| | | 151 | | /// <param name="options">Options to control the behavior.</param> |
| | | 152 | | /// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns> |
| | 0 | 153 | | public static JsonValue? Create(short? value, JsonNodeOptions? options = null) => value.HasValue ? new JsonValue |
| | | 154 | | |
| | | 155 | | /// <summary> |
| | | 156 | | /// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value. |
| | | 157 | | /// </summary> |
| | | 158 | | /// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param> |
| | | 159 | | /// <param name="options">Options to control the behavior.</param> |
| | | 160 | | /// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns> |
| | 0 | 161 | | public static JsonValue Create(int value, JsonNodeOptions? options = null) => new JsonValuePrimitive<int>(value, |
| | | 162 | | |
| | | 163 | | /// <summary> |
| | | 164 | | /// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value. |
| | | 165 | | /// </summary> |
| | | 166 | | /// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param> |
| | | 167 | | /// <param name="options">Options to control the behavior.</param> |
| | | 168 | | /// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns> |
| | 0 | 169 | | public static JsonValue? Create(int? value, JsonNodeOptions? options = null) => value.HasValue ? new JsonValuePr |
| | | 170 | | |
| | | 171 | | /// <summary> |
| | | 172 | | /// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value. |
| | | 173 | | /// </summary> |
| | | 174 | | /// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param> |
| | | 175 | | /// <param name="options">Options to control the behavior.</param> |
| | | 176 | | /// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns> |
| | 0 | 177 | | public static JsonValue Create(long value, JsonNodeOptions? options = null) => new JsonValuePrimitive<long>(valu |
| | | 178 | | |
| | | 179 | | /// <summary> |
| | | 180 | | /// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value. |
| | | 181 | | /// </summary> |
| | | 182 | | /// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param> |
| | | 183 | | /// <param name="options">Options to control the behavior.</param> |
| | | 184 | | /// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns> |
| | 0 | 185 | | public static JsonValue? Create(long? value, JsonNodeOptions? options = null) => value.HasValue ? new JsonValueP |
| | | 186 | | |
| | | 187 | | /// <summary> |
| | | 188 | | /// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value. |
| | | 189 | | /// </summary> |
| | | 190 | | /// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param> |
| | | 191 | | /// <param name="options">Options to control the behavior.</param> |
| | | 192 | | /// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns> |
| | | 193 | | [CLSCompliantAttribute(false)] |
| | 0 | 194 | | public static JsonValue Create(sbyte value, JsonNodeOptions? options = null) => new JsonValuePrimitive<sbyte>(va |
| | | 195 | | |
| | | 196 | | /// <summary> |
| | | 197 | | /// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value. |
| | | 198 | | /// </summary> |
| | | 199 | | /// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param> |
| | | 200 | | /// <param name="options">Options to control the behavior.</param> |
| | | 201 | | /// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns> |
| | | 202 | | [CLSCompliantAttribute(false)] |
| | 0 | 203 | | public static JsonValue? Create(sbyte? value, JsonNodeOptions? options = null) => value.HasValue ? new JsonValue |
| | | 204 | | |
| | | 205 | | /// <summary> |
| | | 206 | | /// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value. |
| | | 207 | | /// </summary> |
| | | 208 | | /// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param> |
| | | 209 | | /// <param name="options">Options to control the behavior.</param> |
| | | 210 | | /// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns> |
| | 0 | 211 | | public static JsonValue Create(float value, JsonNodeOptions? options = null) => new JsonValuePrimitive<float>(va |
| | | 212 | | |
| | | 213 | | /// <summary> |
| | | 214 | | /// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value. |
| | | 215 | | /// </summary> |
| | | 216 | | /// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param> |
| | | 217 | | /// <param name="options">Options to control the behavior.</param> |
| | | 218 | | /// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns> |
| | 0 | 219 | | public static JsonValue? Create(float? value, JsonNodeOptions? options = null) => value.HasValue ? new JsonValue |
| | | 220 | | |
| | | 221 | | /// <summary> |
| | | 222 | | /// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value. |
| | | 223 | | /// </summary> |
| | | 224 | | /// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param> |
| | | 225 | | /// <param name="options">Options to control the behavior.</param> |
| | | 226 | | /// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns> |
| | | 227 | | [return: NotNullIfNotNull(nameof(value))] |
| | 0 | 228 | | public static JsonValue? Create(string? value, JsonNodeOptions? options = null) => value != null ? new JsonValue |
| | | 229 | | |
| | | 230 | | /// <summary> |
| | | 231 | | /// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value. |
| | | 232 | | /// </summary> |
| | | 233 | | /// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param> |
| | | 234 | | /// <param name="options">Options to control the behavior.</param> |
| | | 235 | | /// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns> |
| | | 236 | | [CLSCompliantAttribute(false)] |
| | 0 | 237 | | public static JsonValue Create(ushort value, JsonNodeOptions? options = null) => new JsonValuePrimitive<ushort>( |
| | | 238 | | |
| | | 239 | | /// <summary> |
| | | 240 | | /// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value. |
| | | 241 | | /// </summary> |
| | | 242 | | /// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param> |
| | | 243 | | /// <param name="options">Options to control the behavior.</param> |
| | | 244 | | /// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns> |
| | | 245 | | [CLSCompliantAttribute(false)] |
| | 0 | 246 | | public static JsonValue? Create(ushort? value, JsonNodeOptions? options = null) => value.HasValue ? new JsonValu |
| | | 247 | | |
| | | 248 | | /// <summary> |
| | | 249 | | /// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value. |
| | | 250 | | /// </summary> |
| | | 251 | | /// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param> |
| | | 252 | | /// <param name="options">Options to control the behavior.</param> |
| | | 253 | | /// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns> |
| | | 254 | | [CLSCompliantAttribute(false)] |
| | 0 | 255 | | public static JsonValue Create(uint value, JsonNodeOptions? options = null) => new JsonValuePrimitive<uint>(valu |
| | | 256 | | |
| | | 257 | | /// <summary> |
| | | 258 | | /// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value. |
| | | 259 | | /// </summary> |
| | | 260 | | /// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param> |
| | | 261 | | /// <param name="options">Options to control the behavior.</param> |
| | | 262 | | /// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns> |
| | | 263 | | [CLSCompliantAttribute(false)] |
| | 0 | 264 | | public static JsonValue? Create(uint? value, JsonNodeOptions? options = null) => value.HasValue ? new JsonValueP |
| | | 265 | | |
| | | 266 | | /// <summary> |
| | | 267 | | /// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value. |
| | | 268 | | /// </summary> |
| | | 269 | | /// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param> |
| | | 270 | | /// <param name="options">Options to control the behavior.</param> |
| | | 271 | | /// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns> |
| | | 272 | | [CLSCompliantAttribute(false)] |
| | 0 | 273 | | public static JsonValue Create(ulong value, JsonNodeOptions? options = null) => new JsonValuePrimitive<ulong>(va |
| | | 274 | | |
| | | 275 | | /// <summary> |
| | | 276 | | /// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value. |
| | | 277 | | /// </summary> |
| | | 278 | | /// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param> |
| | | 279 | | /// <param name="options">Options to control the behavior.</param> |
| | | 280 | | /// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns> |
| | | 281 | | [CLSCompliantAttribute(false)] |
| | 0 | 282 | | public static JsonValue? Create(ulong? value, JsonNodeOptions? options = null) => value.HasValue ? new JsonValue |
| | | 283 | | |
| | | 284 | | /// <summary> |
| | | 285 | | /// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value. |
| | | 286 | | /// </summary> |
| | | 287 | | /// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param> |
| | | 288 | | /// <param name="options">Options to control the behavior.</param> |
| | | 289 | | /// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns> |
| | 0 | 290 | | public static JsonValue? Create(JsonElement value, JsonNodeOptions? options = null) => JsonValue.CreateFromEleme |
| | | 291 | | |
| | | 292 | | /// <summary> |
| | | 293 | | /// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value. |
| | | 294 | | /// </summary> |
| | | 295 | | /// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param> |
| | | 296 | | /// <param name="options">Options to control the behavior.</param> |
| | | 297 | | /// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns> |
| | 0 | 298 | | public static JsonValue? Create(JsonElement? value, JsonNodeOptions? options = null) => value is JsonElement ele |
| | | 299 | | } |
| | | 300 | | } |