public void Write(MutagenWriter writer, int item, long length)
        {
            switch (length)
            {
            case 1:
                writer.Write((byte)item);
                break;

            case 2:
                writer.Write((ushort)item);
                break;

            case 4:
                writer.Write(item);
                break;

            default:
                throw new NotImplementedException();
            }
        }
Example #2
0
 public void Dispose()
 {
     _tributary.Position = 0;
     if (_tributary.Length <= ushort.MaxValue)
     {
         using (HeaderExport.Subrecord(_writer, _mainRecord))
         {
             _tributary.CopyTo(_writer.BaseStream);
         }
     }
     else
     {
         using (HeaderExport.Subrecord(_writer, _extraLengthRecord))
         {
             _writer.Write(checked ((uint)_tributary.Length));
         }
         _writer.Write(_mainRecord.TypeInt);
         _writer.WriteZeros(2);
         _tributary.CopyTo(_writer.BaseStream);
     }
 }
Example #3
0
 public void WriteNullable(
     MutagenWriter writer,
     ITranslatedStringGetter?item,
     StringBinaryType binaryType,
     StringsSource source)
 {
     if (item == null)
     {
         return;
     }
     if (writer.MetaData.StringsWriter == null)
     {
         writer.Write(
             item.String ?? string.Empty,
             binaryType: binaryType);
     }
     else
     {
         writer.Write(writer.MetaData.StringsWriter.Register(item, source));
     }
 }
 public void Write(
     MutagenWriter writer,
     string item,
     RecordType header,
     StringBinaryType binaryType = StringBinaryType.NullTerminate)
 {
     using (HeaderExport.Header(writer, header, ObjectType.Subrecord))
     {
         writer.Write(
             item,
             binaryType: binaryType);
     }
 }
 public void WriteNullable(
     MutagenWriter writer,
     string?item,
     StringBinaryType binaryType = StringBinaryType.NullTerminate)
 {
     if (item == null)
     {
         return;
     }
     writer.Write(
         item,
         binaryType: binaryType);
 }
Example #6
0
        public static void Write(MutagenWriter writer, float?item, FloatIntegerType integerType, double multiplier)
        {
            if (item == null)
            {
                return;
            }
            switch (integerType)
            {
            case FloatIntegerType.UInt:
                writer.Write((uint)Math.Round(item.Value / multiplier));
                break;

            case FloatIntegerType.UShort:
                writer.Write((ushort)Math.Round(item.Value / multiplier));
                break;

            case FloatIntegerType.Byte:
                writer.Write((byte)Math.Round(item.Value / multiplier));
                break;

            default:
                throw new NotImplementedException();
            }
        }
 public void WriteNullable(
     MutagenWriter writer,
     string?item,
     RecordType header,
     StringBinaryType binaryType = StringBinaryType.NullTerminate)
 {
     if (item == null)
     {
         return;
     }
     using (HeaderExport.Header(writer, header, ObjectType.Subrecord))
     {
         writer.Write(
             item,
             binaryType: binaryType);
     }
 }
Example #8
0
 public void Write(
     MutagenWriter writer,
     string item,
     RecordType header,
     StringBinaryType binaryType = StringBinaryType.NullTerminate)
 {
     try
     {
         using (HeaderExport.Header(writer, header, ObjectType.Subrecord))
         {
             writer.Write(
                 item,
                 binaryType: binaryType);
         }
     }
     catch (Exception ex)
     {
         throw SubrecordException.Factory(ex, header);
     }
 }
Example #9
0
 public void WriteNullable(
     MutagenWriter writer,
     string?item,
     RecordType header,
     StringBinaryType binaryType = StringBinaryType.NullTerminate)
 {
     if (item == null)
     {
         return;
     }
     try
     {
         using (HeaderExport.Header(writer, header, ObjectType.Subrecord))
         {
             writer.Write(
                 item,
                 binaryType: binaryType);
         }
     }
     catch (Exception ex)
     {
         throw SubrecordException.Enrich(ex, header);
     }
 }
Example #10
0
 public void Write(
     MutagenWriter writer,
     ReadOnlyMemorySlice <byte>?item,
     RecordType header,
     RecordType overflowRecord)
 {
     try
     {
         if (!item.HasValue)
         {
             return;
         }
         if (item.Value.Length > ushort.MaxValue)
         {
             using (HeaderExport.Subrecord(writer, overflowRecord))
             {
                 writer.Write(item.Value.Length);
             }
             using (HeaderExport.Subrecord(writer, header))
             {
             }
             Write(writer, item.Value.Span);
         }
         else
         {
             using (HeaderExport.Subrecord(writer, header))
             {
                 Write(writer, item.Value.Span);
             }
         }
     }
     catch (Exception ex)
     {
         throw SubrecordException.Enrich(ex, header);
     }
 }
Example #11
0
 public void Write(MutagenWriter writer, ReadOnlySpan <byte> item)
 {
     writer.Write(item);
 }
Example #12
0
 public override void Write(MutagenWriter writer, RecordType item)
 {
     writer.Write(item.TypeInt);
 }
Example #13
0
 public override void Write(MutagenWriter writer, Color item)
 {
     writer.Write(item, ColorBinaryType.Alpha);
 }
 public void Write(
     MutagenWriter writer,
     string item)
 {
     writer.Write(item, binaryType: StringBinaryType.NullTerminate);
 }
Example #15
0
 public override void Write(MutagenWriter writer, DateTime item)
 {
     writer.Write(new byte[4]);
 }
 public override void Write(MutagenWriter writer, ushort item)
 {
     writer.Write(item);
 }
 public override void Write(MutagenWriter writer, double item)
 {
     writer.Write(item);
 }
Example #18
0
 public override void Write(MutagenWriter writer, P3Int item)
 {
     writer.Write(item.X);
     writer.Write(item.Y);
     writer.Write(item.Z);
 }
 public override void Write(MutagenWriter writer, P2Int16 item)
 {
     writer.Write(item.X);
     writer.Write(item.Y);
 }
Example #20
0
 public override void Write(MutagenWriter writer, MemorySlice <byte> item)
 {
     writer.Write(item);
 }
Example #21
0
 public override void Write(MutagenWriter writer, long item)
 {
     writer.Write(item);
 }
Example #22
0
 public void Write(MutagenWriter writer, ReadOnlyMemorySlice <byte> item)
 {
     writer.Write(item.Span);
 }