Class ItemDataSource<TItemData>
ItemDataSource is a data source for item data.
public class ItemDataSource<TItemData> : FileDataSource<int, TItemData, ItemDataLoader<TItemData>>, IDataSource<int, TItemData, ItemDataLoader<TItemData>>, IDataSource<int, TItemData>, IDataSource, IDataCrud, IDataCrud<int, TItemData> where TItemData : ItemData
Type Parameters
TItemData
The type of item data to load. Must inherit from ItemData.
- Inheritance
-
ItemDataSource<TItemData>
- Implements
-
IDataSource<int, TItemData>
- Derived
- Inherited Members
- Extension Methods
Constructors
ItemDataSource(string, bool, string?, string?, bool)
ItemDataSource is a data source for item data.
public ItemDataSource(string filePath, bool preloadInternalItems = false, string? fileName = "CustomItems", string? extension = "json", bool autoCreateFile = true)
Parameters
filePath
stringThe file path where item data is stored.
preloadInternalItems
boolWhether to preload internal items.
fileName
stringThe name of the file where item data is stored.
extension
stringThe file extension for item data files.
autoCreateFile
boolWhether to automatically create the file if it does not exist.
Properties
KeyResolver
Key resolver function to resolve keys from data items.
public override Func<TItemData, int>? KeyResolver { get; set; }
Property Value
Log
protected override Logger Log { get; }
Property Value
PreloadInternalItems
Whether to preload internal items from the enum Item.
public bool PreloadInternalItems { get; }
Property Value
Methods
CreateItemData(int, string)
Creates a new instance of TItemData
with the specified item ID and name.
protected TItemData CreateItemData(int itemId, string name)
Parameters
itemId
intThe item ID to assign to the new item data.
name
stringThe name to assign to the new item data.
Returns
- TItemData
Returns a new instance of
TItemData
with the specified item ID and name.
Exceptions
- DatabaseException
Thrown if the item data instance cannot be created.
Get(int)
public override TItemData Get(int key)
Parameters
key
int
Returns
- TItemData
Initialize(IDatabase<int, TItemData>)
public override void Initialize(IDatabase<int, TItemData> database)