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); }
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); }
public void GetAllMethodsByAttribute_InternalMethod() { var a = MethodSelector.GetAllMethodsByAttribute <BeanAttribute>(typeof(Config)).Where(m => m.Name == "F"); Assert.Single(a); }
public void GetAllMethodsByAttribute_ImplVirtualMethodAnnotated() { var a = MethodSelector.GetAllMethodsByAttribute <BeanAttribute>(typeof(Config)).Where(m => m.Name == "E"); Assert.Single(a); }