Add InjectAttribute for annotating injectable properties
This commit is contained in:
9
src/Discord.Net.Commands/Attributes/InjectAttribute.cs
Normal file
9
src/Discord.Net.Commands/Attributes/InjectAttribute.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Discord.Commands {
|
||||||
|
|
||||||
|
[AttributeUsage(AttributeTargets.Property)]
|
||||||
|
public class InjectAttribute : Attribute {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -19,7 +19,9 @@ namespace Discord.Commands
|
|||||||
|
|
||||||
var constructor = constructors[0];
|
var constructor = constructors[0];
|
||||||
System.Reflection.ParameterInfo[] parameters = constructor.GetParameters();
|
System.Reflection.ParameterInfo[] parameters = constructor.GetParameters();
|
||||||
System.Reflection.PropertyInfo[] properties = typeInfo.DeclaredProperties.Where(p => p.CanWrite).ToArray();
|
System.Reflection.PropertyInfo[] properties = typeInfo.DeclaredProperties
|
||||||
|
.Where(p => p.CanWrite && p.GetCustomAttribute<InjectAttribute>() != null)
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
return (map) =>
|
return (map) =>
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user