Preparing xPushService ...
This commit is contained in:
+31
-16
@@ -14,6 +14,7 @@ using xExceptions.Constants;
|
||||
using xPushService.Configurations;
|
||||
using xPushService.Constants;
|
||||
using xPushService.Helpers;
|
||||
using xPushService.Interfaces;
|
||||
using xPushService.Providers;
|
||||
|
||||
namespace xPushService.DI
|
||||
@@ -160,25 +161,35 @@ namespace xPushService.DI
|
||||
//
|
||||
var hubRoute = config.BaseRoute + "/" + hubDescriptor.Route;
|
||||
hubRoutes.Add(hubRoute);
|
||||
Console.WriteLine($"XPushService HubRoute: {hubRoute}");
|
||||
|
||||
//
|
||||
Type routesType = routes.GetType();
|
||||
MethodInfo mapHubMethod = routesType
|
||||
.GetMethods()
|
||||
.SingleOrDefault(m =>
|
||||
m.Name == "MapHub" &&
|
||||
m.GetParameters().Length == 1
|
||||
);
|
||||
if (mapHubMethod.IsNull())
|
||||
try
|
||||
{
|
||||
throw XException.ActionFailed.ToException();
|
||||
}
|
||||
//
|
||||
Type routesType = routes.GetType();
|
||||
MethodInfo mapHubMethod = routesType
|
||||
.GetMethods()
|
||||
.SingleOrDefault(m =>
|
||||
m.Name == "MapHub" &&
|
||||
m.GetParameters().Length == 1
|
||||
);
|
||||
if (mapHubMethod.IsNull())
|
||||
{
|
||||
throw XException.ActionFailed.ToException();
|
||||
}
|
||||
|
||||
//
|
||||
object[] genericMapHubMethodArgs = { new PathString(hubRoute) };
|
||||
MethodInfo genericMapHubMethod = mapHubMethod.MakeGenericMethod(hubDescriptor.Hub);
|
||||
genericMapHubMethod.Invoke(routes, genericMapHubMethodArgs);
|
||||
//
|
||||
object[] genericMapHubMethodArgs = { new PathString(hubRoute) };
|
||||
MethodInfo genericMapHubMethod = mapHubMethod.MakeGenericMethod(hubDescriptor.Hub);
|
||||
genericMapHubMethod.Invoke(routes, genericMapHubMethodArgs);
|
||||
|
||||
//
|
||||
Log($"Register {hubDescriptor.Hub} Hub: {hubRoute}");
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -250,7 +261,7 @@ namespace xPushService.DI
|
||||
|
||||
//
|
||||
// Register XPushService Configuration ...
|
||||
services.AddSingleton<XPushServiceConfiguration>(config);
|
||||
services.AddSingleton(config);
|
||||
|
||||
//
|
||||
// Register SignalR ...
|
||||
@@ -267,6 +278,10 @@ namespace xPushService.DI
|
||||
x.PayloadSerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
|
||||
x.PayloadSerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
|
||||
});
|
||||
|
||||
//
|
||||
// Register HubContext Factory ...
|
||||
services.AddSingleton<IXHubContextFactory, XHubContextFactory>();
|
||||
|
||||
//
|
||||
// Register XPushServiceUserNameProvider ...
|
||||
|
||||
Reference in New Issue
Block a user