Files
Tritone/HorseRacingPredictor/HorseRacingPredictor/CsvHelperStubs.cs
Alberto Balbo 72bd778d56 Migrazione UI a WPF e integrazione Racing API moderna
Transizione completa da WinForms a WPF con interfaccia moderna (sidebar, pagine, palette Catppuccin Mocha).
Aggiunta integrazione con The Racing API per le corse dei cavalli, inclusi nuovi moduli di backend e parsing dati.
Introdotti componenti UI personalizzati (CardPanel, ModernButton, ModernProgressBar, NavButton, ModernTheme) per un look coerente e moderno.
Gestione avanzata delle impostazioni, esportazione CSV migliorata, refactoring della logica di business e maggiore robustezza nelle chiamate API.
Aggiunti stub CsvHelper e file di progetto di backup per facilitare la compatibilità e la migrazione.
2026-02-25 18:49:48 +01:00

116 lines
3.8 KiB
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Globalization;
// Minimal compatibility stubs for CsvHelper types used in the project.
// These are light-weight placeholders so the project can compile when the CsvHelper NuGet
// package is not restored. They intentionally provide only the members the project expects.
namespace CsvHelper.Configuration.Attributes
{
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)]
public sealed class NameAttribute : Attribute
{
public string[] Names { get; }
public NameAttribute(params string[] names) => Names = names ?? Array.Empty<string>();
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)]
public sealed class TypeConverterAttribute : Attribute
{
public Type ConverterType { get; }
public TypeConverterAttribute(Type converterType) => ConverterType = converterType;
}
}
namespace CsvHelper.TypeConversion
{
public class DefaultTypeConverter
{
// Signature matches CsvHelper's DefaultTypeConverter override used in the project
public virtual object ConvertFromString(string text, IReaderRow row, MemberMapData memberMapData) => (object)text;
}
public class TypeConverterCache
{
private readonly Dictionary<Type, object> _converters = new Dictionary<Type, object>();
public void AddConverter<T>(DefaultTypeConverter converter) => _converters[typeof(T)] = converter;
}
// Minimal placeholders referenced in code
public interface IReaderRow { }
public class MemberMapData { }
}
namespace CsvHelper.Configuration
{
public enum TrimOptions { None, Trim }
public class CsvConfiguration
{
public CsvConfiguration(CultureInfo culture) { Culture = culture; }
public CultureInfo Culture { get; }
public bool HasHeaderRecord { get; set; }
public Func<PrepareHeaderForMatchArgs, string> PrepareHeaderForMatch { get; set; }
public object HeaderValidated { get; set; }
public Action<object> MissingFieldFound { get; set; }
public Action<object> BadDataFound { get; set; }
public TrimOptions TrimOptions { get; set; }
public string Delimiter { get; set; }
}
// Basic ClassMap and mapping helper used by the project's mapping files
public class ClassMap<T>
{
public MemberMap Map(Func<T, object> func) => new MemberMap();
}
public class MemberMap
{
public MemberMap Name(params string[] names) { return this; }
}
// Minimal args used by PrepareHeaderForMatch delegate in code above
public class PrepareHeaderForMatchArgs
{
public string Header { get; set; }
}
}
namespace CsvHelper
{
using CsvHelper.Configuration;
using CsvHelper.TypeConversion;
public class CsvReader : IDisposable
{
private readonly TextReader _reader;
public CsvReader(TextReader reader, CsvConfiguration config)
{
_reader = reader;
Configuration = config;
Context = new ReaderContext();
}
public CsvConfiguration Configuration { get; }
public ReaderContext Context { get; }
public void Dispose() { /* nothing to dispose in stub */ }
public bool Read() => false;
public void ReadHeader() { }
public string[] HeaderRecord => Array.Empty<string>();
public string GetField(int index) => null;
public IEnumerable<T> GetRecords<T>() { return Enumerable.Empty<T>(); }
public class ReaderContext
{
public TypeConverterCache TypeConverterCache { get; } = new TypeConverterCache();
public void RegisterClassMap<TMap>() { }
}
}
}