public ReflectiveBinding CreateReflectiveBinding(MethodInfo factory, BindingProviderAttribute attribute) { var dependencies = new List <BindingPair>(); if (attribute.DependencyCount > 0) { var parameters = factory.GetParameters(); for (int i = 0; i < attribute.DependencyCount; ++i) { var type = parameters[i].ParameterType; object name = InnerBindingNames.Empty; if (attribute.DependencieNames.Length > i) { name = attribute.DependencieNames[i]; } var duo = new BindingPair(name, type); dependencies.Add(duo); } } var root = new BindingPair(attribute.Name, factory.ReturnType); return(new ReflectiveBinding(root, factory, dependencies, attribute.Singleton, attribute.Subcontexts)); }
public ReflectionBindingProvider(MethodInfo factory, BindingProviderAttribute attribute) : this(new BindingPair(attribute.Name, factory.ReturnType)) { Dependencies = new List <IBindingProvider>(); if (attribute.DependencyCount > 0) { var parameters = factory.GetParameters(); for (int i = 0; i < attribute.DependencyCount; ++i) { var type = parameters[i].ParameterType; object name = InnerBindingNames.Empty; if (attribute.DependencieNames.Length > i) { name = attribute.DependencieNames[i]; } var duo = new BindingPair(name, type); Dependencies.Add(new ReflectionBindingProvider(duo)); } } }