78 lines
1.5 KiB
C#
78 lines
1.5 KiB
C#
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// 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<EntityData>( cfg );
|
|
|
|
WriteSampleData<CardData>( cfg );
|
|
|
|
//res.Ref<DeckData> deckRef = new( "samples/DeckData.xml" );
|
|
|
|
//var deck = deckRef.res;
|
|
|
|
WriteSampleData( cfg, () => new BattleData( DebugSample.Create ) );
|
|
|
|
//WriteSampleData<DeckData>( cfg );
|
|
|
|
|
|
}
|
|
|
|
public static void WriteSampleData<TD>( ser.XmlCfg cfg, Func<TD> fn ) where TD: cs.Data
|
|
=> WriteSampleData( cfg, typeof(TD).Name, fn() );
|
|
|
|
|
|
public static void WriteSampleData<TD>( ser.XmlCfg cfg )
|
|
where TD: cs.Data, new()
|
|
=> WriteSampleData( cfg, $"samples/{typeof(TD).Name}.xml", new TD() );
|
|
|
|
|
|
|
|
public static void WriteSampleData<TD>( 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
|