/// <summary> /// Calls the static Initialize function for the specified GGDBF Context type using the provided /// data source. /// </summary> /// <typeparam name="TGGDBFContextType">Context type.</typeparam> /// <param name="source">The data source.</param> /// <returns>Awaitable for when the Initialize method finishes.</returns> public static async Task CallInitialize <TGGDBFContextType>(IGGDBFDataSource source) where TGGDBFContextType : IGGDBFContext { await(Task) typeof(TGGDBFContextType) .GetMethod(GGDBFConstants.INITIALIZE_METHOD_NAME, BindingFlags.Static | BindingFlags.Public) .Invoke(null, new object[1] { source }); }
public static async Task Initialize(IGGDBFDataSource source) { Instance = new() { Skill = await source.RetrieveTableAsync <TSkillType, DBRPGSkill <TSkillType> >(new NameOverrideTableRetrievalConfig <TSkillType, DBRPGSkill <TSkillType> >("Skill")), Race = await source.RetrieveTableAsync <TRaceType, DBRPGRace <TRaceType> >(new NameOverrideTableRetrievalConfig <TRaceType, DBRPGRace <TRaceType> >("Race")), @Class = await source.RetrieveTableAsync <TClassType, DBRPGClass <TClassType> >(new NameOverrideTableRetrievalConfig <TClassType, DBRPGClass <TClassType> >("Class")), CharacterCustomizationSlotType = await source.RetrieveTableAsync <TCustomizableSlotType, DBRPGCharacterCustomizableSlotType <TCustomizableSlotType> >(new NameOverrideTableRetrievalConfig <TCustomizableSlotType, DBRPGCharacterCustomizableSlotType <TCustomizableSlotType> >("CharacterCustomizationSlotType")), CharacterProportionSlotType = await source.RetrieveTableAsync <TProportionSlotType, DBRPGCharacterProportionSlotType <TProportionSlotType> >(new NameOverrideTableRetrievalConfig <TProportionSlotType, DBRPGCharacterProportionSlotType <TProportionSlotType> >("CharacterProportionSlotType")), Stat = await source.RetrieveTableAsync <TStatType, DBRPGStat <TStatType> >(new NameOverrideTableRetrievalConfig <TStatType, DBRPGStat <TStatType> >("Stat")), CharacterStatDefault = await source.RetrieveTableAsync <DBRPGCharacterStatDefaultKey <TStatType, TRaceType, TClassType>, DBRPGCharacterStatDefault <TStatType, TRaceType, TClassType>, RPGStaticDataContext_DBRPGCharacterStatDefault <TSkillType, TRaceType, TClassType, TProportionSlotType, TCustomizableSlotType, TStatType> >(new NameOverrideTableRetrievalConfig <DBRPGCharacterStatDefaultKey <TStatType, TRaceType, TClassType>, DBRPGCharacterStatDefault <TStatType, TRaceType, TClassType> >("CharacterStatDefault") { KeyResolutionFunction = m => new DBRPGCharacterStatDefaultKey <TStatType, TRaceType, TClassType>(m.Level, m.RaceId, m.ClassId) }), }; }
private async Task <TGGDBFContextType> GetContext(IGGDBFDataSource source) { if (source == null) { throw new ArgumentNullException(nameof(source)); } //TODO: This could load the context multiple times due to race conditions (but should be ok) if (!GGDBFHelpers.IsContextInitialized <TGGDBFContextType>()) { await GGDBFHelpers.CallInitialize <TGGDBFContextType>(source); } return(GGDBFHelpers.GetInstance <TGGDBFContextType>()); }
public ContextGenerator(IGGDBFDataSource source, IGGDBFDataWriter writer) { Source = source ?? throw new ArgumentNullException(nameof(source)); Writer = writer ?? throw new ArgumentNullException(nameof(writer)); }
public static async Task <IReadOnlyDictionary <TPrimaryKeyType, TModelType> > RetrieveTableAsync <TPrimaryKeyType, TModelType, TSerializableModelType>(this IGGDBFDataSource source, TableRetrievalConfig <TPrimaryKeyType, TModelType> config = null, CancellationToken token = default) where TModelType : class where TSerializableModelType : class, TModelType, IGGDBFSerializable { return((await source.RetrieveFullTableAsync <TPrimaryKeyType, TModelType, TSerializableModelType>(config, token)).ToReadOnly()); }
/// <summary> /// Creates a new converting datasource. /// </summary> /// <param name="dataSource">The datasource to adapt.</param> /// <param name="converter">The converter to use to convert between model to serializable model type.</param> public ConverterDataSourceGGDBFAdapter(IGGDBFDataSource dataSource, IGGDBFDataConverter converter) { DataSource = dataSource ?? throw new ArgumentNullException(nameof(dataSource)); Converter = converter ?? throw new ArgumentNullException(nameof(converter)); }
public GGDBFContentController(ILogger<BaseGladerController> logger, IGGDBFDataSource dataSource) : base(logger) { DataSource = dataSource ?? throw new ArgumentNullException(nameof(dataSource)); }
public ContextReflectionGGDBFDataSource(IGGDBFDataSource source, IGGDBFDataConverter converter) { Source = source ?? throw new ArgumentNullException(nameof(source)); Converter = converter ?? throw new ArgumentNullException(nameof(converter)); }