public void Write(IFormatWriter writer, object instance)
            {
                var value   = _serializer.Access.Get(instance);
                var content = _converter.Format(value);

                writer.Content(content);
            }
示例#2
0
            public void Write(IFormatWriter writer, RootClass instance)
            {
                System.Xml.XmlWriter native = writer.Get().AsValid <System.Xml.XmlWriter>();                // if you need it.

                writer.Content(_name, instance.ManyToOneReference.Name);
                _serializer.Write(writer, instance);
            }
示例#3
0
        public void Write(IFormatWriter writer, RomBytes instance)
        {
            var options = new List <string>
            {
                $"version:{CurrentDataFormatVersion}",
            };

            var romByteEncoding = new RomByteEncoding();

            var lines = new List <string>();

            foreach (var rb in instance)
            {
                var encodedTxt = romByteEncoding.EncodeByte(rb);
                lines.Add(encodedTxt);

                // debug check, optional:
#if EXTRA_DEBUG_CHECKS
                var decoded = romByteEncoding.DecodeRomByte(encodedTxt);
                Debug.Assert(decoded.EqualsButNoRomByte(rb));
#endif
            }

            if (CompressGroupBlock)
            {
                options.Add("compress_groupblocks");
                RepeaterCompression.Compress(ref lines);
            }

            if (CompressUsingTable1)
            {
                options.Add("compress_table_1");
                SubstitutionCompression.EncodeCompression_Table1(ref lines);
            }

            writer.Content($"\n{string.Join(",", options)}\n");

            foreach (var line in lines)
            {
                writer.Content(line + "\n");
            }
        }
示例#4
0
        public void Write(IFormatWriter writer, object instance)
        {
            var type = instance?.GetType();

            if (type != null)
            {
                if (_type.IsSatisfiedBy(type))
                {
                    _property.Write(writer, type.GetTypeInfo());
                    _runtime.Write(writer, instance);
                }
                else
                {
                    _body.Write(writer, instance);
                }
            }
            else
            {
                writer.Content(null);
            }
        }
示例#5
0
 public void Write(IFormatWriter writer, T instance) => writer.Content(_identity, _formatter(writer, instance));
示例#6
0
 public void Write(IFormatWriter writer, IInterface instance)
 {
     writer.Content(instance.GetType().AssemblyQualifiedName);
 }
示例#7
0
 public void Write(IFormatWriter writer, string instance)
 {
     writer.Content($"Hello World! {instance}");
 }
示例#8
0
 public void Write(IFormatWriter writer, MemberInfo instance) => writer.Content(writer.Get(instance));
 public void Write(IFormatWriter writer, string instance)
 {
     writer.Content($"The registered encoding is: {_encoding.WebName}");
 }
示例#10
0
 public void Content(IIdentity property, string content)
 {
     _writer.Content(property, content);
 }
示例#11
0
 public void Write(IFormatWriter writer, DateTime instance)
 {
     writer.Content(_converter.Format(instance));
 }
示例#12
0
 public void Content(IIdentity identity, string content) => _writer.Content(identity, content);
示例#13
0
 public void Write(IFormatWriter writer, Subject instance)
 {
     writer.Content($"{instance.Text}|{instance.Number}");
 }
示例#14
0
 public void Write(IFormatWriter writer, RootClass instance)
 {
     writer.Content(_name, instance.ManyToOneReference.Name);
     _serializer.Write(writer, instance);
 }