public IEnumerable <MethodInfo> ResolveMethods(Type type)
        {
            if (type is null)
            {
                throw new ArgumentNullException(nameof(type));
            }

            var resolver = _attributeResolverFactory.CreateAttributeResolver();

            var interfaceType = typeof(ISubscription <>);
            var interfaces    = from i in type.GetInterfaces()
                                where i.Name == interfaceType.Name
                                select i;

            foreach (var i in interfaces)
            {
                foreach (var iMethod in i.GetMethods(BindingFlags.Public | BindingFlags.Instance))
                {
                    foreach (var cMethod in type.GetMethods(BindingFlags.Public | BindingFlags.Instance))
                    {
                        if (iMethod.ToString().Equals(cMethod.ToString(), StringComparison.CurrentCulture))
                        {
                            var attribute = resolver.Invoke(cMethod);
                            if (!(attribute is null))
                            {
                                yield return(cMethod);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        public IEnumerable <Type> ResolveTypes(Assembly assembly)
        {
            if (assembly is null)
            {
                throw new ArgumentNullException(nameof(assembly));
            }

            var resolver = _attributeResolverFactory.CreateAttributeResolver();

            foreach (var type in assembly.GetTypes())
            {
                var attribute = resolver.Invoke(type);
                if (!(attribute is null))
                {
                    yield return(type);
                }
            }
        }