236 lines
7.1 KiB
C#
236 lines
7.1 KiB
C#
// <auto-generated />
|
|
//
|
|
// To parse this JSON data, add NuGet 'System.Text.Json' then do:
|
|
//
|
|
// using QuickType;
|
|
//
|
|
// var welcome = Welcome.FromJson(jsonString);
|
|
#nullable enable
|
|
#pragma warning disable CS8618
|
|
#pragma warning disable CS8601
|
|
#pragma warning disable CS8603
|
|
|
|
namespace QuickType
|
|
{
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
using System.Globalization;
|
|
|
|
public partial class DocDb
|
|
{
|
|
[JsonPropertyName("Code")]
|
|
public string Code { get; set; }
|
|
|
|
[JsonPropertyName("Data")]
|
|
public Data Data { get; set; }
|
|
|
|
[JsonPropertyName("Message")]
|
|
public string Message { get; set; }
|
|
|
|
[JsonPropertyName("RequestId")]
|
|
public string RequestId { get; set; }
|
|
|
|
[JsonPropertyName("Status")]
|
|
public long Status { get; set; }
|
|
|
|
[JsonPropertyName("Success")]
|
|
public bool Success { get; set; }
|
|
}
|
|
|
|
public partial class Data
|
|
{
|
|
[JsonPropertyName("Nodes")]
|
|
public List<Node> Nodes { get; set; }
|
|
}
|
|
|
|
public partial class Node
|
|
{
|
|
[JsonPropertyName("Metadata")]
|
|
public Metadata Metadata { get; set; }
|
|
|
|
[JsonPropertyName("Score")]
|
|
public double Score { get; set; }
|
|
|
|
[JsonPropertyName("Text")]
|
|
public string Text { get; set; }
|
|
}
|
|
|
|
public partial class Metadata
|
|
{
|
|
[JsonPropertyName("parent")]
|
|
public string Parent { get; set; }
|
|
|
|
[JsonPropertyName("file_path")]
|
|
public Uri FilePath { get; set; }
|
|
|
|
[JsonPropertyName("image_url")]
|
|
public List<Uri> ImageUrl { get; set; }
|
|
|
|
[JsonPropertyName("nid")]
|
|
public string Nid { get; set; }
|
|
|
|
[JsonPropertyName("title")]
|
|
public string Title { get; set; }
|
|
|
|
[JsonPropertyName("doc_id")]
|
|
public string DocId { get; set; }
|
|
|
|
[JsonPropertyName("content")]
|
|
public string Content { get; set; }
|
|
|
|
[JsonPropertyName("workspace_id")]
|
|
public string WorkspaceId { get; set; }
|
|
|
|
[JsonPropertyName("hier_title")]
|
|
public string HierTitle { get; set; }
|
|
|
|
[JsonPropertyName("doc_name")]
|
|
public string DocName { get; set; }
|
|
|
|
[JsonPropertyName("pipeline_id")]
|
|
public string PipelineId { get; set; }
|
|
|
|
[JsonPropertyName("_id")]
|
|
public string Id { get; set; }
|
|
}
|
|
|
|
public partial class Welcome
|
|
{
|
|
public static Welcome FromJson(string json) => JsonSerializer.Deserialize<Welcome>(json, QuickType.Converter.Settings);
|
|
}
|
|
|
|
public static class Serialize
|
|
{
|
|
public static string ToJson(this Welcome self) => JsonSerializer.Serialize(self, QuickType.Converter.Settings);
|
|
}
|
|
|
|
internal static class Converter
|
|
{
|
|
public static readonly JsonSerializerOptions Settings = new(JsonSerializerDefaults.General)
|
|
{
|
|
Converters =
|
|
{
|
|
new DateOnlyConverter(),
|
|
new TimeOnlyConverter(),
|
|
IsoDateTimeOffsetConverter.Singleton
|
|
},
|
|
};
|
|
}
|
|
|
|
public class DateOnlyConverter : JsonConverter<DateOnly>
|
|
{
|
|
private readonly string serializationFormat;
|
|
public DateOnlyConverter() : this(null) { }
|
|
|
|
public DateOnlyConverter(string? serializationFormat)
|
|
{
|
|
this.serializationFormat = serializationFormat ?? "yyyy-MM-dd";
|
|
}
|
|
|
|
public override DateOnly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
|
{
|
|
var value = reader.GetString();
|
|
return DateOnly.Parse(value!);
|
|
}
|
|
|
|
public override void Write(Utf8JsonWriter writer, DateOnly value, JsonSerializerOptions options)
|
|
=> writer.WriteStringValue(value.ToString(serializationFormat));
|
|
}
|
|
|
|
public class TimeOnlyConverter : JsonConverter<TimeOnly>
|
|
{
|
|
private readonly string serializationFormat;
|
|
|
|
public TimeOnlyConverter() : this(null) { }
|
|
|
|
public TimeOnlyConverter(string? serializationFormat)
|
|
{
|
|
this.serializationFormat = serializationFormat ?? "HH:mm:ss.fff";
|
|
}
|
|
|
|
public override TimeOnly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
|
{
|
|
var value = reader.GetString();
|
|
return TimeOnly.Parse(value!);
|
|
}
|
|
|
|
public override void Write(Utf8JsonWriter writer, TimeOnly value, JsonSerializerOptions options)
|
|
=> writer.WriteStringValue(value.ToString(serializationFormat));
|
|
}
|
|
|
|
internal class IsoDateTimeOffsetConverter : JsonConverter<DateTimeOffset>
|
|
{
|
|
public override bool CanConvert(Type t) => t == typeof(DateTimeOffset);
|
|
|
|
private const string DefaultDateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK";
|
|
|
|
private DateTimeStyles _dateTimeStyles = DateTimeStyles.RoundtripKind;
|
|
private string? _dateTimeFormat;
|
|
private CultureInfo? _culture;
|
|
|
|
public DateTimeStyles DateTimeStyles
|
|
{
|
|
get => _dateTimeStyles;
|
|
set => _dateTimeStyles = value;
|
|
}
|
|
|
|
public string? DateTimeFormat
|
|
{
|
|
get => _dateTimeFormat ?? string.Empty;
|
|
set => _dateTimeFormat = (string.IsNullOrEmpty(value)) ? null : value;
|
|
}
|
|
|
|
public CultureInfo Culture
|
|
{
|
|
get => _culture ?? CultureInfo.CurrentCulture;
|
|
set => _culture = value;
|
|
}
|
|
|
|
public override void Write(Utf8JsonWriter writer, DateTimeOffset value, JsonSerializerOptions options)
|
|
{
|
|
string text;
|
|
|
|
|
|
if ((_dateTimeStyles & DateTimeStyles.AdjustToUniversal) == DateTimeStyles.AdjustToUniversal
|
|
|| (_dateTimeStyles & DateTimeStyles.AssumeUniversal) == DateTimeStyles.AssumeUniversal)
|
|
{
|
|
value = value.ToUniversalTime();
|
|
}
|
|
|
|
text = value.ToString(_dateTimeFormat ?? DefaultDateTimeFormat, Culture);
|
|
|
|
writer.WriteStringValue(text);
|
|
}
|
|
|
|
public override DateTimeOffset Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
|
{
|
|
string? dateText = reader.GetString();
|
|
|
|
if (string.IsNullOrEmpty(dateText) == false)
|
|
{
|
|
if (!string.IsNullOrEmpty(_dateTimeFormat))
|
|
{
|
|
return DateTimeOffset.ParseExact(dateText, _dateTimeFormat, Culture, _dateTimeStyles);
|
|
}
|
|
else
|
|
{
|
|
return DateTimeOffset.Parse(dateText, Culture, _dateTimeStyles);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return default(DateTimeOffset);
|
|
}
|
|
}
|
|
|
|
|
|
public static readonly IsoDateTimeOffsetConverter Singleton = new IsoDateTimeOffsetConverter();
|
|
}
|
|
}
|
|
#pragma warning restore CS8618
|
|
#pragma warning restore CS8601
|
|
#pragma warning restore CS8603
|