public static void Write <T>(
     this TypicalBinaryTranslation <T, MutagenFrame, MutagenWriter> transl,
     MutagenWriter writer,
     T item,
     RecordType header,
     bool nullable)
 {
     if (item == null)
     {
         if (nullable)
         {
             return;
         }
         throw new ArgumentException("Non optional string was null.");
     }
     try
     {
         using (HeaderExport.Header(writer, header, ObjectType.Subrecord))
         {
             transl.Write(writer, item);
         }
     }
     catch (Exception ex)
     {
         throw SubrecordException.Factory(ex, header);
     }
 }
예제 #2
0
 public void WriteNullable(
     MutagenWriter writer,
     ITranslatedStringGetter?item,
     RecordType header,
     StringBinaryType binaryType,
     StringsSource source)
 {
     if (item == null)
     {
         return;
     }
     try
     {
         using (HeaderExport.Header(writer, header, ObjectType.Subrecord))
         {
             if (writer.MetaData.StringsWriter == null)
             {
                 writer.Write(
                     item.String ?? string.Empty,
                     binaryType: binaryType);
             }
             else
             {
                 writer.Write(writer.MetaData.StringsWriter.Register(item, source));
             }
         }
     }
     catch (Exception ex)
     {
         throw SubrecordException.Enrich(ex, header);
     }
 }
 public static void Write(
     this PrimitiveBinaryTranslation <bool, MutagenFrame, MutagenWriter> transl,
     MutagenWriter writer,
     bool item,
     RecordType header,
     byte byteLength)
 {
     try
     {
         using (HeaderExport.Header(writer, header, ObjectType.Subrecord))
         {
             writer.Write(item ? 1 : 0, byteLength);
         }
     }
     catch (Exception ex)
     {
         throw SubrecordException.Factory(ex, header);
     }
 }
예제 #4
0
 public static void Write <TEnum>(
     this EnumBinaryTranslation <TEnum, MutagenFrame, MutagenWriter> transl,
     MutagenWriter writer,
     TEnum item,
     RecordType header,
     long length)
     where TEnum : struct, Enum, IConvertible
 {
     try
     {
         using (HeaderExport.Header(writer, header, ObjectType.Subrecord))
         {
             transl.WriteValue(writer, item, length);
         }
     }
     catch (Exception ex)
     {
         throw SubrecordException.Factory(ex, header);
     }
 }
 public void Write(
     MutagenWriter writer,
     FormKey item,
     RecordType header,
     bool nullable = false)
 {
     try
     {
         using (HeaderExport.Header(writer, header, ObjectType.Subrecord))
         {
             this.Write(
                 writer,
                 item);
         }
     }
     catch (Exception ex)
     {
         throw SubrecordException.Enrich(ex, header);
     }
 }
예제 #6
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.Enrich(ex, header);
     }
 }
 public static void WriteAsMarker(
     this PrimitiveBinaryTranslation <bool, MutagenFrame, MutagenWriter> transl,
     MutagenWriter writer,
     bool item,
     RecordType header)
 {
     try
     {
         if (!item)
         {
             return;
         }
         using (HeaderExport.Header(writer, header, ObjectType.Subrecord))
         {
             // Presence of marker signifies true
         }
     }
     catch (Exception ex)
     {
         throw SubrecordException.Factory(ex, header);
     }
 }
예제 #8
0
 public void Write(
     MutagenWriter writer,
     ITranslatedStringGetter item,
     RecordType header,
     StringBinaryType binaryType,
     StringsSource source)
 {
     try
     {
         using (HeaderExport.Header(writer, header, ObjectType.Subrecord))
         {
             Write(
                 writer,
                 item,
                 binaryType,
                 source);
         }
     }
     catch (Exception ex)
     {
         throw SubrecordException.Enrich(ex, header);
     }
 }