I have an interface like so
public interface INetworkPacketEventHandler
{
int Id { get; }
Task HandleAsync(INetworkClient client, INetworkPacketReader reader);
}
I want to get a Dictionary<short, Type>
so I can later know which handler to create from the identifier.
I have this, but it always returns an empty IEnumerable
var types =
from type in Assembly.GetExecutingAssembly().GetTypes()
where type.IsDefined(typeof(INetworkPacketEventHandler), true)
select new KeyValuePair<short, Type>((short)type.GetProperty("Id").GetValue(type), type);
New contributor
sam korbin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.