* Ongoing MongoDB work * Refactor MongoDB serializer configuration and improve type handling - Added `BsonSerializerHelpers` for streamlined serializer registration with error handling. - Introduced `ConfigureMongoDbSerializers` hosted service to centralize serializer setup. - Enhanced `FlowScopeSerializer` to handle additional BSON types. - Cleaned up and reorganized MongoDB feature implementations, removing redundant code and improving consistency. * Remove `BsonSerializerHelpers` and update MongoDB serializer registration - Deleted `BsonSerializerHelpers` as it was redundant. - Updated `ConfigureMongoDbSerializers` to directly register serializers using `BsonSerializer`. - Simplified `FlowScopeSerializer` null handling for improved readability. * Switch persistence provider to Entity Framework Core in `Program.cs`. * Update src/modules/Elsa.MongoDb/Serializers/FlowScopeSerializer.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Configures MongoDB services and options. Configures MongoDB services, including client and database creation. Registers default naming strategy and collection naming strategy. Adds BsonClassMap configuration for KeyValuePair. * Simplify null check in `FlowScopeSerializer`. * Allow `FlowScopeSerializer` to handle nullable `FlowScope`. * Registers FlowScope BSON class map Registers the `FlowScope` class with BSON to enable proper serialization and deserialization of workflow scopes within MongoDB. This ensures that workflow scopes, which are used to manage variables within a workflow, are correctly stored and retrieved from the database. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
55 lines
2 KiB
C#
55 lines
2 KiB
C#
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
namespace Elsa.Features.Services;
|
|
|
|
/// <summary>
|
|
/// A thin abstraction on top of <see cref="IServiceCollection"/> to help organize features and dependencies.
|
|
/// </summary>
|
|
public interface IModule
|
|
{
|
|
/// <summary>
|
|
/// The service collection being populated.
|
|
/// </summary>
|
|
IServiceCollection Services { get; }
|
|
|
|
/// <summary>
|
|
/// A dictionary into which features can stash away values for later use.
|
|
/// </summary>
|
|
IDictionary<object, object> Properties { get; }
|
|
|
|
/// <summary>
|
|
/// Returns true if a feature of the specified type has been configured.
|
|
/// </summary>
|
|
bool HasFeature<T>() where T : class, IFeature;
|
|
|
|
/// <summary>
|
|
/// Returns true if a feature of the specified type has been configured.
|
|
/// </summary>
|
|
bool HasFeature(Type featureType);
|
|
|
|
/// <summary>
|
|
/// Creates and configures a feature of the specified type.
|
|
/// </summary>
|
|
T Configure<T>(Action<T>? configure = null) where T : class, IFeature;
|
|
|
|
/// <summary>
|
|
/// Creates and configures a feature of the specified type.
|
|
/// </summary>
|
|
T Configure<T>(Func<IModule, T> factory, Action<T>? configure = null) where T : class, IFeature;
|
|
|
|
/// <summary>
|
|
/// Configures a <see cref="IHostedService"/> using an optional priority to control in which order it will be registered with the service container.
|
|
/// </summary>
|
|
IModule ConfigureHostedService<T>(int priority = 0) where T : class, IHostedService;
|
|
|
|
/// <summary>
|
|
/// Configures a <see cref="IHostedService"/> using an optional priority to control in which order it will be registered with the service container.
|
|
/// </summary>
|
|
IModule ConfigureHostedService(Type hostedServiceType, int priority = 0);
|
|
|
|
/// <summary>
|
|
/// Will apply all configured features, causing the <see cref="Services"/> collection to be populated.
|
|
/// </summary>
|
|
void Apply();
|
|
} |