Browse Source

Add InjectAttribute for annotating injectable properties

tags/1.0-rc
james7132 8 years ago
parent
commit
f0b4c24e82
2 changed files with 12 additions and 1 deletions
  1. +9
    -0
      src/Discord.Net.Commands/Attributes/InjectAttribute.cs
  2. +3
    -1
      src/Discord.Net.Commands/Utilities/ReflectionUtils.cs

+ 9
- 0
src/Discord.Net.Commands/Attributes/InjectAttribute.cs View File

@@ -0,0 +1,9 @@
using System;

namespace Discord.Commands {

[AttributeUsage(AttributeTargets.Property)]
public class InjectAttribute : Attribute {
}

}

+ 3
- 1
src/Discord.Net.Commands/Utilities/ReflectionUtils.cs 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) =>
{


Loading…
Cancel
Save