268
|
1 using System;
|
|
2 using System.Linq;
|
|
3 using System.Text;
|
|
4
|
267
|
5 namespace Implab.ServiceHost.Unity {
|
|
6 public class TypeReference {
|
|
7 public string TypeName { get; set; }
|
|
8
|
|
9 public string Namespace { get; set; }
|
|
10
|
|
11 public TypeReference[] GenericParameters { get; set; }
|
268
|
12
|
|
13 public bool IsArray { get; set; }
|
|
14
|
|
15 public bool IsOpenGeneric {
|
|
16 get {
|
|
17 return GenericParameters!=null && GenericParameters.Contains(null);
|
|
18 }
|
|
19 }
|
|
20
|
|
21 public bool IsGeneric {
|
|
22 get {
|
|
23 return GenericParameters != null && GenericParameters.Length > 0;
|
|
24 }
|
|
25 }
|
|
26
|
|
27 public override string ToString() {
|
|
28 var builder = new StringBuilder();
|
|
29
|
|
30 if (!string.IsNullOrEmpty(Namespace)) {
|
|
31 builder.Append(Namespace);
|
|
32 builder.Append('.');
|
|
33 }
|
|
34
|
|
35 if (!string.IsNullOrEmpty(TypeName)) {
|
|
36 builder.Append(TypeName);
|
|
37 } else {
|
|
38 builder.Append("__unnamed__");
|
|
39 }
|
|
40
|
|
41 if (GenericParameters != null && GenericParameters.Length > 0) {
|
|
42 builder.Append('{');
|
|
43 for(var i = 0; i < GenericParameters.Length; i++) {
|
|
44 if (i > 0)
|
|
45 builder.Append(',');
|
|
46 builder.Append(GenericParameters[i]);
|
|
47 }
|
|
48 builder.Append('}');
|
|
49 }
|
|
50
|
|
51 return builder.ToString();
|
|
52 }
|
|
53 public static TypeReference Parse(string text) {
|
|
54 var parser = new TypeReferenceParser(text);
|
|
55 return parser.Parse();
|
|
56 }
|
267
|
57 }
|
|
58 } |