2 // Copyright (c) Microsoft Corporation. All rights reserved.
5 namespace Microsoft.Activities.Presentation.Xaml
8 using System.Collections;
9 using System.ComponentModel.Composition;
10 using System.Reflection;
12 class ImportAttributeInfo : AttributeInfo<ImportAttribute>
14 static ConstructorInfo nameConstructor;
15 static ConstructorInfo typeConstructor;
16 static ConstructorInfo nameAndTypeConstructor;
18 public override bool IsComplete
23 public override ICollection GetConstructorArguments(ImportAttribute attribute, ref ConstructorInfo constructor)
25 if (attribute.ContractName != null)
27 if (attribute.ContractType != null)
29 constructor = NameAndTypeConstructor;
30 return new object[] { attribute.ContractName, attribute.ContractType };
34 constructor = NameConstructor;
35 return new object[] { attribute.ContractName };
38 else if (attribute.ContractType != null)
40 constructor = TypeConstructor;
41 return new object[] { attribute.ContractType };
45 return new object[] { };
49 public override ConstructorInfo GetConstructor()
51 return typeof(ImportAttribute).GetConstructor(Type.EmptyTypes);
54 static ConstructorInfo NameConstructor
58 if (nameConstructor == null)
60 nameConstructor = typeof(ImportAttribute).GetConstructor(new Type[] { typeof(string) });
62 return nameConstructor;
66 static ConstructorInfo NameAndTypeConstructor
70 if (nameAndTypeConstructor == null)
72 nameAndTypeConstructor = typeof(ImportAttribute).GetConstructor(new Type[] { typeof(string), typeof(Type) });
74 return nameAndTypeConstructor;
78 static ConstructorInfo TypeConstructor
82 if (typeConstructor == null)
84 typeConstructor = typeof(ImportAttribute).GetConstructor(new Type[] { typeof(Type) });
86 return typeConstructor;