Inheritance: IEmitter
Exemplo n.º 1
0
        public Serializer(Emitter/*!*/ emitter, YamlOptions/*!*/ opts) {
            ContractUtils.RequiresNotNull(emitter, "emitter");

            _emitter = emitter;
            _useExplicitStart = opts.ExplicitStart;
            _useExplicitEnd = opts.ExplicitEnd;
            if (opts.UseVersion) {
                _useVersion = opts.Version;
            }
            _anchorTemplate = opts.AnchorFormat ?? "id{0:000}";
            _emitter.Emit(StreamStartEvent.Instance);
        }
Exemplo n.º 2
0
        public static MutableString QuickEmit(RubyContext/*!*/ context, [NotNull]BlockParam/*!*/ block, RubyModule/*!*/ self, object objectId, [NotNull]Hash/*!*/ opts) {
            YamlOptions cfg = YamlOptions.DefaultOptions;
            MutableStringWriter writer = new MutableStringWriter();
            Emitter emitter = new Emitter(writer, cfg);

            using (Serializer s = new Serializer(emitter, cfg)) {
                RubyRepresenter r = new RubyRepresenter(context, s, cfg);
                object result;
                block.Yield(r, out result);
                s.Serialize(result as Node);

                return writer.String;
            }
        }
Exemplo n.º 3
0
        public static object QuickEmit(RubyContext/*!*/ context, [NotNull]BlockParam/*!*/ block, RubyModule/*!*/ self, object objectId, [NotNull]Hash/*!*/ opts) {
            YamlOptions cfg = YamlOptions.DefaultOptions;
            
            // TODO: encoding
            MutableStringWriter writer = new MutableStringWriter(MutableString.CreateMutable(RubyEncoding.UTF8));
            Emitter emitter = new Emitter(writer, cfg);

            using (Serializer s = new Serializer(emitter, cfg)) {
                RubyRepresenter r = new RubyRepresenter(context, s, cfg);
                object result;

                if (block.Yield(r, out result)) {
                    return result;
                }

                s.Serialize(result as Node);
                return writer.String;
            }
        }