Unified docstrings
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
namespace HopFrame.Core.Configuration;
|
||||
|
||||
/**
|
||||
* The configuration for the library
|
||||
*/
|
||||
/// <summary>
|
||||
/// The configuration for the library
|
||||
/// </summary>
|
||||
public sealed class HopFrameConfig {
|
||||
/** The configurations for the table repositories */
|
||||
/// The configurations for the table repositories
|
||||
public IList<TableConfig> Tables { get; set; } = new List<TableConfig>();
|
||||
|
||||
internal HopFrameConfig() {}
|
||||
|
||||
@@ -1,40 +1,40 @@
|
||||
namespace HopFrame.Core.Configuration;
|
||||
|
||||
/**
|
||||
* The configuration for a single property
|
||||
*/
|
||||
/// <summary>
|
||||
/// The configuration for a single property
|
||||
/// </summary>
|
||||
public class PropertyConfig {
|
||||
/** [GENERATED] The unique identifier for the property (usually the real property name in the model) */
|
||||
/// [GENERATED] The unique identifier for the property (usually the real property name in the model)
|
||||
public required string Identifier { get; init; }
|
||||
|
||||
/** [GENERATED] The displayed name of the Property */
|
||||
/// [GENERATED] The displayed name of the Property
|
||||
public required string DisplayName { get; set; }
|
||||
|
||||
/** [GENERATED] The real type of the property */
|
||||
/// [GENERATED] The real type of the property
|
||||
public required Type Type { get; set; }
|
||||
|
||||
/** [GENERATED] The type as wich the property should be treated */
|
||||
/// [GENERATED] The type as wich the property should be treated
|
||||
public required PropertyType PropertyType { get; set; }
|
||||
|
||||
/** Determines if the property will appear in the table */
|
||||
/// Determines if the property will appear in the table
|
||||
public bool Listable { get; set; } = true;
|
||||
|
||||
/** Determines if the table can be sorted by the property */
|
||||
/// Determines if the table can be sorted by the property
|
||||
public bool Sortable { get; set; } = true;
|
||||
|
||||
/** Determines if the table can be searched by the property */
|
||||
/// Determines if the table can be searched by the property
|
||||
public bool Searchable { get; set; } = true;
|
||||
|
||||
/**
|
||||
* Determines if the value of the property can be edited
|
||||
* (if true the value can still be set during creation)
|
||||
*/
|
||||
/// <summary>
|
||||
/// Determines if the value of the property can be edited<br/>
|
||||
/// (if true the value can still be set during creation)
|
||||
/// </summary>
|
||||
public bool Editable { get; set; } = true;
|
||||
|
||||
/** Determines if the property is visible in the creation or edit dialog */
|
||||
/// Determines if the property is visible in the creation or edit dialog
|
||||
public bool Creatable { get; set; } = true;
|
||||
|
||||
/** [GENERATED] The place (from left to right) that the property will appear in the table and editor */
|
||||
/// [GENERATED] The place (from left to right) that the property will appear in the table and editor
|
||||
public int OrderIndex { get; set; }
|
||||
|
||||
internal PropertyConfig() {}
|
||||
@@ -46,45 +46,45 @@ public class PropertyConfig {
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum PropertyType : byte {
|
||||
/** Used together with another type to indicate that the value can be null */
|
||||
/// Used together with another type to indicate that the value can be null
|
||||
Nullable = 0b10000000,
|
||||
|
||||
/** Used together with another type to indicate that the property is a relation */
|
||||
/// Used together with another type to indicate that the property is a relation
|
||||
Relation = 0b01000000,
|
||||
|
||||
/** Used together with another type to indicate that the value is enumerable */
|
||||
/// Used together with another type to indicate that the value is enumerable
|
||||
List = 0b00100000,
|
||||
|
||||
/** Indicates that the value is numeric */
|
||||
/// Indicates that the value is numeric
|
||||
Numeric = 0x01,
|
||||
|
||||
/** Indicates that the value is a boolean */
|
||||
/// Indicates that the value is a boolean
|
||||
Boolean = 0x02,
|
||||
|
||||
/** Indicates that the value is a timestamp */
|
||||
/// Indicates that the value is a timestamp
|
||||
DateTime = 0x03,
|
||||
|
||||
/** Indicates that the value is a date */
|
||||
/// Indicates that the value is a date
|
||||
DateOnly = 0x04,
|
||||
|
||||
/** Indicates that the value is a time of day */
|
||||
/// Indicates that the value is a time of day
|
||||
TimeOnly = 0x05,
|
||||
|
||||
/** Indicates that the value is a list of fixed values */
|
||||
/// Indicates that the value is a list of fixed values
|
||||
Enum = 0x06,
|
||||
|
||||
/** Indicates that the value is a string */
|
||||
/// Indicates that the value is a string
|
||||
Text = 0x07,
|
||||
|
||||
/** Indicates that the value is an email */
|
||||
/// Indicates that the value is an email
|
||||
Email = 0x08,
|
||||
|
||||
/** Indicates that the value is a long string */
|
||||
/// Indicates that the value is a long string
|
||||
TextArea = 0x09,
|
||||
|
||||
/** Indicates that the value should be hidden */
|
||||
/// Indicates that the value should be hidden
|
||||
Password = 0x0A,
|
||||
|
||||
/** Indicates that the value is a phone number */
|
||||
/// Indicates that the value is a phone number
|
||||
PhoneNumber = 0x0B
|
||||
}
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
namespace HopFrame.Core.Configuration;
|
||||
|
||||
/**
|
||||
* The configuration for a table
|
||||
*/
|
||||
/// <summary>
|
||||
/// The configuration for a table
|
||||
/// </summary>
|
||||
public class TableConfig {
|
||||
/** [GENERATED] The unique identifier for the table (usually the name of the model) */
|
||||
/// [GENERATED] The unique identifier for the table (usually the name of the model)
|
||||
public required string Identifier { get; init; }
|
||||
|
||||
/** [GENERATED] The configurations for the properties of the model */
|
||||
/// [GENERATED] The configurations for the properties of the model
|
||||
public IList<PropertyConfig> Properties { get; set; } = new List<PropertyConfig>();
|
||||
|
||||
/** [GENERATED] The type of the model */
|
||||
/// [GENERATED] The type of the model
|
||||
public required Type TableType { get; set; }
|
||||
|
||||
/** [GENERATED] The type identifier for the repository */
|
||||
/// [GENERATED] The type identifier for the repository
|
||||
public required Type RepositoryType { get; set; }
|
||||
|
||||
/** [GENERATED] the url of the table page */
|
||||
/// [GENERATED] the url of the table page
|
||||
public required string Route { get; set; }
|
||||
|
||||
/** [GENERATED] The displayed name of the table */
|
||||
/// [GENERATED] The displayed name of the table
|
||||
public required string DisplayName { get; set; }
|
||||
|
||||
/** A short description for the table */
|
||||
/// A short description for the table
|
||||
public string? Description { get; set; }
|
||||
|
||||
/** [GENERATED] The place (from top to bottom) that the table will appear in on the sidebar */
|
||||
/// [GENERATED] The place (from top to bottom) that the table will appear in on the sidebar
|
||||
public int OrderIndex { get; set; }
|
||||
|
||||
internal TableConfig() {}
|
||||
|
||||
@@ -6,11 +6,11 @@ using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
|
||||
namespace HopFrame.Core.Configurators;
|
||||
|
||||
/**
|
||||
* The configurator for the <see cref="HopFrameConfig"/>
|
||||
*/
|
||||
/// <summary>
|
||||
/// The configurator for the <see cref="HopFrameConfig"/>
|
||||
/// </summary>
|
||||
public class HopFrameConfigurator(HopFrameConfig config, IServiceCollection services) {
|
||||
/** The internal config that is modified */
|
||||
/// The internal config that is modified
|
||||
public HopFrameConfig Config { get; } = config;
|
||||
|
||||
internal IServiceCollection Services { get; } = services;
|
||||
@@ -21,7 +21,7 @@ public class HopFrameConfigurator(HopFrameConfig config, IServiceCollection serv
|
||||
/// <typeparam name="TRepository">The repository that handles the table</typeparam>
|
||||
/// <typeparam name="TModel">The type of the model</typeparam>
|
||||
/// <param name="configurator">The configurator for the table</param>
|
||||
public HopFrameConfigurator AddRepository<TRepository, TModel>(Action<TableConfigurator<TModel>>? configurator = null) where TRepository : IHopFrameRepository where TModel : notnull {
|
||||
public HopFrameConfigurator AddRepository<TRepository, TModel>(Action<TableConfigurator<TModel>>? configurator = null) where TRepository : IHopFrameRepository where TModel : class {
|
||||
var table = ConfigurationHelper.InitializeTable(Config, typeof(TRepository), typeof(TModel));
|
||||
Config.Tables.Add(table);
|
||||
Services.TryAddScoped(typeof(TRepository));
|
||||
@@ -36,7 +36,7 @@ public class HopFrameConfigurator(HopFrameConfig config, IServiceCollection serv
|
||||
/// <param name="configurator">The configurator for the table</param>
|
||||
/// <typeparam name="TModel">The model of the table</typeparam>
|
||||
/// <exception cref="ArgumentException">Is thrown when configuration validation fails</exception>
|
||||
public HopFrameConfigurator AddTable<TModel>(TableConfig config, Action<TableConfigurator<TModel>>? configurator = null) where TModel : notnull {
|
||||
public HopFrameConfigurator AddTable<TModel>(TableConfig config, Action<TableConfigurator<TModel>>? configurator = null) where TModel : class {
|
||||
if (typeof(TModel) != config.TableType)
|
||||
throw new ArgumentException($"Table type for table '{config.Identifier}' does not mach requested type '{typeof(TModel).Name}'!");
|
||||
|
||||
|
||||
@@ -2,50 +2,50 @@
|
||||
|
||||
namespace HopFrame.Core.Configurators;
|
||||
|
||||
/**
|
||||
* The configurator for the <see cref="PropertyConfig"/>
|
||||
*/
|
||||
/// <summary>
|
||||
/// The configurator for the <see cref="PropertyConfig"/>
|
||||
/// </summary>
|
||||
public class PropertyConfigurator(PropertyConfig config) {
|
||||
/** The internal config that is modified */
|
||||
/// The internal config that is modified
|
||||
public PropertyConfig Config { get; } = config;
|
||||
|
||||
/** <inheritdoc cref="PropertyConfig.DisplayName" /> */
|
||||
/// <inheritdoc cref="PropertyConfig.DisplayName" />
|
||||
public PropertyConfigurator SetDisplayName(string displayName) {
|
||||
Config.DisplayName = displayName;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** <inheritdoc cref="PropertyConfig.Listable" /> */
|
||||
/// <inheritdoc cref="PropertyConfig.Listable" />
|
||||
public PropertyConfigurator Listable(bool listable) {
|
||||
Config.Listable = listable;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** <inheritdoc cref="PropertyConfig.Sortable" /> */
|
||||
/// <inheritdoc cref="PropertyConfig.Sortable" />
|
||||
public PropertyConfigurator Sortable(bool sortable) {
|
||||
Config.Sortable = sortable;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** <inheritdoc cref="PropertyConfig.Searchable" /> */
|
||||
/// <inheritdoc cref="PropertyConfig.Searchable" />
|
||||
public PropertyConfigurator Searchable(bool searchable) {
|
||||
Config.Searchable = searchable;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** <inheritdoc cref="PropertyConfig.Editable" /> */
|
||||
/// <inheritdoc cref="PropertyConfig.Editable" />
|
||||
public PropertyConfigurator Editable(bool editable) {
|
||||
Config.Editable = editable;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** <inheritdoc cref="PropertyConfig.Creatable" /> */
|
||||
/// <inheritdoc cref="PropertyConfig.Creatable" />
|
||||
public PropertyConfigurator Creatable(bool creatable) {
|
||||
Config.Creatable = creatable;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** <inheritdoc cref="PropertyConfig.OrderIndex" /> */
|
||||
/// <inheritdoc cref="PropertyConfig.OrderIndex" />
|
||||
public PropertyConfigurator SetOrderIndex(int index) {
|
||||
Config.OrderIndex = index;
|
||||
return this;
|
||||
|
||||
@@ -4,38 +4,38 @@ using HopFrame.Core.Helpers;
|
||||
|
||||
namespace HopFrame.Core.Configurators;
|
||||
|
||||
/**
|
||||
* The configurator for the <see cref="TableConfig"/>
|
||||
*/
|
||||
public class TableConfigurator<TModel>(TableConfig config) where TModel : notnull {
|
||||
/** The internal config that is modified */
|
||||
/// <summary>
|
||||
/// The configurator for the <see cref="TableConfig"/>
|
||||
/// </summary>
|
||||
public class TableConfigurator<TModel>(TableConfig config) where TModel : class {
|
||||
/// The internal config that is modified
|
||||
public TableConfig Config { get; } = config;
|
||||
|
||||
/** <inheritdoc cref="TableConfig.Route"/> */
|
||||
/// <inheritdoc cref="TableConfig.Route"/>
|
||||
public TableConfigurator<TModel> SetRoute(string route) {
|
||||
Config.Route = route;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** <inheritdoc cref="TableConfig.DisplayName"/> */
|
||||
/// <inheritdoc cref="TableConfig.DisplayName"/>
|
||||
public TableConfigurator<TModel> SetDisplayName(string displayName) {
|
||||
Config.DisplayName = displayName;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** <inheritdoc cref="TableConfig.Description"/> */
|
||||
/// <inheritdoc cref="TableConfig.Description"/>
|
||||
public TableConfigurator<TModel> SetDescription(string description) {
|
||||
Config.Description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** <inheritdoc cref="TableConfig.OrderIndex"/> */
|
||||
/// <inheritdoc cref="TableConfig.OrderIndex"/>
|
||||
public TableConfigurator<TModel> SetOrderIndex(int index) {
|
||||
Config.OrderIndex = index;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Returns the configurator for a property */
|
||||
/// Returns the configurator for a property
|
||||
public PropertyConfigurator Property(string identifier) {
|
||||
var prop = Config.Properties
|
||||
.FirstOrDefault(p => p.Identifier == identifier);
|
||||
@@ -46,7 +46,7 @@ public class TableConfigurator<TModel>(TableConfig config) where TModel : notnul
|
||||
return new PropertyConfigurator(prop);
|
||||
}
|
||||
|
||||
/** <inheritdoc cref="Property"/> */
|
||||
/// <inheritdoc cref="Property"/>
|
||||
public PropertyConfigurator Property<TProp>(Expression<Func<TModel, TProp>> propertyExpression) {
|
||||
var propertyName = ExpressionHelper.GetPropertyInfo(propertyExpression).Name;
|
||||
var prop = Config.Properties.FirstOrDefault(p => p.Identifier == propertyName);
|
||||
|
||||
@@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace HopFrame.Core.EFCore;
|
||||
|
||||
/** Adds useful extensions to the <see cref="HopFrameConfigurator"/> to add managed <see cref="DbContext"/> repositories */
|
||||
/// Adds useful extensions to the <see cref="HopFrameConfigurator"/> to add managed <see cref="DbContext"/> repositories
|
||||
public static class HopFrameConfiguratorExtensions {
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -2,48 +2,48 @@
|
||||
|
||||
namespace HopFrame.Core.Repositories;
|
||||
|
||||
/** The base repository that provides access to the model dataset */
|
||||
/// The base repository that provides access to the model dataset
|
||||
public abstract class HopFrameRepository<TModel> : IHopFrameRepository where TModel : class {
|
||||
|
||||
/** <inheritdoc cref="LoadPageGenericAsync"/> */
|
||||
/// <inheritdoc cref="LoadPageGenericAsync"/>
|
||||
public abstract Task<IEnumerable<TModel>> LoadPageAsync(int page, int perPage, CancellationToken ct = default);
|
||||
|
||||
/** <inheritdoc/> */
|
||||
/// <inheritdoc/>
|
||||
public abstract Task<int> CountAsync(CancellationToken ct = default);
|
||||
|
||||
/** <inheritdoc cref="SearchGenericAsync"/> */
|
||||
/// <inheritdoc cref="SearchGenericAsync"/>
|
||||
public abstract Task<IEnumerable<TModel>> SearchAsync(string searchTerm, int page, int perPage, CancellationToken ct = default);
|
||||
|
||||
/** <inheritdoc cref="CreateGenericAsync"/> */
|
||||
/// <inheritdoc cref="CreateGenericAsync"/>
|
||||
public abstract Task CreateAsync(TModel entry, CancellationToken ct = default);
|
||||
|
||||
/** <inheritdoc cref="UpdateGenericAsync"/> */
|
||||
/// <inheritdoc cref="UpdateGenericAsync"/>
|
||||
public abstract Task UpdateAsync(TModel entry, CancellationToken ct = default);
|
||||
|
||||
/** <inheritdoc cref="DeleteGenericAsync"/> */
|
||||
/// <inheritdoc cref="DeleteGenericAsync"/>
|
||||
public abstract Task DeleteAsync(TModel entry, CancellationToken ct = default);
|
||||
|
||||
/** <inheritdoc/> */
|
||||
/// <inheritdoc/>
|
||||
public async Task<IEnumerable> LoadPageGenericAsync(int page, int perPage, CancellationToken ct) {
|
||||
return await LoadPageAsync(page, perPage, ct);
|
||||
}
|
||||
|
||||
/** <inheritdoc/> */
|
||||
/// <inheritdoc/>
|
||||
public async Task<IEnumerable> SearchGenericAsync(string searchTerm, int page, int perPage, CancellationToken ct) {
|
||||
return await SearchAsync(searchTerm, page, perPage, ct);
|
||||
}
|
||||
|
||||
/** <inheritdoc/> */
|
||||
/// <inheritdoc/>
|
||||
public Task CreateGenericAsync(object entry, CancellationToken ct) {
|
||||
return CreateAsync((TModel)entry, ct);
|
||||
}
|
||||
|
||||
/** <inheritdoc/> */
|
||||
/// <inheritdoc/>
|
||||
public Task UpdateGenericAsync(object entry, CancellationToken ct) {
|
||||
return UpdateAsync((TModel)entry, ct);
|
||||
}
|
||||
|
||||
/** <inheritdoc/> */
|
||||
/// <inheritdoc/>
|
||||
public Task DeleteGenericAsync(object entry, CancellationToken ct) {
|
||||
return DeleteAsync((TModel)entry, ct);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#pragma warning disable CS1573 // Parameter has no matching param tag in the XML comment (but other parameters do)
|
||||
namespace HopFrame.Core.Repositories;
|
||||
|
||||
/** The generic repository that provides access to the model dataset */
|
||||
/// The generic repository that provides access to the model dataset
|
||||
public interface IHopFrameRepository {
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -6,10 +6,10 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace HopFrame.Core;
|
||||
|
||||
/** An extension class to provide access to the setup of the library */
|
||||
/// An extension class to provide access to the setup of the library
|
||||
public static class ServiceCollectionExtensions {
|
||||
|
||||
/** Configures the library using the provided configurator */
|
||||
/// Configures the library using the provided configurator
|
||||
public static void AddHopFrame(this IServiceCollection services, Action<HopFrameConfigurator> configurator) {
|
||||
var config = new HopFrameConfig();
|
||||
services.AddSingleton(config);
|
||||
|
||||
@@ -3,7 +3,7 @@ using HopFrame.Core.Repositories;
|
||||
|
||||
namespace HopFrame.Core.Services;
|
||||
|
||||
/** A service used to access configs and repositories provided by the <see cref="HopFrameConfig"/> */
|
||||
/// A service used to access configs and repositories provided by the <see cref="HopFrameConfig"/>
|
||||
public interface IConfigAccessor {
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user