diff Implab.ServiceHost/Unity/RegistrationBuilder.cs @ 277:963b17c275be v3

Refactoring Added <array> element to injection parameters Working on registrations of factories
author cin
date Sat, 28 Apr 2018 18:48:09 +0300
parents 22629bf26121
children f07be402ab02
line wrap: on
line diff
--- a/Implab.ServiceHost/Unity/RegistrationBuilder.cs	Sat Apr 28 00:11:38 2018 +0300
+++ b/Implab.ServiceHost/Unity/RegistrationBuilder.cs	Sat Apr 28 18:48:09 2018 +0300
@@ -5,17 +5,39 @@
 using System.Xml.Serialization;
 using Implab.Xml;
 using Unity.Injection;
+using Unity.Lifetime;
 using Unity.Registration;
 
 namespace Implab.ServiceHost.Unity {
+    /// <summary>
+    /// Базовый класс для формирования записей в контейнере, созволяет указать время жизни для записи
+    /// </summary>
     public abstract class RegistrationBuilder {
         public Type RegistrationType {
             get;
             private set;
         }
 
+        internal LifetimeManager Lifetime { get; set; }
+
         protected RegistrationBuilder(Type registrationType) {
             RegistrationType = registrationType;
         }
+
+        internal void Visit(SingletonLifetimeElement simgletonLifetime) {
+            Lifetime = new SingletonLifetimeManager();
+        }
+
+        internal void Visit(ContainerLifetimeElement containerLifetime) {
+            Lifetime = new ContainerControlledLifetimeManager();
+        }
+
+        internal void Visit(HierarchicalLifetimeElement hierarchicalLifetime) {
+            Lifetime = new HierarchicalLifetimeManager();
+        }
+
+        internal void Visist(ContextLifetimeElement contextLifetime) {
+            Lifetime = new PerResolveLifetimeManager();
+        }
     }
 }
\ No newline at end of file