refactor and add using constants instead of hard coded strings ...

This commit is contained in:
2026-07-30 14:24:35 +03:30
parent b582b5c73a
commit c4a60f655d
10 changed files with 61 additions and 22 deletions
@@ -2,6 +2,7 @@ using System;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.Metadata.Builders;
using xDataService.Providers; using xDataService.Providers;
using xWebinarService.Constants;
using xWebinarService.Models.Entities; using xWebinarService.Models.Entities;
namespace xWebinarService.Configurations.Entities namespace xWebinarService.Configurations.Entities
@@ -10,7 +11,7 @@ namespace xWebinarService.Configurations.Entities
{ {
public override void Configure(EntityTypeBuilder<XWebinar> builder) public override void Configure(EntityTypeBuilder<XWebinar> builder)
{ {
builder.ToTable("Webinars"); builder.ToTable(XWebinarServiceConstants.XWebinarTable);
} }
} }
} }
@@ -1,6 +1,7 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.Metadata.Builders;
using xDataService.Providers; using xDataService.Providers;
using xWebinarService.Constants;
using xWebinarService.Models.Entities; using xWebinarService.Models.Entities;
namespace xWebinarService.Configurations.Entities namespace xWebinarService.Configurations.Entities
@@ -9,7 +10,7 @@ namespace xWebinarService.Configurations.Entities
{ {
public override void Configure(EntityTypeBuilder<XWebinarSubscriber> builder) public override void Configure(EntityTypeBuilder<XWebinarSubscriber> builder)
{ {
builder.ToTable("WebinarSubscribers"); builder.ToTable(XWebinarServiceConstants.XWebinarSubscriberTable);
} }
} }
} }
+37
View File
@@ -0,0 +1,37 @@
namespace xWebinarService.Constants
{
public struct XWebinarServiceConstants
{
//
// Service Extensions Log Tag ...
public const string XWebinarServiceDILogTag = "XWebinarService";
//
// Table Mapping Identifiers ...
public const string XWebinarTable = "Webinars";
public const string XWebinarSubscriberTable = "WebinarSubscribers";
//
// GraphQL Collection Mappings ...
public const string XWebinarSingleName = "webinar";
public const string XWebinarCollectionName = "webinars";
public const string XWebinarSubscriberSingleName = "webinarSubscriber";
public const string XWebinarSubscriberCollectionName = "webinarSubscribers";
//
// Hubs ...
public const string XWebinarDtoHub = "webinarDto";
public const string XWebinarEntityHub = "webinarEntity";
public const string XWebinarSubscriberDtoHub = "webinarSubscriberDto";
public const string XWebinarSubscriberEntityHub = "webinarSubscriberEntity";
//
// Custome Constants ...
//
// EF Repositories Helper Extensions ...
public const string GetXWebinarEFRepositoryDescriptor = "GetXWebinarEFRepositoryDescriptor";
public const string GetXWebinarSubscriberEFRepositoryDescriptor = "GetXWebinarSubscriberEFRepositoryDescriptor";
}
}
+10 -9
View File
@@ -10,6 +10,7 @@ using xDataService.Models;
using xExceptions.Constants; using xExceptions.Constants;
using xPushService.DI; using xPushService.DI;
using xPushService.Helpers; using xPushService.Helpers;
using xWebinarService.Constants;
using xWebinarService.Helpers; using xWebinarService.Helpers;
using xWebinarService.Interfaces.Dtos; using xWebinarService.Interfaces.Dtos;
using xWebinarService.Interfaces.Entities; using xWebinarService.Interfaces.Entities;
@@ -78,12 +79,12 @@ namespace xWebinarService.DI
var pushHelper = new XPushServiceHelper(); var pushHelper = new XPushServiceHelper();
// //
pushHelper.AddHub<XWebinarDtoHub>("webinarDto"); pushHelper.AddHub<XWebinarDtoHub>(XWebinarServiceConstants.XWebinarDtoHub);
pushHelper.AddHub<XWebinarEntityHub>("webinarEntity"); pushHelper.AddHub<XWebinarEntityHub>(XWebinarServiceConstants.XWebinarEntityHub);
// //
pushHelper.AddHub<XWebinarSubscriberDtoHub>("webinarSubscriberDto"); pushHelper.AddHub<XWebinarSubscriberDtoHub>(XWebinarServiceConstants.XWebinarSubscriberDtoHub);
pushHelper.AddHub<XWebinarSubscriberEntityHub>("webinarSubscriberEntity"); pushHelper.AddHub<XWebinarSubscriberEntityHub>(XWebinarServiceConstants.XWebinarSubscriberEntityHub);
// //
app.UseXPushService(pushHelper); app.UseXPushService(pushHelper);
@@ -120,7 +121,7 @@ namespace xWebinarService.DI
/// <summary> /// <summary>
/// a LogTag for Service ... /// a LogTag for Service ...
/// </summary> /// </summary>
private static string XLogTag = "XWebinarService"; private static string XLogTag = XWebinarServiceConstants.XWebinarServiceDILogTag;
/// <summary> /// <summary>
/// print a log in Console ... /// print a log in Console ...
@@ -193,17 +194,17 @@ namespace xWebinarService.DI
// //
webinarDescriptor = typeof(XWebinarServiceHelper) webinarDescriptor = typeof(XWebinarServiceHelper)
.InvokeGenericMethod<XRepositoryDescriptor>( .InvokeGenericMethod<XRepositoryDescriptor>(
methodName: "GetXWebinarEFRepositoryDescriptor", args: null,
runtimeType: contextType, runtimeType: contextType,
args: null methodName: XWebinarServiceConstants.GetXWebinarEFRepositoryDescriptor
); );
// //
webinarSubscriberDescriptor = typeof(XWebinarServiceHelper) webinarSubscriberDescriptor = typeof(XWebinarServiceHelper)
.InvokeGenericMethod<XRepositoryDescriptor>( .InvokeGenericMethod<XRepositoryDescriptor>(
methodName: "GetXWebinarSubscriberEFRepositoryDescriptor", args: null,
runtimeType: contextType, runtimeType: contextType,
args: null methodName: XWebinarServiceConstants.GetXWebinarSubscriberEFRepositoryDescriptor
); );
break; break;
@@ -2,7 +2,7 @@ using System;
using xDataService.Interfaces; using xDataService.Interfaces;
using xWebinarService.Models.Entities; using xWebinarService.Models.Entities;
namespace xWebinarService.Interfaces namespace xWebinarService.Interfaces.Entities
{ {
public interface IXWebinarSeeder : IXBaseDbSeeder<XWebinar, Guid> public interface IXWebinarSeeder : IXBaseDbSeeder<XWebinar, Guid>
{ } { }
@@ -1,7 +1,7 @@
using xDataService.Interfaces; using xDataService.Interfaces;
using xWebinarService.Models.Entities; using xWebinarService.Models.Entities;
namespace xWebinarService.Interfaces namespace xWebinarService.Interfaces.Entities
{ {
public interface IXWebinarSubscriberSeeder : IXBaseDbSeeder<XWebinarSubscriber, int> public interface IXWebinarSubscriberSeeder : IXBaseDbSeeder<XWebinarSubscriber, int>
{ } { }
@@ -1,11 +1,10 @@
using System; using System;
using xDataService.Configuration; using xDataService.Configuration;
using xDataService.Providers; using xDataService.Providers;
using xWebinarService.Interfaces;
using xWebinarService.Interfaces.Entities; using xWebinarService.Interfaces.Entities;
using xWebinarService.Models.Entities; using xWebinarService.Models.Entities;
namespace xWebinarService.Providers namespace xWebinarService.Providers.Entities
{ {
public abstract class XWebinarSeederBase : XBaseDbSeeder<XWebinar, Guid>, IXWebinarSeeder public abstract class XWebinarSeederBase : XBaseDbSeeder<XWebinar, Guid>, IXWebinarSeeder
{ {
@@ -1,11 +1,9 @@
using System;
using xDataService.Configuration; using xDataService.Configuration;
using xDataService.Providers; using xDataService.Providers;
using xWebinarService.Interfaces;
using xWebinarService.Interfaces.Entities; using xWebinarService.Interfaces.Entities;
using xWebinarService.Models.Entities; using xWebinarService.Models.Entities;
namespace xWebinarService.Providers namespace xWebinarService.Providers.Entities
{ {
public abstract class XWebinarSubscriberSeederBase : XBaseDbSeeder<XWebinarSubscriber, int>, IXWebinarSubscriberSeeder public abstract class XWebinarSubscriberSeederBase : XBaseDbSeeder<XWebinarSubscriber, int>, IXWebinarSubscriberSeeder
{ {
@@ -1,6 +1,7 @@
using System; using System;
using xDataService.Configuration; using xDataService.Configuration;
using xDataService.GraphQL; using xDataService.GraphQL;
using xWebinarService.Constants;
using xWebinarService.Interfaces.Entities; using xWebinarService.Interfaces.Entities;
using xWebinarService.Models.Entities; using xWebinarService.Models.Entities;
@@ -15,12 +16,12 @@ namespace xWebinarService.Providers.GraphQL
public override string GetInQueryCollectionName() public override string GetInQueryCollectionName()
{ {
return "webinars"; return XWebinarServiceConstants.XWebinarCollectionName;
} }
public override string GetInQuerySingleName() public override string GetInQuerySingleName()
{ {
return "webinar"; return XWebinarServiceConstants.XWebinarSingleName;
} }
} }
} }
@@ -1,6 +1,7 @@
using System; using System;
using xDataService.Configuration; using xDataService.Configuration;
using xDataService.GraphQL; using xDataService.GraphQL;
using xWebinarService.Constants;
using xWebinarService.Interfaces.Entities; using xWebinarService.Interfaces.Entities;
using xWebinarService.Models.Entities; using xWebinarService.Models.Entities;
@@ -15,12 +16,12 @@ namespace xWebinarService.Providers.GraphQL
public override string GetInQueryCollectionName() public override string GetInQueryCollectionName()
{ {
return "webinarSubscribers"; return XWebinarServiceConstants.XWebinarSubscriberCollectionName;
} }
public override string GetInQuerySingleName() public override string GetInQuerySingleName()
{ {
return "webinarSubscriber"; return XWebinarServiceConstants.XWebinarSubscriberSingleName;
} }
} }
} }