public override bool Enter(IObjectDescriptor value, IEmitter context)
        {
            IYamlTypeConverter yamlTypeConverter = typeConverters.FirstOrDefault((IYamlTypeConverter t) => t.Accepts(value.Type));

            if (yamlTypeConverter != null)
            {
                yamlTypeConverter.WriteYaml(context, value.Value, value.Type);
                return(false);
            }
            IYamlConvertible yamlConvertible = value.Value as IYamlConvertible;

            if (yamlConvertible != null)
            {
                yamlConvertible.Write(context, nestedObjectSerializer);
                return(false);
            }
            IYamlSerializable yamlSerializable = value.Value as IYamlSerializable;

            if (yamlSerializable != null)
            {
                yamlSerializable.WriteYaml(context);
                return(false);
            }
            return(base.Enter(value, context));
        }
Ejemplo n.º 2
0
        public void Test_Writing_A_Valid_Identifier()
        {
            string identifier = "TOA2";

            converter.WriteYaml(emitter, Identifier.From(identifier), IDENTIFIER_TYPE);

            emitter.Received().Emit(Arg.Do <Scalar>(scalar =>
            {
                scalar.Tag.Should().BeNull();

                scalar.Value.Should().Be(identifier);
            }));
        }