Removed IRegistration from Member selector

This commit is contained in:
Eugene Sadovoi 2019-06-02 19:58:09 -04:00
Родитель eb6e5ef941
Коммит af3b4963df
11 изменённых файлов: 19 добавлений и 24 удалений

Просмотреть файл

@ -1,10 +1,10 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using Unity.Registration;
using Unity.Injection;
namespace Unity
{
public delegate IEnumerable<object> MemberSelector<TMember>(Type type, IRegistration? set)
public delegate IEnumerable<object> MemberSelector<TMember>(Type type, InjectionMember[]? members)
where TMember : MemberInfo;
}

Просмотреть файл

@ -75,12 +75,12 @@ namespace Unity
#region Selection
public override IEnumerable<object> Select(Type type, IRegistration? registration)
public override IEnumerable<object> Select(Type type, InjectionMember[]? injectionMembers)
{
var members = new List<InjectionMember>();
// Select Injected Members
foreach (var injectionMember in registration?.InjectionMembers ?? EmptyCollection)
foreach (var injectionMember in injectionMembers ?? EmptyCollection)
{
if (injectionMember is InjectionMember<ConstructorInfo, object[]>)
{

Просмотреть файл

@ -40,7 +40,7 @@ namespace Unity
// Select ConstructorInfo
var selector = GetOrDefault(builder.Registration);
var selection = selector.Invoke(builder.Type, builder.Registration)
var selection = selector.Invoke(builder.Type, builder.InjectionMembers)
.FirstOrDefault();
// Select constructor for the Type

Просмотреть файл

@ -5,17 +5,16 @@ using System.Linq;
using System.Reflection;
using Unity.Exceptions;
using Unity.Injection;
using Unity.Registration;
namespace Unity
{
public partial class ConstructorPipeline
{
public override IEnumerable<object> Select(Type type, IRegistration? registration)
public override IEnumerable<object> Select(Type type, InjectionMember[]? injectionMembers)
{
// Select Injected Members
foreach (var injectionMember in registration?.InjectionMembers ?? EmptyCollection)
foreach (var injectionMember in injectionMembers ?? EmptyCollection)
{
if (injectionMember is InjectionMember<ConstructorInfo, object[]>)
{

Просмотреть файл

@ -5,7 +5,6 @@ using System.Reflection;
using Unity.Builder;
using Unity.Exceptions;
using Unity.Injection;
using Unity.Registration;
using Unity.Resolution;
namespace Unity
@ -24,12 +23,12 @@ namespace Unity
#region Overrides
public override IEnumerable<object> Select(Type type, IRegistration? registration)
public override IEnumerable<object> Select(Type type, InjectionMember[]? injectionMembers)
{
HashSet<object> memberSet = new HashSet<object>();
// Select Injected Members
foreach (var injectionMember in registration?.InjectionMembers ?? EmptyCollection)
foreach (var injectionMember in injectionMembers ?? EmptyCollection)
{
if (injectionMember is InjectionMember<FieldInfo, object> && memberSet.Add(injectionMember))
yield return injectionMember;

Просмотреть файл

@ -128,7 +128,7 @@ namespace Unity
public IEnumerable<Expression> GetExpressions(Type type, IRegistration? registration)
{
var selector = GetOrDefault(registration);
var members = selector(type, registration);
var members = selector(type, registration?.InjectionMembers);
return ExpressionsFromSelection(type, members);
}

Просмотреть файл

@ -20,7 +20,7 @@ namespace Unity
var pipeline = builder.Pipeline();
var selector = GetOrDefault(builder.Registration);
var members = selector.Invoke(builder.Type, builder.Registration);
var members = selector.Invoke(builder.Type, builder.InjectionMembers);
var resolvers = ResolversFromSelection(builder.Type, members).ToArray();
return 0 == resolvers.Length

Просмотреть файл

@ -2,18 +2,17 @@
using System.Collections.Generic;
using System.Reflection;
using Unity.Injection;
using Unity.Registration;
namespace Unity
{
public abstract partial class MemberPipeline<TMemberInfo, TData>
{
public virtual IEnumerable<object> Select(Type type, IRegistration? registration)
public virtual IEnumerable<object> Select(Type type, InjectionMember[]? injectionMembers)
{
HashSet<object> memberSet = new HashSet<object>();
// Select Injected Members
foreach (var injectionMember in registration?.InjectionMembers ?? EmptyCollection)
foreach (var injectionMember in injectionMembers ?? EmptyCollection)
{
if (injectionMember is InjectionMember<TMemberInfo, TData> && memberSet.Add(injectionMember))
yield return injectionMember;

Просмотреть файл

@ -26,12 +26,12 @@ namespace Unity
#region Overrides
public override IEnumerable<object> Select(Type type, IRegistration? registration)
public override IEnumerable<object> Select(Type type, InjectionMember[]? injectionMembers)
{
HashSet<object> memberSet = new HashSet<object>();
// Select Injected Members
foreach (var injectionMember in registration?.InjectionMembers ?? EmptyCollection)
foreach (var injectionMember in injectionMembers ?? EmptyCollection)
{
if (injectionMember is InjectionMember<MethodInfo, object[]> && memberSet.Add(injectionMember))
yield return injectionMember;

Просмотреть файл

@ -2,19 +2,18 @@
using System.Collections.Generic;
using System.Reflection;
using Unity.Injection;
using Unity.Registration;
namespace Unity
{
public partial class MethodPipeline
{
public override IEnumerable<object> Select(Type type, IRegistration? registration)
public override IEnumerable<object> Select(Type type, InjectionMember[]? injectionMembers)
{
HashSet<object> memberSet = new HashSet<object>();
// Select Injected Members
foreach (var injectionMember in registration?.InjectionMembers ?? EmptyCollection)
foreach (var injectionMember in injectionMembers ?? EmptyCollection)
{
if (injectionMember is InjectionMember<MethodInfo, object[]> && memberSet.Add(injectionMember))
yield return injectionMember;

Просмотреть файл

@ -5,7 +5,6 @@ using System.Reflection;
using Unity.Builder;
using Unity.Exceptions;
using Unity.Injection;
using Unity.Registration;
using Unity.Resolution;
namespace Unity
@ -25,12 +24,12 @@ namespace Unity
#region Overrides
public override IEnumerable<object> Select(Type type, IRegistration? registration)
public override IEnumerable<object> Select(Type type, InjectionMember[]? injectionMembers)
{
HashSet<object> memberSet = new HashSet<object>();
// Select Injected Members
foreach (var injectionMember in registration?.InjectionMembers ?? EmptyCollection)
foreach (var injectionMember in injectionMembers ?? EmptyCollection)
{
if (injectionMember is InjectionMember<PropertyInfo, object> && memberSet.Add(injectionMember))
yield return injectionMember;