Abstractions Updates
This commit is contained in:
Родитель
123d4bccb1
Коммит
0eead3598f
|
@ -86,11 +86,22 @@ namespace Unity.Builder
|
|||
: Registration.Get(policyInterface));
|
||||
}
|
||||
|
||||
public object Get(Type type, Type policyInterface)
|
||||
{
|
||||
return List.Get(type, UnityContainer.All, policyInterface) ??
|
||||
((UnityContainer)Container).GetPolicy(type, UnityContainer.All, policyInterface);
|
||||
}
|
||||
|
||||
public void Set(Type policyInterface, object policy)
|
||||
{
|
||||
List.Set(RegistrationType, Name, policyInterface, policy);
|
||||
}
|
||||
|
||||
public void Set(Type type, Type policyInterface, object policy)
|
||||
{
|
||||
List.Set(type, UnityContainer.All, policyInterface, policy);
|
||||
}
|
||||
|
||||
public void Set(Type type, string name, Type policyInterface, object policy)
|
||||
{
|
||||
List.Set(type, name, policyInterface, policy);
|
||||
|
|
|
@ -76,6 +76,25 @@ namespace Unity.Storage
|
|||
return _innerPolicyList?.Get(type, name, policyInterface);
|
||||
}
|
||||
|
||||
public object Get(Type type, Type policyInterface)
|
||||
{
|
||||
object policy = null;
|
||||
|
||||
if (_policies?.TryGetValue(new PolicyKey(type, UnityContainer.All, policyInterface), out policy) ?? false)
|
||||
{
|
||||
return policy;
|
||||
}
|
||||
|
||||
return _innerPolicyList?.Get(type, UnityContainer.All, policyInterface);
|
||||
}
|
||||
|
||||
public void Set(Type type, Type policyInterface, object policy)
|
||||
{
|
||||
if (null == _policies)
|
||||
_policies = new Dictionary<PolicyKey, object>(PolicyKeyEqualityComparer.Default);
|
||||
|
||||
_policies[new PolicyKey(type, UnityContainer.All, policyInterface)] = policy;
|
||||
}
|
||||
|
||||
public void Set(Type type, string name, Type policyInterface, object policy)
|
||||
{
|
||||
|
|
|
@ -92,10 +92,16 @@ namespace Unity
|
|||
public virtual void ClearAll()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual object Get(Type type, Type policyInterface)
|
||||
=> _container.GetPolicy(type, All, policyInterface);
|
||||
|
||||
public virtual object Get(Type type, string name, Type policyInterface)
|
||||
public virtual object Get(Type type, string name, Type policyInterface)
|
||||
=> _container.GetPolicy(type, name, policyInterface);
|
||||
|
||||
public virtual void Set(Type type, Type policyInterface, object policy)
|
||||
=> _container.SetPolicy(type, All, policyInterface, policy);
|
||||
|
||||
public virtual void Set(Type type, string name, Type policyInterface, object policy)
|
||||
=> _container.SetPolicy(type, name, policyInterface, policy);
|
||||
|
||||
|
|
|
@ -405,6 +405,14 @@ namespace Unity
|
|||
|
||||
#region IPolicyList
|
||||
|
||||
public object Get(Type type, Type policyInterface)
|
||||
{
|
||||
if (_type != type)
|
||||
return _container.GetPolicy(type, All, policyInterface);
|
||||
|
||||
return _registration.Get(policyInterface);
|
||||
}
|
||||
|
||||
public object Get(Type type, string name, Type policyInterface)
|
||||
{
|
||||
if (_type != type || _name != name)
|
||||
|
@ -413,6 +421,13 @@ namespace Unity
|
|||
return _registration.Get(policyInterface);
|
||||
}
|
||||
|
||||
public void Set(Type type, Type policyInterface, object policy)
|
||||
{
|
||||
if (_type != type)
|
||||
_container.SetPolicy(type, All, policyInterface, policy);
|
||||
else
|
||||
_registration.Set(policyInterface, policy);
|
||||
}
|
||||
|
||||
public void Set(Type type, string name, Type policyInterface, object policy)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче