aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Core/DI
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/Tango.Core/DI')
-rw-r--r--Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs44
1 files changed, 3 insertions, 41 deletions
diff --git a/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs b/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs
index 19e1e91bc..de42ac6e7 100644
--- a/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs
+++ b/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs
@@ -48,11 +48,6 @@ namespace Tango.Core.DI
private List<Tuple<Type, Action<Object>>> _waitingRetrivals;
/// <summary>
- /// Gets or sets a value indicating whether to throw an exception when a type is requested but not registered.
- /// </summary>
- public bool ThrowOnRequestedTypeNotFound { get; set; } = true;
-
- /// <summary>
/// Initializes a new instance of the <see cref="TangoIOC"/> class.
/// </summary>
public TangoIOC()
@@ -191,21 +186,7 @@ namespace Tango.Core.DI
}
else
{
- //Try get by inherited..
- registeredType = _registeredTypes.Select(x => x.Value).SingleOrDefault(x => type.IsAssignableFrom(x.InterfaceType));
-
- if (registeredType != null)
- {
- if (registeredType.Instance == null)
- {
- registeredType.Instance = CreateInstance(registeredType.ImplementationType);
- NotifyAwaitingRetrievals(registeredType);
- }
-
- return registeredType.Instance;
- }
-
- if (!DesignMode && ThrowOnRequestedTypeNotFound)
+ if (!DesignMode)
{
throw new InvalidOperationException(String.Format("Requested type '{0}' could not be found.", type.Name));
}
@@ -244,20 +225,6 @@ namespace Tango.Core.DI
return;
}
}
- else
- {
- //Try get by inherited..
- registeredType = _registeredTypes.Select(x => x.Value).SingleOrDefault(x => type.IsAssignableFrom(x.InterfaceType));
-
- if (registeredType != null)
- {
- if (registeredType.Instance != null)
- {
- callback(registeredType.Instance);
- return;
- }
- }
- }
_waitingRetrivals.Add(new Tuple<Type, Action<object>>(type, callback));
}
@@ -294,11 +261,6 @@ namespace Tango.Core.DI
/// <param name="instance">The instance.</param>
protected virtual void RegisterInternal(Type interfaceType, Type implementationType, Object instance)
{
- if (DesignMode)
- {
- return;
- }
-
if (!interfaceType.IsAssignableFrom(implementationType))
{
throw new InvalidOperationException(String.Format("Interface type '{0}' cannot be assigned from implementation type '{1}'.", interfaceType.Name, implementationType.Name));
@@ -385,7 +347,7 @@ namespace Tango.Core.DI
/// <returns></returns>
public virtual IEnumerable<object> GetAllInstancesByBase(Type baseType)
{
- return _registeredTypes.Where(x => baseType.IsAssignableFrom(x.Key)).Select(x => x.Value.Instance != null ? x.Value.Instance : GetInstance(x.Value.ImplementationType));
+ return _registeredTypes.Where(x => baseType.IsAssignableFrom(x.Key)).Select(x => x.Value.Instance != null ? x.Value.Instance : CreateInstance(x.Value.ImplementationType));
}
/// <summary>
@@ -396,7 +358,7 @@ namespace Tango.Core.DI
{
var type = target.GetType();
- foreach (var prop in type.GetPropertiesWithAttribute<TangoInjectAttribute>(BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic))
+ foreach (var prop in type.GetPropertiesWithAttribute<TangoInjectAttribute>(BindingFlags.Public | BindingFlags.Instance))
{
var att = prop.GetCustomAttribute<TangoInjectAttribute>();