aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Core/DI
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2018-06-30 03:59:41 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2018-06-30 03:59:41 +0300
commit010535f3064bbf69f063c5f329b7689c070a4ea8 (patch)
tree6e3f1b0ea6cc27373c3aea7159069f63ba8c9d0b /Software/Visual_Studio/Tango.Core/DI
parent48904928ae83d9c836fe8408374a21af01e5b132 (diff)
downloadTango-010535f3064bbf69f063c5f329b7689c070a4ea8.tar.gz
Tango-010535f3064bbf69f063c5f329b7689c070a4ea8.zip
Implemented "Dialogs" on TouchPanel and PPC INotificationProvider !
Added Inject method to TangoIOC. Started working on color correction.
Diffstat (limited to 'Software/Visual_Studio/Tango.Core/DI')
-rw-r--r--Software/Visual_Studio/Tango.Core/DI/ITangoIOC.cs6
-rw-r--r--Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs29
2 files changed, 26 insertions, 9 deletions
diff --git a/Software/Visual_Studio/Tango.Core/DI/ITangoIOC.cs b/Software/Visual_Studio/Tango.Core/DI/ITangoIOC.cs
index 145e9988a..1e847e47a 100644
--- a/Software/Visual_Studio/Tango.Core/DI/ITangoIOC.cs
+++ b/Software/Visual_Studio/Tango.Core/DI/ITangoIOC.cs
@@ -97,6 +97,12 @@ namespace Tango.Core.DI
T GetInstance<T>();
/// <summary>
+ /// Injects any dependencies to the target properties using the <see cref="TangoInjectAttribute"/>.
+ /// </summary>
+ /// <param name="target">The target.</param>
+ void Inject(Object target);
+
+ /// <summary>
/// Executes the specified action when type T is available. if already available action will be executed immediately.
/// </summary>
/// <typeparam name="T"></typeparam>
diff --git a/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs b/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs
index c10c550cb..20827bca7 100644
--- a/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs
+++ b/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs
@@ -306,15 +306,7 @@ namespace Tango.Core.DI
instance = Activator.CreateInstance(type);
}
- foreach (var prop in type.GetPropertiesWithAttribute<TangoInjectAttribute>(BindingFlags.Public | BindingFlags.Instance))
- {
- prop.SetValue(instance, GetInstance(prop.PropertyType));
- }
-
- foreach (var field in type.GetFieldsWithAttribute<TangoInjectAttribute>(BindingFlags.NonPublic | BindingFlags.Instance))
- {
- field.SetValue(instance, GetInstance(field.FieldType));
- }
+ Inject(instance);
return instance;
}
@@ -338,5 +330,24 @@ namespace Tango.Core.DI
{
return _registeredTypes.Where(x => baseType.IsAssignableFrom(x.Key)).Select(x => x.Value.Instance != null ? x.Value.Instance : CreateInstance(x.Value.ImplementationType));
}
+
+ /// <summary>
+ /// Injects any dependencies to the target properties using the <see cref="TangoInjectAttribute" />.
+ /// </summary>
+ /// <param name="target">The target.</param>
+ public void Inject(object target)
+ {
+ var type = target.GetType();
+
+ foreach (var prop in type.GetPropertiesWithAttribute<TangoInjectAttribute>(BindingFlags.Public | BindingFlags.Instance))
+ {
+ prop.SetValue(target, GetInstance(prop.PropertyType));
+ }
+
+ foreach (var field in type.GetFieldsWithAttribute<TangoInjectAttribute>(BindingFlags.NonPublic | BindingFlags.Instance))
+ {
+ field.SetValue(target, GetInstance(field.FieldType));
+ }
+ }
}
}