///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // D E R E L I C T // /// // (c) 2003..2024 //using Microsoft.CodeAnalysis.CSharp.Syntax; // Skip for now #if false using cs; using System; using System.IO; using System.Security.Cryptography.X509Certificates; static public class Samples { public static void CreateDataSamples() { ser.XmlCfg cfg = new() { POD = ser.POD.Elements, }; //cfg.POD = lib.POD.Elements; WriteSampleData( cfg ); WriteSampleData( cfg ); //res.Ref deckRef = new( "samples/DeckData.xml" ); //var deck = deckRef.res; WriteSampleData( cfg, () => new BattleData( DebugSample.Create ) ); //WriteSampleData( cfg ); } public static void WriteSampleData( ser.XmlCfg cfg, Func fn ) where TD: cs.Data => WriteSampleData( cfg, typeof(TD).Name, fn() ); public static void WriteSampleData( ser.XmlCfg cfg ) where TD: cs.Data, new() => WriteSampleData( cfg, $"samples/{typeof(TD).Name}.xml", new TD() ); public static void WriteSampleData( ser.XmlCfg cfg, string path, TD entityData ) where TD: cs.Data { log.high( $"WriteSampleData: Writing {typeof(TD).Name} to {path}" ); try { ser.XmlSer xml = new( cfg ); using FileStream stream = new( path, FileMode.Create ); xml.Serialize( stream, entityData ); } catch( Exception ex ) { log.warn( $"WriteSampleData: ex {ex.Message}" ); log.info( $"Stack.\n{ex.StackTrace}" ); } } } #endif