diff Implab.ServiceHost/Unity/SpecializedTypeReference.cs @ 278:6691aff01de1 v3

Implab: added XmlDefaultSeializer (SerializersPool is now obsolete) Implab.ServiceHost: rewritten TypeReference (added support for nested types), stable API
author cin
date Thu, 03 May 2018 09:59:44 +0300
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Implab.ServiceHost/Unity/SpecializedTypeReference.cs	Thu May 03 09:59:44 2018 +0300
@@ -0,0 +1,52 @@
+using System;
+using System.Linq;
+using System.Text;
+
+namespace Implab.ServiceHost.Unity {
+    public class SpecializedTypeReference : TypeReference {
+        public override string Name {
+            get {
+                return GenericType.Name;
+            }
+        }
+
+        public override string Namespace {
+            get {
+                return GenericType.Namespace;
+            }
+        }
+
+        public override int GenericParametersCount {
+            get {
+                return GenericParameters.Length;
+            }
+        }
+
+        public TypeReference GenericType { get; private set; }
+
+        public TypeReference[] GenericParameters { get; private set; }
+
+        internal SpecializedTypeReference(TypeReference genericType, TypeReference[] genericParameters) {
+            GenericType = genericType;
+            GenericParameters = genericParameters;
+        }
+
+        internal override void Visit(TypeResolutionContext visitor) {
+            visitor.Visit(this);
+        }
+
+        internal override void WriteTypeName(StringBuilder builder) {
+            GenericType.WriteTypeName(builder);
+        }
+
+        internal override void WriteTypeParams(StringBuilder builder) {
+            builder.Append('{');
+            for (var i = 0; i < GenericParameters.Length; i++) {
+                if (i > 0)
+                    builder.Append(',');
+                builder.Append(GenericParameters[i]);
+            }
+            builder.Append('}');
+        }
+    }
+}
\ No newline at end of file