diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-07-30 18:16:30 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-07-30 18:16:30 +0300 |
| commit | ead172c9292326266b2c1622f058df5e2039bd05 (patch) | |
| tree | 13c73297dec8e2507544fd5b0f2194750c942922 /Software/Visual_Studio/Tango.Core/DI | |
| parent | ba5a7741072abbda41e674fe19308a9b505b49f8 (diff) | |
| download | Tango-ead172c9292326266b2c1622f058df5e2039bd05.tar.gz Tango-ead172c9292326266b2c1622f058df5e2039bd05.zip | |
Working on PPC Machine Studio External Bridge !
Diffstat (limited to 'Software/Visual_Studio/Tango.Core/DI')
| -rw-r--r-- | Software/Visual_Studio/Tango.Core/DI/TangoCreateWhenRegisteredAttribute.cs | 13 | ||||
| -rw-r--r-- | Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs | 7 |
2 files changed, 19 insertions, 1 deletions
diff --git a/Software/Visual_Studio/Tango.Core/DI/TangoCreateWhenRegisteredAttribute.cs b/Software/Visual_Studio/Tango.Core/DI/TangoCreateWhenRegisteredAttribute.cs new file mode 100644 index 000000000..572c9f413 --- /dev/null +++ b/Software/Visual_Studio/Tango.Core/DI/TangoCreateWhenRegisteredAttribute.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Core.DI +{ + [AttributeUsage(AttributeTargets.Class)] + public class TangoCreateWhenRegisteredAttribute : Attribute + { + } +} diff --git a/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs b/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs index 50b892552..de42ac6e7 100644 --- a/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs +++ b/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs @@ -280,6 +280,11 @@ namespace Tango.Core.DI var registeredType = new RegisteredType(interfaceType, implementationType, instance); _registeredTypes.Add(interfaceType, registeredType); + if (implementationType.GetCustomAttribute<TangoCreateWhenRegisteredAttribute>() != null && instance == null) + { + instance = GetInstance(interfaceType); + } + if (registeredType.Instance != null) { NotifyAwaitingRetrievals(registeredType); @@ -363,7 +368,7 @@ namespace Tango.Core.DI } else { - GetInstanceWhenAvailable(prop.PropertyType, (x) => + GetInstanceWhenAvailable(prop.PropertyType, (x) => { prop.SetValue(target, GetInstance(prop.PropertyType)); }); |
