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
TItemDataThe 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
filePathstringThe file path where item data is stored.
preloadInternalItemsboolWhether to preload internal items.
fileNamestringThe name of the file where item data is stored.
extensionstringThe file extension for item data files.
autoCreateFileboolWhether 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
itemIdintThe item ID to assign to the new item data.
namestringThe name to assign to the new item data.
Returns
- TItemData
Returns a new instance of
TItemDatawith 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
keyint
Returns
- TItemData
Initialize(IDatabase<int, TItemData>)
public override void Initialize(IDatabase<int, TItemData> database)