Vixen
02b45cc4
csharp
public static class YamlScalarConverters

Every type that is one scalar in a document rather than a mapping.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

A registry rather than a chain of if (type == typeof(…)) in the binder, because the set is open: Vector3, Color4 and Rectangle all want to be one scalar and none of them can be named from here without Vixen.Core.Yaml depending on the mathematics. An assembly registers its own on the way past.

Delegates rather than a generic interface, deliberately. IYamlScalar<T> would read better and would need MakeGenericMethod to invoke for a type only known at run time, which is the one thing NativeAOT cannot do — see CollectionFactory for the same argument reached from the other direction.

Methods (2)

  • public static void Register(Type type, Func<string, object> parse, Func<object, string> format, YamlScalarStyle style = Any, bool acceptsNull = false)

    Records how a type is written as one scalar.

  • public static bool TryGet(Type type, out YamlScalarConverter? converter)

    Looks up how a type is written.

Used by (3)

  • MathScalarsVixen.Core.Yaml
  • YamlSerializerVixen.Core.Yaml
  • SceneScalarsVixen.Editor.Core