コード例 #1
0
        public IBeanDefinitionCollection ScanAssembly(Assembly asm, params string[] baseNamespaces)
        {
            var regexes    = BuildBaseNamespacesRegexes(baseNamespaces);
            var beanDefCol = new BeanDefinitionCollection();

            beanDefCol.AddRange(asm.GetTypes()
                                .Where(t => t.Namespace != null && regexes.Any(regex => regex.IsMatch(t.Namespace)))
                                .Where(t => IsCandidate(t))
                                .Where(t => t.HasAttribute <ComponentAttribute>(true))
                                .SkipWhile(t => !_scannerStrategies.Any(stg => stg.IsMatch(t)))
                                .SelectMany(t => _scannerStrategies.First(stg => stg.IsMatch(t)).Create(t))
                                .ToArray());

            return(beanDefCol);
        }
コード例 #2
0
        public IBeanDefinitionCollection ParseBeanMethods(Type configType)
        {
            var defCol = new BeanDefinitionCollection();

            defCol.AddRange(MethodSelector.GetAllMethodsByAttribute <BeanAttribute>(configType)
                            .SelectMany(beanMethod =>
            {
                var def = new MemberMethodBeanDefinition(beanMethod);

                return(new[] { def, new MemberMethodFactoryBeanDefinition(def) });
            })
                            .ToArray());

            return(defCol);
        }