using OneLove.Core.ExtendedEnum;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace OneLove.Core.ExtendedAttribute
{
public class SchedulingAttribute : Attribute
{
private string Url;
private HttpMethods Method;
private string Description;
public SchedulingAttribute(string url, HttpMethods method, string description = null)
{
Url = url;
Method = method;
Description = description;
}
public List<SchedulinEntity> GetSchedulingAttributeList()
{
System.Reflection.Assembly asm = System.Reflection.Assembly.GetAssembly(typeof(SchedulingAttribute));
System.Type[] types = asm.GetExportedTypes();
List<SchedulinEntity> list = new List<SchedulinEntity>();
foreach (Type type in types)
{
var attrs = type.GetCustomAttributes<SchedulingAttribute>();
foreach (var attr in attrs)
{
if (attr is SchedulingAttribute)
{
list.Add(new SchedulinEntity()
{
Description = attr.Description,
Method = attr.Method,
Url = attr.Url,
ApiClassName = type.Name
});
}
}
}
return list;
}
}
public class SchedulinEntity
{
public string Url { get; set; }
public HttpMethods Method { get; set; }
public string Description { get; set; }
public string ApiClassName { get; set; }
}
}