Table of Contents

Class MySqlKitsDataStore

Namespace
Uncreated.Warfare.Kits
Assembly
Uncreated.Warfare.dll
public class MySqlKitsDataStore : IKitDataStore, IEventListener<PlayerLeft>, IAsyncEventListener<PlayerPending>, IHostedService
Inheritance
MySqlKitsDataStore
Implements
Inherited Members

Constructors

MySqlKitsDataStore(IServiceProvider, ILogger<MySqlKitsDataStore>)

public MySqlKitsDataStore(IServiceProvider serviceProvider, ILogger<MySqlKitsDataStore> logger)

Parameters

serviceProvider IServiceProvider
logger ILogger<MySqlKitsDataStore>

Properties

CacheEnabled

If the cache is being kept up to date.

public bool CacheEnabled { get; }

Property Value

bool

CachedKitsById

Dictionary of cached kits by their internal ID.

public IReadOnlyDictionary<string, Kit> CachedKitsById { get; }

Property Value

IReadOnlyDictionary<string, Kit>

CachedKitsByKey

Dictionary of cached kits by their primary key.

public IReadOnlyDictionary<uint, Kit> CachedKitsByKey { get; }

Property Value

IReadOnlyDictionary<uint, Kit>

Methods

AddKitAsync(string, Class, string?, CSteamID, Action<KitModel>, CancellationToken)

Create a new kit with the given ID and basic information.

public Task<Kit> AddKitAsync(string kitId, Class @class, string? displayName, CSteamID creator, Action<KitModel> createAction, CancellationToken token = default)

Parameters

kitId string

Unique internal kit ID.

class Class

Class of the newly created kit.

displayName string

Optional sign text for the default language.

creator CSteamID

Player responsible for creating the kit, or default if not applicable.

createAction Action<KitModel>

Invoked before the kit is saved to modify the starting options.

token CancellationToken

Returns

Task<Kit>

The new kit.

Exceptions

ArgumentException

kitId not unique or createAction threw an exception.

AddKitAsync(string, Class, string?, CSteamID, Func<KitModel, Task>, CancellationToken)

Create a new kit with the given ID and basic information.

public Task<Kit> AddKitAsync(string kitId, Class @class, string? displayName, CSteamID creator, Func<KitModel, Task> createAction, CancellationToken token = default)

Parameters

kitId string

Unique internal kit ID.

class Class

Class of the newly created kit.

displayName string

Optional sign text for the default language.

creator CSteamID

Player responsible for creating the kit, or default if none.

createAction Func<KitModel, Task>

Invoked before the kit is saved to modify the starting options.

token CancellationToken

Returns

Task<Kit>

The new kit.

Exceptions

ArgumentException

kitId not unique or createAction threw an exception.

DeleteKitAsync(uint, KitInclude, CancellationToken)

Delete the kit with the given primary key.

public Task<KitModel?> DeleteKitAsync(uint primaryKey, KitInclude include = KitInclude.Base, CancellationToken token = default)

Parameters

primaryKey uint

The kit to delete.

include KitInclude

What information to include in the returned object.

token CancellationToken

Returns

Task<KitModel>

The kit that was deleted, or null if it wasn't found.

QueryEliteBundleAsync(Func<IQueryable<EliteBundle>, IQueryable<EliteBundle>>, bool, bool, KitInclude, CancellationToken)

Query an elite bundle by it's ID.

public Task<EliteBundle?> QueryEliteBundleAsync(Func<IQueryable<EliteBundle>, IQueryable<EliteBundle>> query, bool includeKits = false, bool includeFaction = false, KitInclude kitListInclude = KitInclude.Default, CancellationToken token = default)

Parameters

query Func<IQueryable<EliteBundle>, IQueryable<EliteBundle>>

Action against the EliteBundle DbSet<TEntity>.

includeKits bool

If the list of kits should be included.

includeFaction bool

If the Faction should also be included.

kitListInclude KitInclude

Data to be included in the list of kits, if includeKits is true.

token CancellationToken

Returns

Task<EliteBundle>

The found bundle, or null if no bundles are found.

QueryEliteBundleAsync(string, bool, bool, KitInclude, CancellationToken)

Query an elite bundle by it's ID.

public Task<EliteBundle?> QueryEliteBundleAsync(string bundleId, bool includeKits = false, bool includeFaction = false, KitInclude kitListInclude = KitInclude.Default, CancellationToken token = default)

Parameters

bundleId string

The unique ID of an elite bundle.

includeKits bool

If the list of kits should be included.

includeFaction bool

If the Faction should also be included.

kitListInclude KitInclude

Data to be included in the list of kits, if includeKits is true.

token CancellationToken

Returns

Task<EliteBundle>

The found bundle, or null if no bundles are found.

QueryEliteBundleAsync(uint, bool, bool, KitInclude, CancellationToken)

Query an elite bundle by it's primary key.

public Task<EliteBundle?> QueryEliteBundleAsync(uint primaryKey, bool includeKits = false, bool includeFaction = false, KitInclude kitListInclude = KitInclude.Default, CancellationToken token = default)

Parameters

primaryKey uint

The unique primary key of an elite bundle.

includeKits bool

If the list of kits should be included.

includeFaction bool

If the Faction should also be included.

kitListInclude KitInclude

Data to be included in the list of kits, if includeKits is true.

token CancellationToken

Returns

Task<EliteBundle>

The found bundle, or null if no bundles are found.

QueryEliteBundlesAsync(Func<IQueryable<EliteBundle>, IQueryable<EliteBundle>>, bool, bool, KitInclude, CancellationToken)

Query an elite bundle by it's ID.

public Task<IList<EliteBundle>> QueryEliteBundlesAsync(Func<IQueryable<EliteBundle>, IQueryable<EliteBundle>> query, bool includeKits = false, bool includeFaction = false, KitInclude kitListInclude = KitInclude.Default, CancellationToken token = default)

Parameters

query Func<IQueryable<EliteBundle>, IQueryable<EliteBundle>>

Action against the EliteBundle DbSet<TEntity>.

includeKits bool

If the list of kits should be included.

includeFaction bool

If the Faction should also be included.

kitListInclude KitInclude

Data to be included in the list of kits, if includeKits is true.

token CancellationToken

Returns

Task<IList<EliteBundle>>

The found bundle, or null if no bundles are found.

QueryFirstAsync<T>(Func<IQueryable<KitModel>, IQueryable<T>>, KitInclude, CancellationToken)

Query data from a kit other than the kit itself (ex. querying an ID using .Select(x => x.Id)).

public Task<T?> QueryFirstAsync<T>(Func<IQueryable<KitModel>, IQueryable<T>> query, KitInclude include = KitInclude.Base, CancellationToken token = default)

Parameters

query Func<IQueryable<KitModel>, IQueryable<T>>

Action against the KitModel DbSet<TEntity>.

include KitInclude

What information to include, only applicable when returning KitModel.

token CancellationToken

Returns

Task<T>

The first match to the query.

Type Parameters

T

The type of data to be returned.

QueryKitAsync(string, KitInclude, CancellationToken)

Find a kit by it's kitId.

public Task<Kit?> QueryKitAsync(string kitId, KitInclude include, CancellationToken token = default)

Parameters

kitId string
include KitInclude

What type of data to be included in the return value.

token CancellationToken

Returns

Task<Kit>

The found kit, or null if no results are found.

QueryKitAsync(uint, KitInclude, CancellationToken)

Find a kit by it's primaryKey.

public Task<Kit?> QueryKitAsync(uint primaryKey, KitInclude include, CancellationToken token = default)

Parameters

primaryKey uint
include KitInclude

What type of data to be included in the return value.

token CancellationToken

Returns

Task<Kit>

The found kit, or null if no results are found.

QueryKitAsync(KitInclude, Func<IQueryable<KitModel>, IQueryable<KitModel>>, CancellationToken)

Find a kit by a custom where filter.

public Task<Kit?> QueryKitAsync(KitInclude include, Func<IQueryable<KitModel>, IQueryable<KitModel>> query, CancellationToken token = default)

Parameters

include KitInclude

What type of data to be included in the return value.

query Func<IQueryable<KitModel>, IQueryable<KitModel>>

Action against the KitModel DbSet<TEntity>.

token CancellationToken

Returns

Task<Kit>

The found kit, or null if no results are found.

QueryKitAsync(KitInclude, Expression<Func<KitModel, bool>>, CancellationToken)

Find a kit by a custom where filter.

public Task<Kit?> QueryKitAsync(KitInclude include, Expression<Func<KitModel, bool>> predicate, CancellationToken token = default)

Parameters

include KitInclude

What type of data to be included in the return value.

predicate Expression<Func<KitModel, bool>>

Filter applied using the where filter.

token CancellationToken

Returns

Task<Kit>

The found kit, or null if no results are found.

QueryKitsAsync(KitInclude, IList<Kit>, Func<IQueryable<KitModel>, IQueryable<KitModel>>, CancellationToken)

Find kits by a custom queryable filter.

public Task<int> QueryKitsAsync(KitInclude include, IList<Kit> output, Func<IQueryable<KitModel>, IQueryable<KitModel>> query, CancellationToken token = default)

Parameters

include KitInclude

What type of data to be included in the return value.

output IList<Kit>

List to output matching kits to. It will not be cleared, only appended to.

query Func<IQueryable<KitModel>, IQueryable<KitModel>>

Action against the KitModel DbSet<TEntity>.

token CancellationToken

Returns

Task<int>

The number of matching kits.

QueryKitsAsync(KitInclude, IList<Kit>, Expression<Func<KitModel, bool>>, CancellationToken)

Find kits by a custom where filter.

public Task<int> QueryKitsAsync(KitInclude include, IList<Kit> output, Expression<Func<KitModel, bool>> predicate, CancellationToken token = default)

Parameters

include KitInclude

What type of data to be included in the return value.

output IList<Kit>

List to output matching kits to. It will not be cleared, only appended to.

predicate Expression<Func<KitModel, bool>>

Filter applied using the where filter.

token CancellationToken

Returns

Task<int>

The number of matching kits.

QueryKitsAsync(KitInclude, Func<IQueryable<KitModel>, IQueryable<KitModel>>, CancellationToken)

Find kits by a custom queryable filter.

public Task<Kit[]> QueryKitsAsync(KitInclude include, Func<IQueryable<KitModel>, IQueryable<KitModel>> query, CancellationToken token = default)

Parameters

include KitInclude

What type of data to be included in the return value.

query Func<IQueryable<KitModel>, IQueryable<KitModel>>

Action against the KitModel DbSet<TEntity>.

token CancellationToken

Returns

Task<Kit[]>

An array of all matching kits.

QueryKitsAsync(KitInclude, Expression<Func<KitModel, bool>>, CancellationToken)

Find kits by a custom where filter.

public Task<Kit[]> QueryKitsAsync(KitInclude include, Expression<Func<KitModel, bool>> predicate, CancellationToken token = default)

Parameters

include KitInclude

What type of data to be included in the return value.

predicate Expression<Func<KitModel, bool>>

Filter applied using the where filter.

token CancellationToken

Returns

Task<Kit[]>

An array of all matching kits.

QueryListAsync<T>(Func<IQueryable<KitModel>, IQueryable<T>>, KitInclude, CancellationToken)

Query data from a kit other than the kit itself (ex. querying all IDs using .Select(x => x.Id)).

public Task<List<T>> QueryListAsync<T>(Func<IQueryable<KitModel>, IQueryable<T>> query, KitInclude include = KitInclude.Base, CancellationToken token = default)

Parameters

query Func<IQueryable<KitModel>, IQueryable<T>>

Action against the KitModel DbSet<TEntity>.

include KitInclude

What information to include, only applicable when returning KitModel.

token CancellationToken

Returns

Task<List<T>>

All matches to the query.

Type Parameters

T

The type of data to be returned.

UpdateKitAsync(uint, KitInclude, Action<KitModel>, CSteamID, CancellationToken)

Modify the kit with the given primaryKey.

public Task<Kit?> UpdateKitAsync(uint primaryKey, KitInclude include, Action<KitModel> updateAction, CSteamID updater, CancellationToken token = default)

Parameters

primaryKey uint

The kit to modify.

include KitInclude

What information to include.

updateAction Action<KitModel>

Callback to apply the modifications.

updater CSteamID

Player who is updating the kit, or default if not applicable.

token CancellationToken

Returns

Task<Kit>

The updated kit, or null if the kit wasn't found.

UpdateKitAsync(uint, KitInclude, Func<KitModel, Task>, CSteamID, CancellationToken)

Modify the kit with the given primaryKey.

public Task<Kit?> UpdateKitAsync(uint primaryKey, KitInclude include, Func<KitModel, Task> updateAction, CSteamID updater, CancellationToken token = default)

Parameters

primaryKey uint

The kit to modify.

include KitInclude

What information to include.

updateAction Func<KitModel, Task>

Callback to apply the modifications.

updater CSteamID

Player who is updating the kit, or default if not applicable.

token CancellationToken

Returns

Task<Kit>

The updated kit, or null if the kit wasn't found.

Events

KitAdded

Invoked when a new kit is added.

public event Action<Kit>? KitAdded

Event Type

Action<Kit>

KitRemoved

Invoked when a kit is fully deleted.

public event Action<KitModel>? KitRemoved

Event Type

Action<KitModel>

KitUpdated

Invoked when a kit's properties are updated.

public event Action<Kit>? KitUpdated

Event Type

Action<Kit>