Remove Auto-Injection

this should be handled by #520
This commit is contained in:
Christopher F
2017-02-11 13:38:26 -05:00
parent b9b6ac36fe
commit 40ede62e4d
2 changed files with 0 additions and 30 deletions

View File

@@ -1,15 +0,0 @@
using System;
namespace Discord.Commands
{
/// <summary>
/// Indicates that this property should be filled in by dependency injection.
/// </summary>
/// <remarks>
/// This property **MUST** have a setter.
/// </remarks>
[AttributeUsage(AttributeTargets.Property)]
public sealed class InjectAttribute : Attribute
{
}
}

View File

@@ -43,21 +43,6 @@ namespace Discord.Commands
try
{
T instance = (T)constructor.Invoke(args);
var fields = instance.GetType().GetRuntimeProperties().Where(p => p.GetCustomAttribute<InjectAttribute>() != null).Where(p => p.CanWrite);
foreach (var field in fields)
{
object arg;
if (map == null || !map.TryGet(field.PropertyType, out arg))
{
if (field.PropertyType == typeof(CommandService))
arg = service;
else if (field.PropertyType == typeof(IDependencyMap))
arg = map;
else
throw new InvalidOperationException($"Failed to inject \"{typeInfo.FullName}\", dependency \"{field.PropertyType.FullName}\" was not found.");
}
field.SetValue(instance, arg);
}
return instance;
}
catch (Exception ex)