585 lines
19 KiB
C#
585 lines
19 KiB
C#
using System;
|
|
using GraphQL.Types;
|
|
using xDataService.Db;
|
|
using xDataService.GraphQL;
|
|
using xDataService.Interfaces;
|
|
using xDataService.Providers;
|
|
using xModels.Base;
|
|
|
|
namespace xDataService.Models
|
|
{
|
|
/// <summary>
|
|
/// a Global non Generic Repository Descriptor ...
|
|
/// </summary>
|
|
public class XRepositoryDescriptor
|
|
{
|
|
/// <summary>
|
|
/// Entity Key Type ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
public Type Key { get; set; } = null;
|
|
|
|
/// <summary>
|
|
/// Entity Type ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
public Type Entity { get; set; } = null;
|
|
|
|
/// <summary>
|
|
/// Context Type ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
public Type Context { get; set; } = null;
|
|
|
|
/// <summary>
|
|
/// Graph Type Key ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
public Type GraphTypeKey { get; set; } = null;
|
|
|
|
/// <summary>
|
|
/// Graph Type ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
public Type GraphType { get; set; } = null;
|
|
|
|
/// <summary>
|
|
/// Entity Type GraphQL Schema ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
public Type GraphSchema { get; set; } = null;
|
|
|
|
/// <summary>
|
|
/// Entity GraphQL Type Helper ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
public Type GraphTypeHelperService { get; set; } = null;
|
|
|
|
/// <summary>
|
|
/// Entity GraphQL Type Helper ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
public Type GraphTypeHelperImplementation { get; set; } = null;
|
|
|
|
/// <summary>
|
|
/// Entity GrapQL Query ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
public Type GraphQuery { get; set; } = null;
|
|
|
|
/// <summary>
|
|
/// Repository Event Provider ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
public Type EventsService { get; set; } = null;
|
|
|
|
/// <summary>
|
|
/// Repository Event Provider ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
public Type EventsImplementation { get; set; } = null;
|
|
|
|
/// <summary>
|
|
/// Repository Key Generator for Entity ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
public Type KeyGeneratorService { get; set; } = null;
|
|
|
|
/// <summary>
|
|
/// Repository Key Generator for Entity ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
public Type KeyGeneratorImplementation { get; set; } = null;
|
|
|
|
/// <summary>
|
|
/// Repository Data Access Design Pattern ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
public Type RepositoryService { get; set; } = null;
|
|
|
|
/// <summary>
|
|
/// Repository Data Access Design Pattern ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
public Type RepositoryImplementation { get; set; } = null;
|
|
|
|
/// <summary>
|
|
/// Database Data Seeder ...
|
|
/// </summary>
|
|
public Type SeederService { get; set; } = null;
|
|
|
|
/// <summary>
|
|
/// Database Data Seeder ...
|
|
/// </summary>
|
|
public Type SeederImplementation { get; set; } = null;
|
|
}
|
|
|
|
/// <summary>
|
|
/// a Repository Descriptor ...
|
|
/// </summary>
|
|
/// <typeparam name="TEntity"></typeparam>
|
|
/// <typeparam name="TKey"></typeparam>
|
|
public class XRepositoryDescriptor<TEntity, TKey> : XRepositoryDescriptor
|
|
where TEntity : XBaseEntity<TKey>
|
|
{
|
|
public XRepositoryDescriptor() : base()
|
|
{
|
|
//
|
|
Key = typeof(TKey);
|
|
Entity = typeof(TEntity);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// a Repository Descriptor ...
|
|
/// </summary>
|
|
public class XRepositoryDescriptor<
|
|
TEntity,
|
|
TKey,
|
|
TKeyGeneratorService,
|
|
TKeyGeneratorImplementation
|
|
> : XRepositoryDescriptor<TEntity, TKey>
|
|
where TEntity : XBaseEntity<TKey>
|
|
where TKeyGeneratorService : IXKeyGenerator<TEntity, TKey>
|
|
where TKeyGeneratorImplementation : XKeyGenerator<TEntity, TKey>
|
|
{
|
|
public XRepositoryDescriptor() : base()
|
|
{
|
|
//
|
|
KeyGeneratorService = typeof(TKeyGeneratorService);
|
|
KeyGeneratorImplementation = typeof(TKeyGeneratorImplementation);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// a Repository Descriptor ...
|
|
/// </summary>
|
|
public class XRepositoryDescriptor<
|
|
TEntity,
|
|
TKey,
|
|
TKeyGeneratorService,
|
|
TKeyGeneratorImplementation,
|
|
TEventsService,
|
|
TEventsImplementation
|
|
> : XRepositoryDescriptor<
|
|
TEntity,
|
|
TKey,
|
|
TKeyGeneratorService,
|
|
TKeyGeneratorImplementation
|
|
>
|
|
where TEntity : XBaseEntity<TKey>
|
|
where TEventsService : IXBaseRepositoryEvents<TEntity>
|
|
where TKeyGeneratorService : IXKeyGenerator<TEntity, TKey>
|
|
where TEventsImplementation : XBaseRepositoryEvents<TEntity>
|
|
where TKeyGeneratorImplementation : XKeyGenerator<TEntity, TKey>
|
|
{
|
|
public XRepositoryDescriptor() : base()
|
|
{
|
|
//
|
|
EventsService = typeof(TEventsService);
|
|
EventsImplementation = typeof(TEventsImplementation);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// a Repository Descriptor ...
|
|
/// </summary>
|
|
public class XRepositoryDescriptor<
|
|
TEntity,
|
|
TKey,
|
|
TKeyGeneratorService,
|
|
TKeyGeneratorImplementation,
|
|
TEventsService,
|
|
TEventsImplementation,
|
|
TGraph,
|
|
TGraphKey,
|
|
TGraphQuery,
|
|
TGraphTypeHelperService,
|
|
TGraphTypeHelperImplementation,
|
|
TGraphSchema
|
|
> : XRepositoryDescriptor<
|
|
TEntity,
|
|
TKey,
|
|
TKeyGeneratorService,
|
|
TKeyGeneratorImplementation,
|
|
TEventsService,
|
|
TEventsImplementation
|
|
>
|
|
where TGraphSchema : Schema
|
|
where TGraphKey : IGraphType
|
|
where TEntity : XBaseEntity<TKey>
|
|
where TGraph : XBaseGraphObjectType<TEntity, TKey>
|
|
where TEventsService : IXBaseRepositoryEvents<TEntity>
|
|
where TKeyGeneratorService : IXKeyGenerator<TEntity, TKey>
|
|
where TEventsImplementation : XBaseRepositoryEvents<TEntity>
|
|
where TKeyGeneratorImplementation : XKeyGenerator<TEntity, TKey>
|
|
where TGraphTypeHelperService : IXBaseGraphQLTypeHelper<TEntity, TKey>
|
|
where TGraphQuery : XBaseGraphQLQuery<TEntity, TKey, TGraph, TGraphKey>
|
|
where TGraphTypeHelperImplementation : XBaseGraphQLTypeHelper<TEntity, TKey>
|
|
{
|
|
public XRepositoryDescriptor() : base()
|
|
{
|
|
//
|
|
GraphType = typeof(TGraph);
|
|
GraphTypeKey = typeof(TGraphKey);
|
|
GraphQuery = typeof(TGraphQuery);
|
|
GraphSchema = typeof(TGraphSchema);
|
|
GraphTypeHelperService = typeof(TGraphTypeHelperService);
|
|
GraphTypeHelperImplementation = typeof(TGraphTypeHelperImplementation);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// a Repository Descriptor ...
|
|
/// </summary>
|
|
public class XInMemoryRepositoryDescriptor<
|
|
TEntity,
|
|
TKey,
|
|
TKeyGeneratorService,
|
|
TKeyGeneratorImplementation,
|
|
TEventsService,
|
|
TEventsImplementation,
|
|
TGraph,
|
|
TGraphKey,
|
|
TGraphQuery,
|
|
TGraphTypeHelperService,
|
|
TGraphTypeHelperImplementation,
|
|
TGraphSchema,
|
|
TRepositoryService,
|
|
TRepositoryImplementation
|
|
> : XRepositoryDescriptor<
|
|
TEntity,
|
|
TKey,
|
|
TKeyGeneratorService,
|
|
TKeyGeneratorImplementation,
|
|
TEventsService,
|
|
TEventsImplementation,
|
|
TGraph,
|
|
TGraphKey,
|
|
TGraphQuery,
|
|
TGraphTypeHelperService,
|
|
TGraphTypeHelperImplementation,
|
|
TGraphSchema
|
|
>
|
|
where TGraphSchema : Schema
|
|
where TGraphKey : IGraphType
|
|
where TEntity : XBaseEntity<TKey>
|
|
where TGraph : XBaseGraphObjectType<TEntity, TKey>
|
|
where TEventsService : IXBaseRepositoryEvents<TEntity>
|
|
where TKeyGeneratorService : IXKeyGenerator<TEntity, TKey>
|
|
where TRepositoryService : IXBaseRepository<TEntity, TKey>
|
|
where TEventsImplementation : XBaseRepositoryEvents<TEntity>
|
|
where TKeyGeneratorImplementation : XKeyGenerator<TEntity, TKey>
|
|
where TGraphTypeHelperService : IXBaseGraphQLTypeHelper<TEntity, TKey>
|
|
where TRepositoryImplementation : XBaseInMemoryRepository<TEntity, TKey>
|
|
where TGraphQuery : XBaseGraphQLQuery<TEntity, TKey, TGraph, TGraphKey>
|
|
where TGraphTypeHelperImplementation : XBaseGraphQLTypeHelper<TEntity, TKey>
|
|
{
|
|
public XInMemoryRepositoryDescriptor() : base()
|
|
{
|
|
//
|
|
RepositoryService = typeof(TRepositoryService);
|
|
RepositoryImplementation = typeof(TRepositoryImplementation);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// a Repository Descriptor ...
|
|
/// </summary>
|
|
public class XInMemoryRepositoryDescriptor<
|
|
TEntity,
|
|
TKey,
|
|
TKeyGeneratorService,
|
|
TKeyGeneratorImplementation,
|
|
TEventsService,
|
|
TEventsImplementation,
|
|
TGraph,
|
|
TGraphKey,
|
|
TGraphQuery,
|
|
TGraphTypeHelperService,
|
|
TGraphTypeHelperImplementation,
|
|
TGraphSchema,
|
|
TRepositoryService,
|
|
TRepositoryImplementation,
|
|
TSeederService,
|
|
TSeederImplementation
|
|
> : XRepositoryDescriptor<
|
|
TEntity,
|
|
TKey,
|
|
TKeyGeneratorService,
|
|
TKeyGeneratorImplementation,
|
|
TEventsService,
|
|
TEventsImplementation,
|
|
TGraph,
|
|
TGraphKey,
|
|
TGraphQuery,
|
|
TGraphTypeHelperService,
|
|
TGraphTypeHelperImplementation,
|
|
TGraphSchema
|
|
>
|
|
where TGraphSchema : Schema
|
|
where TGraphKey : IGraphType
|
|
where TEntity : XBaseEntity<TKey>
|
|
where TGraph : XBaseGraphObjectType<TEntity, TKey>
|
|
where TSeederService : IXBaseDbSeeder<TEntity, TKey>
|
|
where TEventsService : IXBaseRepositoryEvents<TEntity>
|
|
where TKeyGeneratorService : IXKeyGenerator<TEntity, TKey>
|
|
where TRepositoryService : IXBaseRepository<TEntity, TKey>
|
|
where TSeederImplementation : XBaseDbSeeder<TEntity, TKey>
|
|
where TEventsImplementation : XBaseRepositoryEvents<TEntity>
|
|
where TKeyGeneratorImplementation : XKeyGenerator<TEntity, TKey>
|
|
where TGraphTypeHelperService : IXBaseGraphQLTypeHelper<TEntity, TKey>
|
|
where TRepositoryImplementation : XBaseInMemoryRepository<TEntity, TKey>
|
|
where TGraphQuery : XBaseGraphQLQuery<TEntity, TKey, TGraph, TGraphKey>
|
|
where TGraphTypeHelperImplementation : XBaseGraphQLTypeHelper<TEntity, TKey>
|
|
{
|
|
public XInMemoryRepositoryDescriptor() : base()
|
|
{
|
|
//
|
|
SeederService = typeof(TSeederService);
|
|
SeederImplementation = typeof(TSeederImplementation);
|
|
|
|
//
|
|
RepositoryService = typeof(TRepositoryService);
|
|
RepositoryImplementation = typeof(TRepositoryImplementation);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// a Repository Descriptor ...
|
|
/// </summary>
|
|
public class XMongoRepositoryDescriptor<
|
|
TEntity,
|
|
TKey,
|
|
TKeyGeneratorService,
|
|
TKeyGeneratorImplementation,
|
|
TEventsService,
|
|
TEventsImplementation,
|
|
TGraph,
|
|
TGraphKey,
|
|
TGraphQuery,
|
|
TGraphTypeHelperService,
|
|
TGraphTypeHelperImplementation,
|
|
TGraphSchema,
|
|
TRepositoryService,
|
|
TRepositoryImplementation
|
|
> : XRepositoryDescriptor<
|
|
TEntity,
|
|
TKey,
|
|
TKeyGeneratorService,
|
|
TKeyGeneratorImplementation,
|
|
TEventsService,
|
|
TEventsImplementation,
|
|
TGraph,
|
|
TGraphKey,
|
|
TGraphQuery,
|
|
TGraphTypeHelperService,
|
|
TGraphTypeHelperImplementation,
|
|
TGraphSchema
|
|
>
|
|
where TGraphSchema : Schema
|
|
where TGraphKey : IGraphType
|
|
where TEntity : XBaseEntity<TKey>
|
|
where TGraph : XBaseGraphObjectType<TEntity, TKey>
|
|
where TEventsService : IXBaseRepositoryEvents<TEntity>
|
|
where TKeyGeneratorService : IXKeyGenerator<TEntity, TKey>
|
|
where TRepositoryService : IXBaseRepository<TEntity, TKey>
|
|
where TEventsImplementation : XBaseRepositoryEvents<TEntity>
|
|
where TKeyGeneratorImplementation : XKeyGenerator<TEntity, TKey>
|
|
where TRepositoryImplementation : XBaseMongoRepository<TEntity, TKey>
|
|
where TGraphTypeHelperService : IXBaseGraphQLTypeHelper<TEntity, TKey>
|
|
where TGraphQuery : XBaseGraphQLQuery<TEntity, TKey, TGraph, TGraphKey>
|
|
where TGraphTypeHelperImplementation : XBaseGraphQLTypeHelper<TEntity, TKey>
|
|
{
|
|
public XMongoRepositoryDescriptor() : base()
|
|
{
|
|
//
|
|
RepositoryService = typeof(TRepositoryService);
|
|
RepositoryImplementation = typeof(TRepositoryImplementation);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// a Repository Descriptor ...
|
|
/// </summary>
|
|
public class XMongoRepositoryDescriptor<
|
|
TEntity,
|
|
TKey,
|
|
TKeyGeneratorService,
|
|
TKeyGeneratorImplementation,
|
|
TEventsService,
|
|
TEventsImplementation,
|
|
TGraph,
|
|
TGraphKey,
|
|
TGraphQuery,
|
|
TGraphTypeHelperService,
|
|
TGraphTypeHelperImplementation,
|
|
TGraphSchema,
|
|
TRepositoryService,
|
|
TRepositoryImplementation,
|
|
TSeederService,
|
|
TSeederImplementation
|
|
> : XRepositoryDescriptor<
|
|
TEntity,
|
|
TKey,
|
|
TKeyGeneratorService,
|
|
TKeyGeneratorImplementation,
|
|
TEventsService,
|
|
TEventsImplementation,
|
|
TGraph,
|
|
TGraphKey,
|
|
TGraphQuery,
|
|
TGraphTypeHelperService,
|
|
TGraphTypeHelperImplementation,
|
|
TGraphSchema
|
|
>
|
|
where TGraphSchema : Schema
|
|
where TGraphKey : IGraphType
|
|
where TEntity : XBaseEntity<TKey>
|
|
where TGraph : XBaseGraphObjectType<TEntity, TKey>
|
|
where TSeederService : IXBaseDbSeeder<TEntity, TKey>
|
|
where TEventsService : IXBaseRepositoryEvents<TEntity>
|
|
where TSeederImplementation : XBaseDbSeeder<TEntity, TKey>
|
|
where TKeyGeneratorService : IXKeyGenerator<TEntity, TKey>
|
|
where TRepositoryService : IXBaseRepository<TEntity, TKey>
|
|
where TEventsImplementation : XBaseRepositoryEvents<TEntity>
|
|
where TKeyGeneratorImplementation : XKeyGenerator<TEntity, TKey>
|
|
where TRepositoryImplementation : XBaseMongoRepository<TEntity, TKey>
|
|
where TGraphTypeHelperService : IXBaseGraphQLTypeHelper<TEntity, TKey>
|
|
where TGraphQuery : XBaseGraphQLQuery<TEntity, TKey, TGraph, TGraphKey>
|
|
where TGraphTypeHelperImplementation : XBaseGraphQLTypeHelper<TEntity, TKey>
|
|
{
|
|
public XMongoRepositoryDescriptor() : base()
|
|
{
|
|
//
|
|
SeederService = typeof(TSeederService);
|
|
SeederImplementation = typeof(TSeederImplementation);
|
|
|
|
//
|
|
RepositoryService = typeof(TRepositoryService);
|
|
RepositoryImplementation = typeof(TRepositoryImplementation);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// a Repository Descriptor ...
|
|
/// </summary>
|
|
public class XEFRepositoryDescriptor<
|
|
TEntity,
|
|
TKey,
|
|
TKeyGeneratorService,
|
|
TKeyGeneratorImplementation,
|
|
TEventsService,
|
|
TEventsImplementation,
|
|
TGraph,
|
|
TGraphKey,
|
|
TGraphQuery,
|
|
TGraphTypeHelperService,
|
|
TGraphTypeHelperImplementation,
|
|
TGraphSchema,
|
|
TRepositoryService,
|
|
TRepositoryImplementation,
|
|
TContext
|
|
> : XRepositoryDescriptor<
|
|
TEntity,
|
|
TKey,
|
|
TKeyGeneratorService,
|
|
TKeyGeneratorImplementation,
|
|
TEventsService,
|
|
TEventsImplementation,
|
|
TGraph,
|
|
TGraphKey,
|
|
TGraphQuery,
|
|
TGraphTypeHelperService,
|
|
TGraphTypeHelperImplementation,
|
|
TGraphSchema
|
|
>
|
|
where TGraphSchema : Schema
|
|
where TContext : XDbContext
|
|
where TGraphKey : IGraphType
|
|
where TEntity : XBaseEntity<TKey>
|
|
where TGraph : XBaseGraphObjectType<TEntity, TKey>
|
|
where TEventsService : IXBaseRepositoryEvents<TEntity>
|
|
where TKeyGeneratorService : IXKeyGenerator<TEntity, TKey>
|
|
where TRepositoryService : IXBaseRepository<TEntity, TKey>
|
|
where TEventsImplementation : XBaseRepositoryEvents<TEntity>
|
|
where TKeyGeneratorImplementation : XKeyGenerator<TEntity, TKey>
|
|
where TGraphTypeHelperService : IXBaseGraphQLTypeHelper<TEntity, TKey>
|
|
where TGraphQuery : XBaseGraphQLQuery<TEntity, TKey, TGraph, TGraphKey>
|
|
where TRepositoryImplementation : XBaseEFRepository<TEntity, TKey, TContext>
|
|
where TGraphTypeHelperImplementation : XBaseGraphQLTypeHelper<TEntity, TKey>
|
|
{
|
|
public XEFRepositoryDescriptor() : base()
|
|
{
|
|
//
|
|
Context = typeof(TContext);
|
|
RepositoryService = typeof(TRepositoryService);
|
|
RepositoryImplementation = typeof(TRepositoryImplementation);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// a Repository Descriptor ...
|
|
/// </summary>
|
|
public class XEFRepositoryDescriptor<
|
|
TEntity,
|
|
TKey,
|
|
TKeyGeneratorService,
|
|
TKeyGeneratorImplementation,
|
|
TEventsService,
|
|
TEventsImplementation,
|
|
TGraph,
|
|
TGraphKey,
|
|
TGraphQuery,
|
|
TGraphTypeHelperService,
|
|
TGraphTypeHelperImplementation,
|
|
TGraphSchema,
|
|
TRepositoryService,
|
|
TRepositoryImplementation,
|
|
TContext,
|
|
TSeederService,
|
|
TSeederImplementation
|
|
> : XRepositoryDescriptor<
|
|
TEntity,
|
|
TKey,
|
|
TKeyGeneratorService,
|
|
TKeyGeneratorImplementation,
|
|
TEventsService,
|
|
TEventsImplementation,
|
|
TGraph,
|
|
TGraphKey,
|
|
TGraphQuery,
|
|
TGraphTypeHelperService,
|
|
TGraphTypeHelperImplementation,
|
|
TGraphSchema
|
|
>
|
|
where TGraphSchema : Schema
|
|
where TContext : XDbContext
|
|
where TGraphKey : IGraphType
|
|
where TEntity : XBaseEntity<TKey>
|
|
where TGraph : XBaseGraphObjectType<TEntity, TKey>
|
|
where TSeederService : IXBaseDbSeeder<TEntity, TKey>
|
|
where TEventsService : IXBaseRepositoryEvents<TEntity>
|
|
where TSeederImplementation : XBaseDbSeeder<TEntity, TKey>
|
|
where TKeyGeneratorService : IXKeyGenerator<TEntity, TKey>
|
|
where TRepositoryService : IXBaseRepository<TEntity, TKey>
|
|
where TEventsImplementation : XBaseRepositoryEvents<TEntity>
|
|
where TKeyGeneratorImplementation : XKeyGenerator<TEntity, TKey>
|
|
where TGraphTypeHelperService : IXBaseGraphQLTypeHelper<TEntity, TKey>
|
|
where TGraphQuery : XBaseGraphQLQuery<TEntity, TKey, TGraph, TGraphKey>
|
|
where TRepositoryImplementation : XBaseEFRepository<TEntity, TKey, TContext>
|
|
where TGraphTypeHelperImplementation : XBaseGraphQLTypeHelper<TEntity, TKey>
|
|
{
|
|
public XEFRepositoryDescriptor() : base()
|
|
{
|
|
//
|
|
SeederService = typeof(TSeederService);
|
|
SeederImplementation = typeof(TSeederImplementation);
|
|
|
|
//
|
|
Context = typeof(TContext);
|
|
RepositoryService = typeof(TRepositoryService);
|
|
RepositoryImplementation = typeof(TRepositoryImplementation);
|
|
}
|
|
}
|
|
} |