Add InjectAttribute for annotating injectable properties

This commit is contained in:
james7132
2017-02-10 21:52:33 +00:00
parent a551064eaf
commit f0b4c24e82
2 changed files with 12 additions and 1 deletions

View File

@@ -0,0 +1,9 @@
using System;
namespace Discord.Commands {
[AttributeUsage(AttributeTargets.Property)]
public class InjectAttribute : Attribute {
}
}

View File

@@ -19,7 +19,9 @@ namespace Discord.Commands
var constructor = constructors[0];
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) =>
{