openai/openai-dotnet
Publicmirrored from https://github.com/openai/openai-dotnetAvailable
src/Generated/Internal/Optional.cs
48lines · modecode
| 1 | // <auto-generated/> |
| 2 | |
| 3 | #nullable disable |
| 4 | |
| 5 | using System.Collections.Generic; |
| 6 | using System.Text.Json; |
| 7 | |
| 8 | namespace OpenAI |
| 9 | { |
| 10 | internal static class Optional |
| 11 | { |
| 12 | public static bool IsCollectionDefined<T>(IEnumerable<T> collection) |
| 13 | { |
| 14 | return !(collection is ChangeTrackingList<T> changeTrackingList && changeTrackingList.IsUndefined); |
| 15 | } |
| 16 | |
| 17 | public static bool IsCollectionDefined<TKey, TValue>(IDictionary<TKey, TValue> collection) |
| 18 | { |
| 19 | return !(collection is ChangeTrackingDictionary<TKey, TValue> changeTrackingDictionary && changeTrackingDictionary.IsUndefined); |
| 20 | } |
| 21 | |
| 22 | public static bool IsCollectionDefined<TKey, TValue>(IReadOnlyDictionary<TKey, TValue> collection) |
| 23 | { |
| 24 | return !(collection is ChangeTrackingDictionary<TKey, TValue> changeTrackingDictionary && changeTrackingDictionary.IsUndefined); |
| 25 | } |
| 26 | |
| 27 | public static bool IsDefined<T>(T? value) |
| 28 | where T : struct |
| 29 | { |
| 30 | return value.HasValue; |
| 31 | } |
| 32 | |
| 33 | public static bool IsDefined(object value) |
| 34 | { |
| 35 | return value != null; |
| 36 | } |
| 37 | |
| 38 | public static bool IsDefined(JsonElement value) |
| 39 | { |
| 40 | return value.ValueKind != JsonValueKind.Undefined; |
| 41 | } |
| 42 | |
| 43 | public static bool IsDefined(string value) |
| 44 | { |
| 45 | return value != null; |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | |