(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / System / System.CodeDom / CodeTypeReference.cs
blob7a955d8868b3bb4ff44debf1c186ed22fbae14b7
1 //
2 // System.CodeDom CodeTypeReferenceExpression Class implementation
3 //
4 // Author:
5 // Daniel Stodden (stodden@in.tum.de)
6 // Marek Safar (marek.safar@seznam.cz)
7 //
8 // (C) 2001 Ximian, Inc.
9 //
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 using System.Runtime.InteropServices;
34 namespace System.CodeDom
36 [Serializable]
37 [ClassInterface(ClassInterfaceType.AutoDispatch)]
38 [ComVisible(true)]
39 public class CodeTypeReference
40 : CodeObject
42 private string baseType;
43 private CodeTypeReference arrayType;
44 private int rank;
46 #if NET_2_0
47 CodeTypeReferenceCollection typeArguments;
48 CodeTypeReferenceOptions codeTypeReferenceOption;
49 #endif
52 // Constructors
54 public CodeTypeReference( string baseType )
56 if (baseType.Length == 0) {
57 this.baseType = typeof (void).FullName;
58 return;
61 int array_start = baseType.LastIndexOf ('[');
62 if (array_start == -1) {
63 this.baseType = baseType;
64 return;
66 string[] args = baseType.Split (',');
68 int array_end = baseType.LastIndexOf (']');
70 #if NET_2_0
71 if ((array_end - array_start) != args.Length) {
72 arrayType = new CodeTypeReference (baseType.Substring (0, array_start));
73 array_start++;
74 TypeArguments.Add (new CodeTypeReference (baseType.Substring (array_start, array_end - array_start)));
75 } else
76 #endif
77 arrayType = new CodeTypeReference (baseType.Substring (0, array_start), args.Length);
80 public CodeTypeReference( Type baseType )
82 if (baseType.IsArray) {
83 this.rank = baseType.GetArrayRank ();
84 this.arrayType = new CodeTypeReference (baseType.GetElementType ());
85 this.baseType = arrayType.BaseType;
86 return;
88 this.baseType = baseType.FullName;
91 public CodeTypeReference( CodeTypeReference arrayType, int rank )
93 this.baseType = null;
94 this.rank = rank;
95 this.arrayType = arrayType;
98 public CodeTypeReference( string baseType, int rank )
99 : this (new CodeTypeReference (baseType), rank)
103 #if NET_2_0
104 public CodeTypeReference( CodeTypeParameter typeParameter ) :
105 this (typeParameter.Name)
109 public CodeTypeReference( string typeName, CodeTypeReferenceOptions codeTypeReferenceOption ) :
110 this (typeName)
112 this.codeTypeReferenceOption = codeTypeReferenceOption;
115 public CodeTypeReference( Type type, CodeTypeReferenceOptions codeTypeReferenceOption ) :
116 this (type)
118 this.codeTypeReferenceOption = codeTypeReferenceOption;
121 public CodeTypeReference( string typeName, params CodeTypeReference[] typeArguments ) :
122 this (typeName)
124 TypeArguments.AddRange (typeArguments);
126 #endif
129 // Properties
132 public CodeTypeReference ArrayElementType
134 get {
135 return arrayType;
137 set {
138 arrayType = value;
142 public int ArrayRank {
143 get {
144 return rank;
146 set {
147 rank = value;
151 public string BaseType {
152 get {
153 if (baseType == null)
154 return String.Empty;
156 return baseType;
158 set {
159 baseType = value;
163 #if NET_2_0
164 [ComVisible (false)]
165 public CodeTypeReferenceOptions Options {
166 get {
167 return codeTypeReferenceOption;
169 set {
170 codeTypeReferenceOption = value;
174 [ComVisible (false)]
175 public CodeTypeReferenceCollection TypeArguments {
176 get {
177 if (typeArguments == null)
178 typeArguments = new CodeTypeReferenceCollection ();
179 return typeArguments;
182 #endif