[runtime] Fix corlib out of date error with disabled COM
[mono.git] / mcs / class / referencesource / System.Activities.Presentation / Microsoft.Tools.Common / Microsoft / Activities / Presentation / Xaml / ImportAttributeInfo.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 ImportAttributeInfo : AttributeInfo<ImportAttribute>
13     {
14         static ConstructorInfo nameConstructor;
15         static ConstructorInfo typeConstructor;
16         static ConstructorInfo nameAndTypeConstructor;
17
18         public override bool IsComplete
19         {
20             get { return false; }
21         }
22
23         public override ICollection GetConstructorArguments(ImportAttribute attribute, ref ConstructorInfo constructor)
24         {
25             if (attribute.ContractName != null)
26             {
27                 if (attribute.ContractType != null)
28                 {
29                     constructor = NameAndTypeConstructor;
30                     return new object[] { attribute.ContractName, attribute.ContractType };
31                 }
32                 else
33                 {
34                     constructor = NameConstructor;
35                     return new object[] { attribute.ContractName };
36                 }
37             }
38             else if (attribute.ContractType != null)
39             {
40                 constructor = TypeConstructor;
41                 return new object[] { attribute.ContractType };
42             }
43             else
44             {
45                 return new object[] { };
46             }
47         }
48
49         public override ConstructorInfo GetConstructor()
50         {
51             return typeof(ImportAttribute).GetConstructor(Type.EmptyTypes);
52         }
53
54         static ConstructorInfo NameConstructor
55         {
56             get
57             {
58                 if (nameConstructor == null)
59                 {
60                     nameConstructor = typeof(ImportAttribute).GetConstructor(new Type[] { typeof(string) });
61                 }
62                 return nameConstructor;
63             }
64         }
65
66         static ConstructorInfo NameAndTypeConstructor
67         {
68             get
69             {
70                 if (nameAndTypeConstructor == null)
71                 {
72                     nameAndTypeConstructor = typeof(ImportAttribute).GetConstructor(new Type[] { typeof(string), typeof(Type) });
73                 }
74                 return nameAndTypeConstructor;
75             }
76         }
77
78         static ConstructorInfo TypeConstructor
79         {
80             get
81             {
82                 if (typeConstructor == null)
83                 {
84                     typeConstructor = typeof(ImportAttribute).GetConstructor(new Type[] { typeof(Type) });
85                 }
86                 return typeConstructor;
87             }
88         }
89     }
90 }