Class MosaicJsonContext
System.Text.Json source-generation context for MOSAIC configuration types.
Inheritance
MosaicJsonContext
Assembly: MOSAIC.dll
Syntax
[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase, ReadCommentHandling = JsonCommentHandling.Skip, AllowTrailingCommas = true, NumberHandling = JsonNumberHandling.AllowReadingFromString, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)]
[JsonSerializable(typeof(JsonModel))]
[JsonSerializable(typeof(Dictionary<string, JsonModel>))]
internal class MosaicJsonContext : JsonSerializerContext, IJsonTypeInfoResolver
Constructors
MosaicJsonContext()
Declaration
public MosaicJsonContext()
MosaicJsonContext(JsonSerializerOptions)
Declaration
public MosaicJsonContext(JsonSerializerOptions options)
Parameters
| Type |
Name |
Description |
| JsonSerializerOptions |
options |
The run time provided options for the context instance.
|
Fields
InstanceMemberBindingFlags
Declaration
private const BindingFlags InstanceMemberBindingFlags = Instance | Public | NonPublic
Field Value
_DictionaryStringJsonModel
Declaration
private JsonTypeInfo<Dictionary<string, JsonModel>>? _DictionaryStringJsonModel
Field Value
_Double
Declaration
private JsonTypeInfo<double>? _Double
Field Value
_IReadOnlyListObject
Declaration
private JsonTypeInfo<IReadOnlyList<object>>? _IReadOnlyListObject
Field Value
_IReadOnlyListString
Declaration
private JsonTypeInfo<IReadOnlyList<string>>? _IReadOnlyListString
Field Value
_Int32
Declaration
private JsonTypeInfo<int>? _Int32
Field Value
_JsonModel
Declaration
private JsonTypeInfo<JsonModel>? _JsonModel
Field Value
_NullableDouble
Declaration
private JsonTypeInfo<double?>? _NullableDouble
Field Value
_Object
Declaration
private JsonTypeInfo<object>? _Object
Field Value
_String
Declaration
private JsonTypeInfo<string>? _String
Field Value
s_defaultOptions
Declaration
private static readonly JsonSerializerOptions s_defaultOptions
Field Value
Properties
Default
Declaration
public static MosaicJsonContext Default { get; }
Property Value
DictionaryStringJsonModel
Defines the source generated JSON serialization contract metadata for a given type.
Declaration
public JsonTypeInfo<Dictionary<string, JsonModel>> DictionaryStringJsonModel { get; }
Property Value
Double
Defines the source generated JSON serialization contract metadata for a given type.
Declaration
public JsonTypeInfo<double> Double { get; }
Property Value
GeneratedSerializerOptions
The source-generated options associated with this context.
Declaration
protected override JsonSerializerOptions? GeneratedSerializerOptions { get; }
Property Value
Overrides
IReadOnlyListObject
Defines the source generated JSON serialization contract metadata for a given type.
Declaration
public JsonTypeInfo<IReadOnlyList<object>> IReadOnlyListObject { get; }
Property Value
IReadOnlyListString
Defines the source generated JSON serialization contract metadata for a given type.
Declaration
public JsonTypeInfo<IReadOnlyList<string>> IReadOnlyListString { get; }
Property Value
Int32
Defines the source generated JSON serialization contract metadata for a given type.
Declaration
public JsonTypeInfo<int> Int32 { get; }
Property Value
JsonModel
Defines the source generated JSON serialization contract metadata for a given type.
Declaration
public JsonTypeInfo<JsonModel> JsonModel { get; }
Property Value
NullableDouble
Defines the source generated JSON serialization contract metadata for a given type.
Declaration
public JsonTypeInfo<double?> NullableDouble { get; }
Property Value
Object
Defines the source generated JSON serialization contract metadata for a given type.
Declaration
public JsonTypeInfo<object> Object { get; }
Property Value
String
Defines the source generated JSON serialization contract metadata for a given type.
Declaration
public JsonTypeInfo<string> String { get; }
Property Value
Methods
Create_DictionaryStringJsonModel(JsonSerializerOptions)
Declaration
private JsonTypeInfo<Dictionary<string, JsonModel>> Create_DictionaryStringJsonModel(JsonSerializerOptions options)
Parameters
Returns
Create_Double(JsonSerializerOptions)
Declaration
private JsonTypeInfo<double> Create_Double(JsonSerializerOptions options)
Parameters
Returns
Create_IReadOnlyListObject(JsonSerializerOptions)
Declaration
private JsonTypeInfo<IReadOnlyList<object>> Create_IReadOnlyListObject(JsonSerializerOptions options)
Parameters
Returns
Create_IReadOnlyListString(JsonSerializerOptions)
Declaration
private JsonTypeInfo<IReadOnlyList<string>> Create_IReadOnlyListString(JsonSerializerOptions options)
Parameters
Returns
Create_Int32(JsonSerializerOptions)
Declaration
private JsonTypeInfo<int> Create_Int32(JsonSerializerOptions options)
Parameters
Returns
Create_JsonModel(JsonSerializerOptions)
Declaration
private JsonTypeInfo<JsonModel> Create_JsonModel(JsonSerializerOptions options)
Parameters
Returns
Create_NullableDouble(JsonSerializerOptions)
Declaration
private JsonTypeInfo<double?> Create_NullableDouble(JsonSerializerOptions options)
Parameters
Returns
Create_Object(JsonSerializerOptions)
Declaration
private JsonTypeInfo<object> Create_Object(JsonSerializerOptions options)
Parameters
Returns
Create_String(JsonSerializerOptions)
Declaration
private JsonTypeInfo<string> Create_String(JsonSerializerOptions options)
Parameters
Returns
DictionaryStringJsonModelSerializeHandler(Utf8JsonWriter, Dictionary<string, JsonModel>?)
Declaration
private void DictionaryStringJsonModelSerializeHandler(Utf8JsonWriter writer, Dictionary<string, JsonModel>? value)
Parameters
ExpandConverter(Type, JsonConverter, JsonSerializerOptions, bool)
Declaration
private static JsonConverter ExpandConverter(Type type, JsonConverter converter, JsonSerializerOptions options, bool validateCanConvert = true)
Parameters
Returns
GetRuntimeConverterForType(Type, JsonSerializerOptions)
Declaration
private static JsonConverter? GetRuntimeConverterForType(Type type, JsonSerializerOptions options)
Parameters
Returns
GetTypeInfo(Type)
Gets metadata for the specified type.
Declaration
public override JsonTypeInfo? GetTypeInfo(Type type)
Parameters
| Type |
Name |
Description |
| Type |
type |
The type to fetch metadata for.
|
Returns
| Type |
Description |
| JsonTypeInfo |
The metadata for the specified type, or null if the context has no metadata for the type.
|
Overrides
IReadOnlyListStringSerializeHandler(Utf8JsonWriter, IReadOnlyList<string>?)
Declaration
private void IReadOnlyListStringSerializeHandler(Utf8JsonWriter writer, IReadOnlyList<string>? value)
Parameters
JsonModelCtorParamInit()
Declaration
private static JsonParameterInfoValues[] JsonModelCtorParamInit()
Returns
| Type |
Description |
| JsonParameterInfoValues[] |
|
JsonModelPropInit(JsonSerializerOptions)
Declaration
private static JsonPropertyInfo[] JsonModelPropInit(JsonSerializerOptions options)
Parameters
Returns
TryGetTypeInfoForRuntimeCustomConverter<TJsonMetadataType>(JsonSerializerOptions, out JsonTypeInfo<TJsonMetadataType>)
Declaration
private static bool TryGetTypeInfoForRuntimeCustomConverter<TJsonMetadataType>(JsonSerializerOptions options, out JsonTypeInfo<TJsonMetadataType> jsonTypeInfo)
Parameters
Returns
Type Parameters
| Name |
Description |
| TJsonMetadataType |
|
Explicit Interface Implementations
IJsonTypeInfoResolver.GetTypeInfo(Type, JsonSerializerOptions)
Resolves a JsonTypeInfo contract for the requested type and options.
Declaration
JsonTypeInfo? IJsonTypeInfoResolver.GetTypeInfo(Type type, JsonSerializerOptions options)
Parameters
| Type |
Name |
Description |
| Type |
type |
Type to be resolved.
|
| JsonSerializerOptions |
options |
Configuration used when resolving the metadata.
|
Returns
Implements