1182 lines
37 KiB
Plaintext
1182 lines
37 KiB
Plaintext
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Configuration\Entities\XContentEntityConfiguration.cs
|
|
|
|
using System;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
using xContentService.Constants;
|
|
using xContentService.Models.Entities;
|
|
using xDataService.Providers;
|
|
|
|
namespace xContentService.Configuration.Entities
|
|
{
|
|
public class XContentEntityConfiguration : XBaseEntityTypeConfiguration<XContent, Guid>
|
|
{
|
|
public override void Configure(EntityTypeBuilder<XContent> builder)
|
|
{
|
|
builder.ToTable(XContentServiceConstants.XContentTable);
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Constants\XContentServiceConstants.cs
|
|
|
|
namespace xContentService.Constants
|
|
{
|
|
public struct XContentServiceConstants
|
|
{
|
|
//
|
|
// Service Extensions Log Tag ...
|
|
public const string XContentServiceDILogTag = "XContentService";
|
|
|
|
//
|
|
// Table Mapping Identifiers ...
|
|
public const string XContentTable = "Contents";
|
|
|
|
//
|
|
// GraphQL Collection Mappings ...
|
|
public const string XContentSingleName = "content";
|
|
public const string XContentCollectionName = "contents";
|
|
|
|
//
|
|
// Hubs ...
|
|
public const string XContentDtoHub = "contentDto";
|
|
public const string XContentEntityHub = "contentEntity";
|
|
|
|
//
|
|
// EF Repositories Helper Extensions ...
|
|
public const string GetXContentEFRepositoryDescriptor = "GetXContentEFRepositoryDescriptor";
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\DI\XDIHelperExtensions.cs
|
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using xCommons.Extensions;
|
|
using xContentService.Constants;
|
|
using xContentService.Providers.Dtos;
|
|
using xContentService.Providers.Entities;
|
|
using xDataService.Constants;
|
|
using xDataService.Models;
|
|
using xPushService.DI;
|
|
using xDataService.DI;
|
|
using xPushService.Helpers;
|
|
using System;
|
|
using xExceptions.Constants;
|
|
using xContentService.Helpers;
|
|
using xCommons.Helpers;
|
|
using xContentService.Interfaces.Dtos;
|
|
using xContentService.Interfaces.Entities;
|
|
using xDataService.Db;
|
|
|
|
namespace xContentService.DI
|
|
{
|
|
/// <summary>
|
|
/// Service Registration Extensions Classes ...
|
|
/// </summary>
|
|
public static partial class XDIHelperExtensions
|
|
{
|
|
/// <summary>
|
|
/// Register Service ...
|
|
/// </summary>
|
|
/// <param name="services"></param>
|
|
/// <param name="repositoryType"></param>
|
|
/// <param name="lifeTime"></param>
|
|
public static void AddXContentService(
|
|
this IServiceCollection services,
|
|
XRepositoryType repositoryType,
|
|
ServiceLifetime lifeTime = ServiceLifetime.Scoped
|
|
)
|
|
{
|
|
AddContentService(
|
|
contextType: null,
|
|
services: services,
|
|
lifeTime: lifeTime,
|
|
repositoryType: repositoryType
|
|
);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Register Service ...
|
|
/// </summary>
|
|
/// <typeparam name="TContext"></typeparam>
|
|
/// <param name="services"></param>
|
|
/// <param name="repositoryType"></param>
|
|
/// <param name="lifeTime"></param>
|
|
public static void AddXContentService<TContext>(
|
|
this IServiceCollection services,
|
|
XRepositoryType repositoryType,
|
|
ServiceLifetime lifeTime = ServiceLifetime.Scoped
|
|
)
|
|
where TContext : XDbContext
|
|
{
|
|
AddContentService(
|
|
services: services,
|
|
lifeTime: lifeTime,
|
|
contextType: typeof(TContext),
|
|
repositoryType: repositoryType
|
|
);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Use xContentService Middleware ...
|
|
/// </summary>
|
|
/// <param name="app"></param>
|
|
/// <param name="isDevelopmentEnvironment"></param>
|
|
public static void UseXContentService(
|
|
this IApplicationBuilder app,
|
|
bool isDevelopmentEnvironment = false
|
|
)
|
|
{
|
|
//
|
|
#region Using XContent Hubs ...
|
|
//
|
|
var pushHelper = new XPushServiceHelper();
|
|
|
|
//
|
|
pushHelper.AddHub<XContentDtoHub>(XContentServiceConstants.XContentDtoHub);
|
|
pushHelper.AddHub<XContentEntityHub>(XContentServiceConstants.XContentEntityHub);
|
|
|
|
//
|
|
app.UseXPushService(pushHelper);
|
|
#endregion
|
|
|
|
//
|
|
// Using XContent Repository Descriptor ...
|
|
if (!descriptor.IsNull())
|
|
{
|
|
//
|
|
app.UseXRepository(
|
|
descriptor: descriptor,
|
|
isDevelopmentEnvironment: isDevelopmentEnvironment
|
|
);
|
|
}
|
|
}
|
|
|
|
//
|
|
#region Private ...
|
|
private static XRepositoryDescriptor descriptor = null;
|
|
|
|
/// <summary>
|
|
/// a LogTag for Service ...
|
|
/// </summary>
|
|
private static string XLogTag = XContentServiceConstants.XContentServiceDILogTag;
|
|
|
|
/// <summary>
|
|
/// print a log in Console ...
|
|
/// </summary>
|
|
/// <param name="message"></param>
|
|
private static void Log(string message)
|
|
{
|
|
Console.WriteLine($"{XLogTag} => {message}");
|
|
}
|
|
|
|
/// <summary>
|
|
/// Register Service ...
|
|
/// </summary>
|
|
/// <param name="services"></param>
|
|
/// <param name="repositoryType"></param>
|
|
/// <param name="contextType"></param>
|
|
/// <param name="lifeTime"></param>
|
|
private static void AddContentService(
|
|
IServiceCollection services,
|
|
XRepositoryType repositoryType,
|
|
Type contextType = null,
|
|
ServiceLifetime lifeTime = ServiceLifetime.Scoped
|
|
)
|
|
{
|
|
//
|
|
var exception = XException.InvalidArgs.ToException(); ;
|
|
|
|
//
|
|
// Services ...
|
|
var isServicesExists = !services.IsNull();
|
|
if (!isServicesExists)
|
|
{
|
|
//
|
|
Log("Service Registration failed, services not provided ...");
|
|
throw exception;
|
|
}
|
|
|
|
//
|
|
// Lifetime ...
|
|
var isLifetimeExists = !lifeTime.IsNull();
|
|
if (!isLifetimeExists)
|
|
{
|
|
//
|
|
Log("Service Registration failed, lifetime not provided ...");
|
|
throw exception;
|
|
}
|
|
|
|
//
|
|
// Validate Repository Type ...
|
|
var isRepositoryTypeValid =
|
|
(repositoryType == XRepositoryType.EF &&
|
|
!contextType.IsNull()) ||
|
|
((repositoryType == XRepositoryType.Mongo ||
|
|
repositoryType == XRepositoryType.InMemory) &&
|
|
contextType.IsNull());
|
|
if (!isRepositoryTypeValid)
|
|
{
|
|
//
|
|
Log("Service Registration failed, Invalid Repository Type and Context Type ...");
|
|
throw exception;
|
|
}
|
|
|
|
//
|
|
// Maske Instance of Repository Descriptor
|
|
// Based on Provided Type ...
|
|
switch (repositoryType)
|
|
{
|
|
//
|
|
case XRepositoryType.EF:
|
|
//
|
|
descriptor = typeof(XContentServiceHelper)
|
|
.InvokeGenericMethod<XRepositoryDescriptor>(
|
|
args: null,
|
|
runtimeType: contextType,
|
|
methodName: XContentServiceConstants.GetXContentEFRepositoryDescriptor
|
|
);
|
|
break;
|
|
|
|
//
|
|
case XRepositoryType.Mongo:
|
|
descriptor = XContentServiceHelper.GetXContentMongoRepositoryDescriptor();
|
|
break;
|
|
|
|
//
|
|
case XRepositoryType.InMemory:
|
|
descriptor = XContentServiceHelper.GetXContentInMemoryRepositoryDescriptor();
|
|
break;
|
|
}
|
|
|
|
//
|
|
// Register XContent Repository Descriptor ...
|
|
services.AddXRepository(
|
|
lifeTime: lifeTime,
|
|
descriptor: descriptor
|
|
);
|
|
|
|
//
|
|
// Register Dto Services ...
|
|
services.Add(
|
|
new ServiceDescriptor(typeof(IXContentServiceProvider), typeof(XContentServiceProvider), lifeTime)
|
|
);
|
|
services.Add(
|
|
new ServiceDescriptor(typeof(IXContentRepositoryService), typeof(XContentRepositoryService), lifeTime)
|
|
);
|
|
services.Add(
|
|
new ServiceDescriptor(typeof(IXContentRepositoryProvider), typeof(XContentRepositoryProvider), lifeTime)
|
|
);
|
|
|
|
//
|
|
// Register Additional Service ...
|
|
// services.Add(
|
|
// new ServiceDescriptor(typeof(IXContentTagProvider), typeof(XContentTagProvider), lifeTime)
|
|
// );
|
|
// services.Add(
|
|
// new ServiceDescriptor(typeof(IXContentTagProvided), typeof(XContentTagProvided), lifeTime)
|
|
// );
|
|
// services.Add(
|
|
// new ServiceDescriptor(typeof(IXContentProvider), typeof(XContentProvider), lifeTime)
|
|
// );
|
|
|
|
//
|
|
Log("Service Regitration Succeed ...");
|
|
}
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Helpers\XContentServiceHelper.cs
|
|
|
|
using System;
|
|
using GraphQL.Types;
|
|
using xContentService.Interfaces.Entities;
|
|
using xContentService.Models.Entities;
|
|
using xContentService.Providers.Entities;
|
|
using xContentService.Providers.GraphQL;
|
|
using xDataService.Db;
|
|
using xDataService.Models;
|
|
using xDataService.Providers;
|
|
|
|
namespace xContentService.Helpers
|
|
{
|
|
public static class XContentServiceHelper
|
|
{
|
|
//
|
|
#region XContent ...
|
|
//
|
|
#region EF Repository Descriptor Provider(s) ...
|
|
public static XEFRepositoryDescriptor<
|
|
XContent,
|
|
Guid,
|
|
IXContentKeyGenerator,
|
|
XContentKeyGenerator,
|
|
IXContentRepositoryEvents,
|
|
XContentRepositoryEvents,
|
|
XContentGraphType,
|
|
GuidGraphType,
|
|
XContentGraphQuery,
|
|
IXContentGraphQLTypeHelper,
|
|
XContentGraphQLTypeHelper,
|
|
XContentGraphSchema,
|
|
IXContentRepository,
|
|
XContentEFRepository<TContext>,
|
|
TContext
|
|
> GetXContentEFRepositoryDescriptor<TContext>()
|
|
where TContext : XDbContext
|
|
{
|
|
//
|
|
var result = new XEFRepositoryDescriptor<
|
|
XContent,
|
|
Guid,
|
|
IXContentKeyGenerator,
|
|
XContentKeyGenerator,
|
|
IXContentRepositoryEvents,
|
|
XContentRepositoryEvents,
|
|
XContentGraphType,
|
|
GuidGraphType,
|
|
XContentGraphQuery,
|
|
IXContentGraphQLTypeHelper,
|
|
XContentGraphQLTypeHelper,
|
|
XContentGraphSchema,
|
|
IXContentRepository,
|
|
XContentEFRepository<TContext>,
|
|
TContext
|
|
>();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
public static XEFRepositoryDescriptor<
|
|
XContent,
|
|
Guid,
|
|
IXContentKeyGenerator,
|
|
XContentKeyGenerator,
|
|
IXContentRepositoryEvents,
|
|
XContentRepositoryEvents,
|
|
XContentGraphType,
|
|
GuidGraphType,
|
|
XContentGraphQuery,
|
|
IXContentGraphQLTypeHelper,
|
|
XContentGraphQLTypeHelper,
|
|
XContentGraphSchema,
|
|
IXContentRepository,
|
|
XContentEFRepository<TContext>,
|
|
TContext,
|
|
IXContentSeeder,
|
|
TSeederImplementation
|
|
> GetXContentEFRepositoryDescriptor<TContext, TSeederImplementation>()
|
|
where TContext : XDbContext
|
|
where TSeederImplementation : XBaseDbSeeder<XContent, Guid>
|
|
{
|
|
//
|
|
var result = new XEFRepositoryDescriptor<
|
|
XContent,
|
|
Guid,
|
|
IXContentKeyGenerator,
|
|
XContentKeyGenerator,
|
|
IXContentRepositoryEvents,
|
|
XContentRepositoryEvents,
|
|
XContentGraphType,
|
|
GuidGraphType,
|
|
XContentGraphQuery,
|
|
IXContentGraphQLTypeHelper,
|
|
XContentGraphQLTypeHelper,
|
|
XContentGraphSchema,
|
|
IXContentRepository,
|
|
XContentEFRepository<TContext>,
|
|
TContext,
|
|
IXContentSeeder,
|
|
TSeederImplementation
|
|
>();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
//
|
|
#region Mongo Repository Descriptor Provider(s) ...
|
|
public static XMongoRepositoryDescriptor<
|
|
XContent,
|
|
Guid,
|
|
IXContentKeyGenerator,
|
|
XContentKeyGenerator,
|
|
IXContentRepositoryEvents,
|
|
XContentRepositoryEvents,
|
|
XContentGraphType,
|
|
GuidGraphType,
|
|
XContentGraphQuery,
|
|
IXContentGraphQLTypeHelper,
|
|
XContentGraphQLTypeHelper,
|
|
XContentGraphSchema,
|
|
IXContentRepository,
|
|
XContentMongoRepository
|
|
> GetXContentMongoRepositoryDescriptor()
|
|
{
|
|
//
|
|
var result = new XMongoRepositoryDescriptor<
|
|
XContent,
|
|
Guid,
|
|
IXContentKeyGenerator,
|
|
XContentKeyGenerator,
|
|
IXContentRepositoryEvents,
|
|
XContentRepositoryEvents,
|
|
XContentGraphType,
|
|
GuidGraphType,
|
|
XContentGraphQuery,
|
|
IXContentGraphQLTypeHelper,
|
|
XContentGraphQLTypeHelper,
|
|
XContentGraphSchema,
|
|
IXContentRepository,
|
|
XContentMongoRepository
|
|
>();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
public static XMongoRepositoryDescriptor<
|
|
XContent,
|
|
Guid,
|
|
IXContentKeyGenerator,
|
|
XContentKeyGenerator,
|
|
IXContentRepositoryEvents,
|
|
XContentRepositoryEvents,
|
|
XContentGraphType,
|
|
GuidGraphType,
|
|
XContentGraphQuery,
|
|
IXContentGraphQLTypeHelper,
|
|
XContentGraphQLTypeHelper,
|
|
XContentGraphSchema,
|
|
IXContentRepository,
|
|
XContentMongoRepository,
|
|
IXContentSeeder,
|
|
TSeederImplementation
|
|
> GetXContentMongoRepositoryDescriptor<TSeederImplementation>()
|
|
where TSeederImplementation : XBaseDbSeeder<XContent, Guid>
|
|
{
|
|
//
|
|
var result = new XMongoRepositoryDescriptor<
|
|
XContent,
|
|
Guid,
|
|
IXContentKeyGenerator,
|
|
XContentKeyGenerator,
|
|
IXContentRepositoryEvents,
|
|
XContentRepositoryEvents,
|
|
XContentGraphType,
|
|
GuidGraphType,
|
|
XContentGraphQuery,
|
|
IXContentGraphQLTypeHelper,
|
|
XContentGraphQLTypeHelper,
|
|
XContentGraphSchema,
|
|
IXContentRepository,
|
|
XContentMongoRepository,
|
|
IXContentSeeder,
|
|
TSeederImplementation
|
|
>();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
//
|
|
#region InMemory Repository Descriptor Provider(s) ...
|
|
public static XInMemoryRepositoryDescriptor<
|
|
XContent,
|
|
Guid,
|
|
IXContentKeyGenerator,
|
|
XContentKeyGenerator,
|
|
IXContentRepositoryEvents,
|
|
XContentRepositoryEvents,
|
|
XContentGraphType,
|
|
GuidGraphType,
|
|
XContentGraphQuery,
|
|
IXContentGraphQLTypeHelper,
|
|
XContentGraphQLTypeHelper,
|
|
XContentGraphSchema,
|
|
IXContentRepository,
|
|
XContentInMemoryRepository
|
|
> GetXContentInMemoryRepositoryDescriptor()
|
|
{
|
|
//
|
|
var result = new XInMemoryRepositoryDescriptor<
|
|
XContent,
|
|
Guid,
|
|
IXContentKeyGenerator,
|
|
XContentKeyGenerator,
|
|
IXContentRepositoryEvents,
|
|
XContentRepositoryEvents,
|
|
XContentGraphType,
|
|
GuidGraphType,
|
|
XContentGraphQuery,
|
|
IXContentGraphQLTypeHelper,
|
|
XContentGraphQLTypeHelper,
|
|
XContentGraphSchema,
|
|
IXContentRepository,
|
|
XContentInMemoryRepository
|
|
>();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
public static XInMemoryRepositoryDescriptor<
|
|
XContent,
|
|
Guid,
|
|
IXContentKeyGenerator,
|
|
XContentKeyGenerator,
|
|
IXContentRepositoryEvents,
|
|
XContentRepositoryEvents,
|
|
XContentGraphType,
|
|
GuidGraphType,
|
|
XContentGraphQuery,
|
|
IXContentGraphQLTypeHelper,
|
|
XContentGraphQLTypeHelper,
|
|
XContentGraphSchema,
|
|
IXContentRepository,
|
|
XContentInMemoryRepository,
|
|
IXContentSeeder,
|
|
TSeederImplementation
|
|
> GetXContentInMemoryRepositoryDescriptor<TSeederImplementation>()
|
|
where TSeederImplementation : XBaseDbSeeder<XContent, Guid>
|
|
{
|
|
//
|
|
var result = new XInMemoryRepositoryDescriptor<
|
|
XContent,
|
|
Guid,
|
|
IXContentKeyGenerator,
|
|
XContentKeyGenerator,
|
|
IXContentRepositoryEvents,
|
|
XContentRepositoryEvents,
|
|
XContentGraphType,
|
|
GuidGraphType,
|
|
XContentGraphQuery,
|
|
IXContentGraphQLTypeHelper,
|
|
XContentGraphQLTypeHelper,
|
|
XContentGraphSchema,
|
|
IXContentRepository,
|
|
XContentInMemoryRepository,
|
|
IXContentSeeder,
|
|
TSeederImplementation
|
|
>();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
#endregion
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Interfaces\Dtos\IXContentDtoHub.cs
|
|
|
|
using System;
|
|
using xContentService.Models.Dtos;
|
|
using xContentService.Models.Entities;
|
|
using xPushService.Interfaces;
|
|
|
|
namespace xContentService.Interfaces.Dtos
|
|
{
|
|
public interface IXContentDtoHub : IXBaseDtoHub<XContent, XContentDto, Guid>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Interfaces\Dtos\IXContentRepositoryService.cs
|
|
|
|
using System;
|
|
using xContentService.Models.Dtos;
|
|
using xContentService.Models.Entities;
|
|
using xDataService.Interfaces;
|
|
|
|
namespace xContentService.Interfaces.Dtos
|
|
{
|
|
public interface IXContentRepositoryService : IXBaseRepositoryService<XContent, XContentDto, Guid>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Interfaces\Dtos\IXContentServiceProvider.cs
|
|
|
|
using System;
|
|
using xContentService.Models.Dtos;
|
|
using xContentService.Models.Entities;
|
|
using xContentService.Providers.Dtos;
|
|
using xPushService.Interfaces;
|
|
|
|
namespace xContentService.Interfaces.Dtos
|
|
{
|
|
public interface IXContentServiceProvider : IXBaseDtoProvider<XContent, XContentDto, Guid, XContentDtoHub>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Interfaces\Enrichers\IXContentEnricher.cs
|
|
|
|
namespace xContentService.Interfaces.Enrichers
|
|
{
|
|
// TODO: Complete this ...
|
|
public interface IXContentEnricher
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Interfaces\Entities\IXContentEntityHub.cs
|
|
|
|
using System;
|
|
using xContentService.Models.Entities;
|
|
using xPushService.Interfaces;
|
|
|
|
namespace xContentService.Interfaces.Entities
|
|
{
|
|
public interface IXContentEntityHub : IXBaseEntityHub<XContent, Guid>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Interfaces\Entities\IXContentGraphQLTypeHelper.cs
|
|
|
|
using System;
|
|
using xContentService.Models.Entities;
|
|
using xDataService.Interfaces;
|
|
|
|
namespace xContentService.Interfaces.Entities
|
|
{
|
|
public interface IXContentGraphQLTypeHelper : IXBaseGraphQLTypeHelper<XContent, Guid>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Interfaces\Entities\IXContentKeyGenerator.cs
|
|
|
|
using System;
|
|
using xContentService.Models.Entities;
|
|
using xDataService.Interfaces;
|
|
|
|
namespace xContentService.Interfaces.Entities
|
|
{
|
|
public interface IXContentKeyGenerator : IXKeyGenerator<XContent, Guid>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Interfaces\Entities\IXContentRepository.cs
|
|
|
|
using System;
|
|
using xContentService.Models.Entities;
|
|
using xDataService.Interfaces;
|
|
|
|
namespace xContentService.Interfaces.Entities
|
|
{
|
|
public interface IXContentRepository : IXBaseRepository<XContent, Guid>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Interfaces\Entities\IXContentRepositoryEvents.cs
|
|
|
|
using xContentService.Models.Entities;
|
|
using xDataService.Interfaces;
|
|
|
|
namespace xContentService.Interfaces.Entities
|
|
{
|
|
public interface IXContentRepositoryEvents : IXBaseRepositoryEvents<XContent>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Interfaces\Entities\IXContentRepositoryProvider.cs
|
|
|
|
using System;
|
|
using xContentService.Models.Entities;
|
|
using xContentService.Providers.Entities;
|
|
using xPushService.Interfaces;
|
|
|
|
namespace xContentService.Interfaces.Entities
|
|
{
|
|
public interface IXContentRepositoryProvider : IXBaseEntityProvider<XContent, Guid, XContentEntityHub>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Interfaces\Entities\IXContentSeeder.cs
|
|
|
|
using System;
|
|
using xContentService.Models.Entities;
|
|
using xDataService.Interfaces;
|
|
|
|
namespace xContentService.Interfaces.Entities
|
|
{
|
|
public interface IXContentSeeder : IXBaseDbSeeder<XContent, Guid>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Models\Dtos\XContentDto.cs
|
|
|
|
using System;
|
|
using xModels.Base;
|
|
using xModels.Dtos;
|
|
|
|
namespace xContentService.Models.Dtos
|
|
{
|
|
/// <summary>
|
|
/// Content Describe DTO ...
|
|
/// </summary>
|
|
public class XContentDto : XBaseGuidIDEntityDto
|
|
{
|
|
public string OwnerId { get; set; }
|
|
public virtual XPersonDto Owner { get; set; }
|
|
|
|
public string Title { get; set; }
|
|
public virtual XResourceDto TitleResource { get; set; }
|
|
|
|
public string Description { get; set; }
|
|
public virtual XResourceDto DescriptionResource { get; set; }
|
|
|
|
public DateTime CreatedOn { get; set; }
|
|
public DateTime UpdatedAt { get; set; }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Models\Entities\XContent.cs
|
|
|
|
using System;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using xModels.Base;
|
|
|
|
namespace xContentService.Models.Entities
|
|
{
|
|
/// <summary>
|
|
/// Content Describe ...
|
|
/// </summary>
|
|
public class XContent : XBaseGuidIDEntity
|
|
{
|
|
/// <summary>
|
|
/// User Identifier ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
[Required]
|
|
[StringLength(255)]
|
|
public string OwnerId { get; set; }
|
|
|
|
/// <summary>
|
|
/// Title of Content ...
|
|
/// </summary>
|
|
[Required]
|
|
[StringLength(255)]
|
|
public string Title { get; set; }
|
|
|
|
/// <summary>
|
|
/// Description of Content ...
|
|
/// </summary>
|
|
[StringLength(255)]
|
|
public string Description { get; set; }
|
|
|
|
/// <summary>
|
|
/// Created Time ...
|
|
/// </summary>
|
|
public DateTime CreatedOn { get; set; }
|
|
|
|
/// <summary>
|
|
/// Updated Time ...
|
|
/// </summary>
|
|
public DateTime UpdatedAt { get; set; }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\XContentEntityRegisterar.cs
|
|
|
|
using System;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using xContentService.Configuration.Entities;
|
|
using xContentService.Models.Entities;
|
|
using xDataService.Interfaces;
|
|
using xDataService.Providers;
|
|
|
|
namespace xContentService.Providers
|
|
{
|
|
public class XContentEntityRegisterar : XBaseEntityRegisterar, IXEntityRegisterar
|
|
{
|
|
public XContentEntityRegisterar()
|
|
: base(nameof(XContentEntityRegisterar))
|
|
{
|
|
//
|
|
// Add Entity ...
|
|
AddEntity<XContent, Guid>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Configure Entities ...
|
|
/// </summary>
|
|
/// <param name="modelBuilder"></param>
|
|
public override void ConfigureEntities(ModelBuilder modelBuilder)
|
|
{
|
|
//
|
|
// Configure Entity Using Provided ...
|
|
modelBuilder
|
|
.ApplyConfigurationsFromAssembly(typeof(XContentEntityConfiguration).Assembly);
|
|
|
|
//
|
|
base.ConfigureEntities(modelBuilder);
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\Dtos\XContentDtoHub.cs
|
|
|
|
using System;
|
|
using Microsoft.Extensions.Logging;
|
|
using xContentService.Interfaces.Dtos;
|
|
using xContentService.Models.Dtos;
|
|
using xContentService.Models.Entities;
|
|
using xPushService.Base;
|
|
|
|
namespace xContentService.Providers.Dtos
|
|
{
|
|
public class XContentDtoHub : XBaseDtoHub<XContent, XContentDto, Guid>, IXContentDtoHub
|
|
{
|
|
public XContentDtoHub(
|
|
ILogger<XContentDtoHub> logger
|
|
) : base(logger)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\Dtos\XContentRepositoryService.cs
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using AutoMapper;
|
|
using xContentService.Interfaces.Dtos;
|
|
using xContentService.Interfaces.Entities;
|
|
using xContentService.Models.Dtos;
|
|
using xContentService.Models.Entities;
|
|
using xDataService.Providers;
|
|
|
|
namespace xContentService.Providers.Dtos
|
|
{
|
|
public class XContentRepositoryService : XBaseRepositoryService<XContent, XContentDto, Guid>, IXContentRepositoryService
|
|
{
|
|
public XContentRepositoryService(
|
|
IXContentRepository repository,
|
|
IEnumerable<Profile> mapperProfiles = null
|
|
) : base(
|
|
repository,
|
|
mapperProfiles
|
|
)
|
|
{ }
|
|
|
|
//
|
|
// TODO: Implement Enrichers ...
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\Dtos\XContentServiceProvider.cs
|
|
|
|
using System;
|
|
using Microsoft.AspNetCore.SignalR;
|
|
using xContentService.Interfaces.Dtos;
|
|
using xContentService.Models.Dtos;
|
|
using xContentService.Models.Entities;
|
|
using xDataService.Configuration;
|
|
using xIdentityService.Interfaces;
|
|
using xPushService.Base;
|
|
|
|
namespace xContentService.Providers.Dtos
|
|
{
|
|
public class XContentServiceProvider : XBaseDtoProvider<XContent, XContentDto, Guid, XContentDtoHub>, IXContentServiceProvider
|
|
{
|
|
public XContentServiceProvider(
|
|
IHubContext<XContentDtoHub> hub,
|
|
XDataServiceConfiguration dataConfiguration,
|
|
IXContentRepositoryService service,
|
|
IXIdentityProvider identityProvider = null
|
|
) : base(
|
|
hub,
|
|
dataConfiguration,
|
|
service,
|
|
identityProvider
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\Enrichers\XContentEnricher.cs
|
|
|
|
using xContentService.Interfaces.Enrichers;
|
|
|
|
namespace xContentService.Providers.Enrichers
|
|
{
|
|
public class XContentEnricher : IXContentEnricher
|
|
{
|
|
//
|
|
// TODO: Complete this ...
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\Entities\XContentEFRepository.cs
|
|
|
|
using System;
|
|
using xContentService.Interfaces.Entities;
|
|
using xContentService.Models.Entities;
|
|
using xDataService.Configuration;
|
|
using xDataService.Db;
|
|
using xDataService.Interfaces;
|
|
using xDataService.Providers;
|
|
|
|
namespace xContentService.Providers.Entities
|
|
{
|
|
public class XContentEFRepository<TContext> : XBaseEFRepository<XContent, Guid, TContext>, IXContentRepository
|
|
where TContext : XDbContext
|
|
{
|
|
public XContentEFRepository(
|
|
IXUnitOfWorks<TContext> unitOfWorks,
|
|
XDataServiceConfiguration configuration,
|
|
IXContentKeyGenerator keyGenerator = null,
|
|
IXContentRepositoryEvents baseRepositoryEvents = null
|
|
) : base(
|
|
unitOfWorks,
|
|
configuration,
|
|
keyGenerator,
|
|
baseRepositoryEvents
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\Entities\XContentEntityHub.cs
|
|
|
|
using System;
|
|
using Microsoft.Extensions.Logging;
|
|
using xContentService.Interfaces.Entities;
|
|
using xContentService.Models.Entities;
|
|
using xPushService.Base;
|
|
|
|
namespace xContentService.Providers.Entities
|
|
{
|
|
public class XContentEntityHub : XBaseEntityHub<XContent, Guid>, IXContentEntityHub
|
|
{
|
|
public XContentEntityHub(
|
|
ILogger<XContentEntityHub> logger
|
|
) : base(logger)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\Entities\XContentInMemoryRepository.cs
|
|
|
|
using System;
|
|
using xContentService.Interfaces.Entities;
|
|
using xContentService.Models.Entities;
|
|
using xDataService.Configuration;
|
|
using xDataService.Providers;
|
|
|
|
namespace xContentService.Providers.Entities
|
|
{
|
|
public class XContentInMemoryRepository : XBaseInMemoryRepository<XContent, Guid>, IXContentRepository
|
|
{
|
|
public XContentInMemoryRepository(
|
|
XDataServiceConfiguration configuration,
|
|
IXContentKeyGenerator keyGenerator = null,
|
|
IXContentRepositoryEvents baseRepositoryEvents = null
|
|
) : base(
|
|
configuration,
|
|
keyGenerator,
|
|
baseRepositoryEvents
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\Entities\XContentKeyGenerator.cs
|
|
|
|
using xContentService.Interfaces.Entities;
|
|
using xContentService.Models.Entities;
|
|
using xDataService.Providers;
|
|
|
|
namespace xContentService.Providers.Entities
|
|
{
|
|
public class XContentKeyGenerator : XGuidKeyGenerator<XContent>, IXContentKeyGenerator
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\Entities\XContentMongoRepository.cs
|
|
|
|
using System;
|
|
using xContentService.Interfaces.Entities;
|
|
using xContentService.Models.Entities;
|
|
using xDataService.Configuration;
|
|
using xDataService.Providers;
|
|
|
|
namespace xContentService.Providers.Entities
|
|
{
|
|
public class XContentMongoRepository : XBaseMongoRepository<XContent, Guid>, IXContentRepository
|
|
{
|
|
public XContentMongoRepository(
|
|
XDataBaseConfiguration dbConfiguration,
|
|
XDataServiceConfiguration configuration,
|
|
string collectionName = null,
|
|
IXContentKeyGenerator keyGenerator = null,
|
|
IXContentRepositoryEvents baseRepositoryEvents = null
|
|
) : base(
|
|
dbConfiguration,
|
|
configuration,
|
|
collectionName,
|
|
keyGenerator,
|
|
baseRepositoryEvents
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\Entities\XContentRepositoryEvents.cs
|
|
|
|
using xContentService.Interfaces.Entities;
|
|
using xContentService.Models.Entities;
|
|
using xDataService.Providers;
|
|
|
|
namespace xContentService.Providers.Entities
|
|
{
|
|
public class XContentRepositoryEvents : XBaseRepositoryEvents<XContent>, IXContentRepositoryEvents
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\Entities\XContentRepositoryProvider.cs
|
|
|
|
using System;
|
|
using Microsoft.AspNetCore.SignalR;
|
|
using xContentService.Interfaces.Entities;
|
|
using xContentService.Models.Entities;
|
|
using xDataService.Configuration;
|
|
using xIdentityService.Interfaces;
|
|
using xPushService.Base;
|
|
|
|
namespace xContentService.Providers.Entities
|
|
{
|
|
public class XContentRepositoryProvider : XBaseEntityProvider<XContent, Guid, XContentEntityHub>, IXContentRepositoryProvider
|
|
{
|
|
public XContentRepositoryProvider(
|
|
IHubContext<XContentEntityHub> hub,
|
|
IXContentRepository repository,
|
|
XDataServiceConfiguration dataConfiguration,
|
|
IXIdentityProvider identityProvider = null
|
|
) : base(
|
|
hub,
|
|
repository,
|
|
dataConfiguration,
|
|
identityProvider
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\Entities\XContentSeederBase.cs
|
|
|
|
using System;
|
|
using xContentService.Interfaces.Entities;
|
|
using xContentService.Models.Entities;
|
|
using xDataService.Configuration;
|
|
using xDataService.Providers;
|
|
|
|
namespace xContentService.Providers.Entities
|
|
{
|
|
public abstract class XContentSeederBase : XBaseDbSeeder<XContent, Guid>, IXContentSeeder
|
|
{
|
|
protected XContentSeederBase(
|
|
string entity,
|
|
string database,
|
|
IXContentRepository repository,
|
|
XDataServiceConfiguration dataServiceConfiguration
|
|
) : base(
|
|
entity,
|
|
database,
|
|
repository,
|
|
dataServiceConfiguration
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\GraphQL\XContentGraphQLTypeHelper.cs
|
|
|
|
using System;
|
|
using xContentService.Constants;
|
|
using xContentService.Interfaces.Entities;
|
|
using xContentService.Models.Entities;
|
|
using xDataService.GraphQL;
|
|
|
|
namespace xContentService.Providers.GraphQL
|
|
{
|
|
public class XContentGraphQLTypeHelper : XBaseGraphQLTypeHelper<XContent, Guid>, IXContentGraphQLTypeHelper
|
|
{
|
|
public override string GetInQueryCollectionName()
|
|
{
|
|
return XContentServiceConstants.XContentCollectionName;
|
|
}
|
|
|
|
public override string GetInQuerySingleName()
|
|
{
|
|
return XContentServiceConstants.XContentSingleName;
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\GraphQL\XContentGraphQuery.cs
|
|
|
|
using System;
|
|
using GraphQL.Types;
|
|
using xContentService.Interfaces.Entities;
|
|
using xContentService.Models.Entities;
|
|
using xDataService.Configuration;
|
|
using xDataService.GraphQL;
|
|
|
|
namespace xContentService.Providers.GraphQL
|
|
{
|
|
public class XContentGraphQuery : XBaseGraphQLQuery<XContent, Guid, XContentGraphType, GuidGraphType>
|
|
{
|
|
public XContentGraphQuery(
|
|
XDataServiceConfiguration configuration,
|
|
IXContentRepository repository,
|
|
IXContentGraphQLTypeHelper helper
|
|
) : base(
|
|
configuration,
|
|
repository,
|
|
helper
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\GraphQL\XContentGraphSchema.cs
|
|
|
|
using System;
|
|
using GraphQL.Types;
|
|
|
|
namespace xContentService.Providers.GraphQL
|
|
{
|
|
public class XContentGraphSchema : Schema
|
|
{
|
|
public XContentGraphSchema(IServiceProvider services) : base(services)
|
|
{
|
|
Query = (XContentGraphQuery)services.GetService(typeof(XContentGraphQuery));
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\GraphQL\XContentGraphType.cs
|
|
|
|
using System;
|
|
using xContentService.Models.Entities;
|
|
using xDataService.GraphQL;
|
|
|
|
namespace xContentService.Providers.GraphQL
|
|
{
|
|
public class XContentGraphType : XBaseGraphObjectType<XContent, Guid>
|
|
{
|
|
public XContentGraphType() : base()
|
|
{
|
|
Field(x => x.Title);
|
|
Field(x => x.OwnerId);
|
|
Field(x => x.CreatedOn);
|
|
Field(x => x.UpdatedAt);
|
|
Field(x => x.Description);
|
|
}
|
|
}
|
|
}
|