public void SerializeTemplate(BinaryWriter writer)
 {
     writer.Write(serializableFields.Count);
     writer.Write(serializableProperties.Count);
     foreach (SerializationField serializableField in serializableFields)
     {
         SerializationField current = serializableField;
         writer.WriteKleiString(current.field.Name);
         Type fieldType = current.field.FieldType;
         WriteType(writer, fieldType);
     }
     foreach (SerializationProperty serializableProperty in serializableProperties)
     {
         SerializationProperty current2 = serializableProperty;
         writer.WriteKleiString(current2.property.Name);
         Type propertyType = current2.property.PropertyType;
         WriteType(writer, propertyType);
     }
 }
 public void SerializeData(object obj, BinaryWriter writer)
 {
     if (onSerializing != null)
     {
         onSerializing.Invoke(obj, null);
     }
     foreach (SerializationField serializableField in serializableFields)
     {
         SerializationField current = serializableField;
         try
         {
             object value = current.field.GetValue(obj);
             writer.WriteValue(current.typeInfo, value);
         }
         catch (Exception innerException)
         {
             string text = $"Error occurred while serializing field {current.field.Name} on template {serializableType.Name}";
             Debug.LogError(text);
             throw new ArgumentException(text, innerException);
         }
     }
     foreach (SerializationProperty serializableProperty in serializableProperties)
     {
         SerializationProperty current2 = serializableProperty;
         try
         {
             object value2 = current2.property.GetValue(obj, null);
             writer.WriteValue(current2.typeInfo, value2);
         }
         catch (Exception innerException2)
         {
             string text2 = $"Error occurred while serializing property {current2.property.Name} on template {serializableType.Name}";
             Debug.LogError(text2);
             throw new ArgumentException(text2, innerException2);
         }
     }
     if (onSerialized != null)
     {
         onSerialized.Invoke(obj, null);
     }
 }