Skip to content
DocsTry Aspire
DocsTry

IntOrStringYamlConverter Methods

ClassMethods3 members
Provides a custom YAML type converter that facilitates serialization and deserialization of objects of type Int32OrStringV1. This converter supports both integers and strings.
Determines whether the given type is supported by this YAML type converter.
public class IntOrStringYamlConverter
{
public bool Accepts(
Type type)
{
// ...
}
}
typeTypeThe type to check for compatibility with the YAML converter.
boolReturns true if the specified type is Int32OrStringV1, otherwise false.
ReadYaml(IParser, Type, ObjectDeserializer)Section titled ReadYaml(IParser, Type, ObjectDeserializer)nullableobject?
Reads a YAML scalar from the parser and converts it into an instance of Int32OrStringV1.
public class IntOrStringYamlConverter
{
public object? ReadYaml(
IParser parser,
Type type,
ObjectDeserializer rootDeserializer)
{
// ...
}
}
parserIParserThe YAML parser to read the scalar value from.
typeTypeThe target type for deserialization, expected to be Int32OrStringV1.
rootDeserializerObjectDeserializerThe root deserializer used for handling nested deserialization.
object?Returns an instance of Int32OrStringV1 constructed from the parsed scalar value.
InvalidOperationExceptionThrown if the current YAML event is not a scalar.
WriteYaml(IEmitter, object?, Type, ObjectSerializer)Section titled WriteYaml(IEmitter, object?, Type, ObjectSerializer)
Writes the given object to the provided YAML emitter using the appropriate format.
public class IntOrStringYamlConverter
{
public void WriteYaml(
IEmitter emitter,
object? value,
Type type,
ObjectSerializer serializer)
{
// ...
}
}
emitterIEmitterThe emitter used to write the YAML output.
valueobject?The object to be serialized. Expected to be of type Int32OrStringV1.
typeTypeThe type of the object being serialized.
serializerObjectSerializerThe serializer to be used for complex object serialization.
InvalidOperationExceptionThrown when the provided value is not of type Int32OrStringV1.