diff Implab.ServiceHost/Unity/RegisterElement.cs @ 273:79110a16cab7 v3

Working on Unity xml configuration: Refactoring in progress
author cin
date Thu, 26 Apr 2018 19:35:01 +0300
parents 9d1cca834b05
children 22629bf26121
line wrap: on
line diff
--- a/Implab.ServiceHost/Unity/RegisterElement.cs	Thu Apr 26 03:14:54 2018 +0300
+++ b/Implab.ServiceHost/Unity/RegisterElement.cs	Thu Apr 26 19:35:01 2018 +0300
@@ -11,8 +11,8 @@
         /// <summary>
         /// An optional type which is registered as a service in the container, must be assignable to <see cref="ProvidesType">.
         /// </summary>
-        [XmlAttribute("type")]
-        public string ImplementationType { get; set; }
+        [XmlAttribute("mapTo")]
+        public string MapToType { get; set; }
 
 
         [XmlElement("constructor", typeof(ConstructorInjectionElement))]
@@ -20,9 +20,15 @@
         [XmlElement("method", typeof(MethodInjectionElement))]
         public AbstractInjectionElement[] Injectors { get; set; }
 
-        public override void Visit(ConfigurationContext context) {
+        public override void Visit(ContainerContext context) {
             context.Visit(this);
         }
+
+        public virtual Type ResolveImplementationType(ContainerContext ctx) {
+            return string.IsNullOrEmpty(MapToType) ?
+                ResolveRegistrationType(ctx) :
+                ctx.Resolve(MapToType);
+        }
     }
     
 }
\ No newline at end of file