public void InspectMethod(IComponentInfo ctx, IKernel kernel, MethodInfo m) { //var componentAttr = m.GetAttribute<ComponentAttribute>(true); var componentAttr = componentAttributeVisitor.VisitMethod(m); if (componentAttr != null) { Type contract = componentAttr.Contract; if (contract != null) { Check(contract); } else { contract = PopulateMethodContract(m); } exports.Add(new MethodExportInfo { Id = componentAttr != null ? componentAttr.Id : Guid.NewGuid().ToString(), Contract = contract, Method = m }); return; } if (m.ReturnType != Types.Void) { return; } var injectAttr = GetInjectAttribute(m); if (injectAttr != null) { var injection = CreateMethodInjection(ctx, kernel, m, injectAttr); if (injection != null) { injections.Add(injection); } return; } var subscribeAttr = GetSubscribeAttribute(m); if (subscribeAttr != null) { var item = CreateSubscribeInfoFactoryProvider(m, subscribeAttr); if (item != null) { providers.Add(item); } return; } var callbackAttr = callbackAttributeVisitor.VisitMethod(m); if (callbackAttr != null) { var parameterCount = m.GetParameters().Length; var callback = parameterCount == 1 ? Delegate.CreateDelegate(typeof(Action <,>).MakeGenericType(m.DeclaringType, typeof(string[])), m) : Delegate.CreateDelegate(typeof(Action <>).MakeGenericType(m.DeclaringType), m); ctx.ExtendedProperties["ReinjectedNotification"] = new KeyValuePair <int, Delegate>(parameterCount, callback); } }
private static SubscribeAttribute GetSubscribeAttribute(MethodInfo m) { //return m.GetAttribute<SubscribeAttribute>(true); return(subscribeAttributeVisitor.VisitMethod(m)); }
private static InjectAttribute GetInjectAttribute(MethodInfo m) { return(injectAttributeVisitor.VisitMethod(m)); //return m.GetAttribute<InjectAttribute>(false); }
private void InspectMethods(IComponentInfo ctx, IKernel kernel, Type componentType) { componentType.GetMethods(Flags) .Where(p => !ignoreVisitor.VisitMethod(p)) .ForEach(p => injectionInspector.InspectMethod(ctx, kernel, p)); }