mirror of https://github.com/abpframework/abp.git
csharpabpc-sharpframeworkblazoraspnet-coredotnet-coreaspnetcorearchitecturesaasdomain-driven-designangularmulti-tenancy
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
827 B
32 lines
827 B
using System;
|
|
using System.Linq;
|
|
using JetBrains.Annotations;
|
|
|
|
namespace Volo.Abp.BackgroundJobs;
|
|
|
|
public class BackgroundJobNameAttribute : Attribute, IBackgroundJobNameProvider
|
|
{
|
|
public string Name { get; }
|
|
|
|
public BackgroundJobNameAttribute([NotNull] string name)
|
|
{
|
|
Name = Check.NotNullOrWhiteSpace(name, nameof(name));
|
|
}
|
|
|
|
public static string GetName<TJobArgs>()
|
|
{
|
|
return GetName(typeof(TJobArgs));
|
|
}
|
|
|
|
public static string GetName([NotNull] Type jobArgsType)
|
|
{
|
|
Check.NotNull(jobArgsType, nameof(jobArgsType));
|
|
|
|
return (jobArgsType
|
|
.GetCustomAttributes(true)
|
|
.OfType<IBackgroundJobNameProvider>()
|
|
.FirstOrDefault()
|
|
?.Name
|
|
?? jobArgsType.FullName)!;
|
|
}
|
|
}
|
|
|