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();
            }
        }
예제 #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);
     }
 }
예제 #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));
     }
 }
예제 #4
0
 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);
     }
 }
예제 #5
0
 public void WriteNullable(
     MutagenWriter writer,
     string?item,
     StringBinaryType binaryType = StringBinaryType.NullTerminate)
 {
     if (item == null)
     {
         return;
     }
     writer.Write(
         item,
         binaryType: binaryType);
 }
예제 #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();
            }
        }
예제 #7
0
 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);
     }
 }
예제 #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);
     }
 }
예제 #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);
     }
 }
예제 #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);
     }
 }
예제 #11
0
 public void Write(MutagenWriter writer, ReadOnlySpan <byte> item)
 {
     writer.Write(item);
 }
예제 #12
0
 public override void Write(MutagenWriter writer, RecordType item)
 {
     writer.Write(item.TypeInt);
 }
예제 #13
0
 public override void Write(MutagenWriter writer, Color item)
 {
     writer.Write(item, ColorBinaryType.Alpha);
 }
예제 #14
0
 public void Write(
     MutagenWriter writer,
     string item)
 {
     writer.Write(item, binaryType: StringBinaryType.NullTerminate);
 }
예제 #15
0
 public override void Write(MutagenWriter writer, DateTime item)
 {
     writer.Write(new byte[4]);
 }
예제 #16
0
 public override void Write(MutagenWriter writer, ushort item)
 {
     writer.Write(item);
 }
예제 #17
0
 public override void Write(MutagenWriter writer, double item)
 {
     writer.Write(item);
 }
예제 #18
0
 public override void Write(MutagenWriter writer, P3Int item)
 {
     writer.Write(item.X);
     writer.Write(item.Y);
     writer.Write(item.Z);
 }
예제 #19
0
 public override void Write(MutagenWriter writer, P2Int16 item)
 {
     writer.Write(item.X);
     writer.Write(item.Y);
 }
예제 #20
0
 public override void Write(MutagenWriter writer, MemorySlice <byte> item)
 {
     writer.Write(item);
 }
예제 #21
0
 public override void Write(MutagenWriter writer, long item)
 {
     writer.Write(item);
 }
예제 #22
0
 public void Write(MutagenWriter writer, ReadOnlyMemorySlice <byte> item)
 {
     writer.Write(item.Span);
 }