Example #1
0
        private string FindInterfaceGenericTypeArguments(IHasMediatorKey key, int compareTo = 1, Func <Type[], string> converter = null)
        {
            var interfaces   = key.GetType().GetInterfaces();
            var allAvailable = interfaces.Select(x => x.GetGenericArguments());

            var types = allAvailable.FirstOrDefault(x =>
            {
                return(x.Length == compareTo);
            });

            if (converter == null)
            {
                converter = t => t.First().Name;
            }

            return(types == null ? null : converter(types));
        }