[reflection] Coop handles icalls in System.Reflection and System.RuntimeTypeHandle...
[mono.git] / mcs / class / referencesource / System.Activities.Presentation / Microsoft.Tools.Common / Microsoft / Activities / Presentation / Xaml / ImportManyAttributeInfo.cs
1 // <copyright>
2 //   Copyright (c) Microsoft Corporation.  All rights reserved.
3 // </copyright>
4
5 namespace Microsoft.Activities.Presentation.Xaml
6 {
7     using System;
8     using System.Collections;
9     using System.ComponentModel.Composition;
10     using System.Reflection;
11
12     class ImportManyAttributeInfo : AttributeInfo<ImportManyAttribute>
13     {
14         static ConstructorInfo nameConstructor;
15         static ConstructorInfo typeConstructor;
16         static ConstructorInfo nameAndTypeConstructor;
17
18         public override bool IsComplete
19         {
20             get
21             {
22                 return false;
23             }
24         }
25
26         public override ICollection GetConstructorArguments(ImportManyAttribute attribute, ref ConstructorInfo constructor)
27         {
28             if (attribute.ContractName != null)
29             {
30                 if (attribute.ContractType != null)
31                 {
32                     constructor = NameAndTypeConstructor;
33                     return new object[] { attribute.ContractName, attribute.ContractType };
34                 }
35                 else
36                 {
37                     constructor = NameConstructor;
38                     return new object[] { attribute.ContractName };
39                 }
40             }
41             else if (attribute.ContractType != null)
42             {
43                 constructor = TypeConstructor;
44                 return new object[] { attribute.ContractType };
45             }
46             else
47             {
48                 return new object[] { };
49             }
50         }
51
52         public override ConstructorInfo GetConstructor()
53         {
54             return typeof(ImportManyAttribute).GetConstructor(Type.EmptyTypes);
55         }
56
57         static ConstructorInfo NameConstructor
58         {
59             get
60             {
61                 if (nameConstructor == null)
62                 {
63                     nameConstructor = typeof(ImportManyAttribute).GetConstructor(new Type[] { typeof(string) });
64                 }
65                 return nameConstructor;
66             }
67         }
68
69         static ConstructorInfo NameAndTypeConstructor
70         {
71             get
72             {
73                 if (nameAndTypeConstructor == null)
74                 {
75                     nameAndTypeConstructor = typeof(ImportManyAttribute).GetConstructor(new Type[] { typeof(Type) });
76                 }
77                 return nameAndTypeConstructor;
78             }
79         }
80
81         static ConstructorInfo TypeConstructor
82         {
83             get
84             {
85                 if (typeConstructor == null)
86                 {
87                     typeConstructor = typeof(ImportManyAttribute).GetConstructor(new Type[] { typeof(string), typeof(Type) });
88                 }
89                 return typeConstructor;
90             }
91         }
92     }
93 }