Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        public object PostConstruct(Type type, object bean)
        {
            var postConstructors = MethodSelector.GetAllMethodsByAttribute <PostConstructAttribute>(type); // context.Existing.GetType()

            foreach (var pc in postConstructors)
            {
                if (pc.GetParameters().Length > 0 || pc.ReturnType != typeof(void))
                {
                    throw new InvalidOperationException("no-arg, void");
                }

                pc.Invoke(bean, new object[0]);
            }

            return(bean);
        }
Ejemplo n.º 3
0
        public void GetAllMethodsByAttribute_InternalMethod()
        {
            var a = MethodSelector.GetAllMethodsByAttribute <BeanAttribute>(typeof(Config)).Where(m => m.Name == "F");

            Assert.Single(a);
        }
Ejemplo n.º 4
0
        public void GetAllMethodsByAttribute_ImplVirtualMethodAnnotated()
        {
            var a = MethodSelector.GetAllMethodsByAttribute <BeanAttribute>(typeof(Config)).Where(m => m.Name == "E");

            Assert.Single(a);
        }