This commit is contained in:
Eugene Sadovoi 2019-04-21 23:27:11 -04:00
Родитель e8aaeb0814
Коммит f9cdfbad9c
3 изменённых файлов: 26 добавлений и 26 удалений

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

@ -58,7 +58,7 @@ namespace Unity.Extensions
for (var i = registry.Buckets[targetBucket]; i >= 0; i = registry.Entries[i].Next)
{
ref var candidate = ref registry.Entries[i];
if (candidate.HashCode != hashCode || candidate.Key.Type != type) continue;
if (candidate.HashCode != hashCode || candidate.Key.Type != type || candidate.Key.Name != name) continue;
candidate.Value = registration;
return;
}

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

@ -35,22 +35,22 @@ namespace Unity
{
Type generic = null;
int targetBucket, hashGeneric = -1, hashDefault = -1;
int hashExact = NamedType.GetHashCode(context.Type, context.Name) & 0x7FFFFFFF;
int hashExact = NamedType.GetHashCode(context.Type, context.Name) & HashMask;
#if NETSTANDARD1_0 || NETCOREAPP1_0
var info = context.Type.GetTypeInfo();
if (info.IsGenericType)
{
generic = info.GetGenericTypeDefinition();
hashDefault = NamedType.GetHashCode(generic, null) & 0x7FFFFFFF;
hashGeneric = (null != context.Name) ? NamedType.GetHashCode(generic, context.Name) & 0x7FFFFFFF : hashDefault;
hashDefault = NamedType.GetHashCode(generic, null) & HashMask;
hashGeneric = (null != context.Name) ? NamedType.GetHashCode(generic, context.Name) & HashMask : hashDefault;
}
#else
if (context.Type.IsGenericType)
{
generic = context.Type.GetGenericTypeDefinition();
hashDefault = NamedType.GetHashCode(generic, null) & 0x7FFFFFFF;
hashGeneric = (null != context.Name) ? NamedType.GetHashCode(generic, context.Name) & 0x7FFFFFFF : hashDefault;
hashDefault = NamedType.GetHashCode(generic, null) & HashMask;
hashGeneric = (null != context.Name) ? NamedType.GetHashCode(generic, context.Name) & HashMask : hashDefault;
}
#endif
@ -67,7 +67,7 @@ namespace Unity
for (var i = registry.Buckets[targetBucket]; i >= 0; i = registry.Entries[i].Next)
{
ref var candidate = ref registry.Entries[i];
if (candidate.Key.Type != context.Type) continue;
if (candidate.HashCode != hashExact || candidate.Key.Type != context.Type) continue;
// Found a registration
return true;
@ -81,7 +81,7 @@ namespace Unity
for (var i = registry.Buckets[targetBucket]; i >= 0; i = registry.Entries[i].Next)
{
ref var candidate = ref registry.Entries[i];
if (candidate.Key.Type != generic) continue;
if (candidate.HashCode != hashGeneric || candidate.Key.Type != generic) continue;
// Found a factory
return true;
@ -95,7 +95,7 @@ namespace Unity
for (var i = registry.Buckets[targetBucket]; i >= 0; i = registry.Entries[i].Next)
{
ref var candidate = ref registry.Entries[i];
if (candidate.Key.Type != generic) continue;
if (candidate.HashCode != hashDefault || candidate.Key.Type != generic) continue;
// Found a factory
return true;

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

@ -286,14 +286,14 @@ namespace Unity
for (var i = 1; i < length; i++)
{
var index = data[i];
var key = registry.Entries[index].Key.Name;
if (null == key) continue;
var name = registry.Entries[index].Key.Name;
if (null == name) continue;
if (set.Add(registry.Entries[index].HashCode, registry.Entries[index].Key.Type))
{
try
{
var registration = (ExplicitRegistration)registry.Entries[index].Value;
value = (TElement)resolve(typeof(TElement), key, registration);
value = (TElement)resolve(typeof(TElement), name, registration);
}
catch (ArgumentException ex) when (ex.InnerException is TypeLoadException)
{
@ -328,15 +328,15 @@ namespace Unity
for (var i = 1; i < length; i++)
{
var index = data[i];
var key = registry.Entries[index].Key.Name;
var name = registry.Entries[index].Key.Name;
if (null == key) continue;
if (null == name) continue;
if (set.Add(registry.Entries[index].HashCode, registry.Entries[index].Key.Type))
{
try
{
var registration = (ExplicitRegistration)registry.Entries[index].Value;
value = (TElement)resolve(typeof(TElement), key, registration);
value = (TElement)resolve(typeof(TElement), name, registration);
}
catch (ArgumentException ex) when (ex.InnerException is TypeLoadException)
{
@ -359,7 +359,7 @@ namespace Unity
{
try
{
int hash = NamedType.GetHashCode(typeof(TElement), key) & 0x7FFFFFFF;
int hash = NamedType.GetHashCode(typeof(TElement), key) & HashMask;
var registration = container.GetOrAdd(hash, typeof(TElement), key, registry.Entries[index].Value);
value = (TElement)resolve(typeof(TElement), key, registration);
}
@ -400,15 +400,15 @@ namespace Unity
for (var i = 1; i < length; i++)
{
var index = data[i];
var key = registry.Entries[index].Key.Name;
if (null == key) continue;
var name = registry.Entries[index].Key.Name;
if (null == name) continue;
if (set.Add(registry.Entries[index].HashCode, registry.Entries[index].Key.Type))
{
try
{
int hash = NamedType.GetHashCode(typeof(TElement), key) & 0x7FFFFFFF;
var registration = container.GetOrAdd(hash, typeof(TElement), key, registry.Entries[index].Value);
value = (TElement)resolve(typeof(TElement), key, registration);
int hash = NamedType.GetHashCode(typeof(TElement), name) & HashMask;
var registration = container.GetOrAdd(hash, typeof(TElement), name, registry.Entries[index].Value);
value = (TElement)resolve(typeof(TElement), name, registration);
}
catch (ArgumentException ex) when (ex.InnerException is TypeLoadException)
{
@ -443,16 +443,16 @@ namespace Unity
for (var i = 1; i < length; i++)
{
var index = data[i];
var key = registry.Entries[index].Key.Name;
var name = registry.Entries[index].Key.Name;
if (null == key) continue;
if (null == name) continue;
if (set.Add(registry.Entries[index].HashCode, registry.Entries[index].Key.Type))
{
try
{
int hash = NamedType.GetHashCode(typeof(TElement), key) & 0x7FFFFFFF;
var registration = container.GetOrAdd(hash, typeof(TElement), key, registry.Entries[index].Value);
value = (TElement)resolve(typeof(TElement), key, registration);
int hash = NamedType.GetHashCode(typeof(TElement), name) & HashMask;
var registration = container.GetOrAdd(hash, typeof(TElement), name, registry.Entries[index].Value);
value = (TElement)resolve(typeof(TElement), name, registration);
}
catch (ArgumentException ex) when (ex.InnerException is TypeLoadException)
{