using System.IO; using System.Text; using Microsoft.Xna.Framework.Content; using MonoGame.Extended.Particles; namespace MonoGame.Extended.Content.ContentReaders; public sealed class ParticleEffectContentReader : ContentTypeReader { /// /// Registers this with the /// so it is resolved without reflection. /// /// /// Call this method once during application startup when publishing with /// PublishAot or PublishTrimmed. /// public static void Register() => ContentTypeReaderManager.AddTypeCreator( typeof(ParticleEffectContentReader).AssemblyQualifiedName, () => new ParticleEffectContentReader()); protected override ParticleEffect Read(ContentReader input, ParticleEffect existingInstance) { string xmlContent = input.ReadString(); byte[] xmlBytes = Encoding.UTF8.GetBytes(xmlContent); using Stream stream = new MemoryStream(xmlBytes); return ParticleEffectSerializer.Deserialize(stream, input.ContentManager); } }