private void Unsubscribe(IComponentIntern component) { foreach (var type in GetComponentHandledMessageTypes(component)) { _messageHandlers.Remove(type, component); } }
private IEnumerable <Type> GetComponentHandledMessageTypes(IComponentIntern component) { foreach (var iface in component.GetType().GetInterfaces()) { if (iface.IsConstructedGenericType) { var genface = iface.GetGenericTypeDefinition(); if (genface == typeof(IHandle <>) || genface == typeof(IHandle <,>)) { yield return(iface.GetGenericArguments()[0]); } } } }