mirror of https://github.com/abpframework/abp.git
11 changed files with 94 additions and 51 deletions
@ -0,0 +1,33 @@ |
|||
using System; |
|||
|
|||
namespace Volo.Abp.BackgroundJobs |
|||
{ |
|||
internal static class BackgroundJobHelper |
|||
{ |
|||
public static Type GetJobArgsType(Type jobType) |
|||
{ |
|||
foreach (var @interface in jobType.GetInterfaces()) |
|||
{ |
|||
if (!@interface.IsGenericType) |
|||
{ |
|||
continue; |
|||
} |
|||
|
|||
if (@interface.GetGenericTypeDefinition() != typeof(IBackgroundJob<>)) |
|||
{ |
|||
continue; |
|||
} |
|||
|
|||
var genericArgs = @interface.GetGenericArguments(); |
|||
if (genericArgs.Length != 1) |
|||
{ |
|||
continue; |
|||
} |
|||
|
|||
return genericArgs[0]; |
|||
} |
|||
|
|||
throw new AbpException($"Could not find type of the job args. Ensure that given type implements the {typeof(IBackgroundJob<>).AssemblyQualifiedName} interface. Given job type: {jobType.AssemblyQualifiedName}"); |
|||
} |
|||
} |
|||
} |
|||
@ -1,21 +1,18 @@ |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.Autofac; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Volo.Abp.BackgroundJobs |
|||
{ |
|||
[DependsOn( |
|||
typeof(AbpBackgroundJobsModule) |
|||
typeof(AbpBackgroundJobsModule), |
|||
typeof(AbpAutofacModule), |
|||
typeof(AbpTestBaseModule) |
|||
)] |
|||
public class AbpBackgroundJobsTestModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
//TODO: Can we automatically register these!
|
|||
context.Services.Configure<BackgroundJobOptions>(options => |
|||
{ |
|||
options.JobTypes[MyJobArgs.Name] = typeof(MyJob); |
|||
}); |
|||
|
|||
context.Services.AddAssemblyOf<AbpBackgroundJobsTestModule>(); |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,7 @@ |
|||
namespace Volo.Abp.Reflection |
|||
{ |
|||
public class ReflectionHelper_Tests |
|||
{ |
|||
//TODO: ...
|
|||
} |
|||
} |
|||
Loading…
Reference in new issue