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 ImportManyAttributeInfo : AttributeInfo<ImportManyAttribute>
14 static ConstructorInfo nameConstructor;
15 static ConstructorInfo typeConstructor;
16 static ConstructorInfo nameAndTypeConstructor;
18 public override bool IsComplete
26 public override ICollection GetConstructorArguments(ImportManyAttribute attribute, ref ConstructorInfo constructor)
28 if (attribute.ContractName != null)
30 if (attribute.ContractType != null)
32 constructor = NameAndTypeConstructor;
33 return new object[] { attribute.ContractName, attribute.ContractType };
37 constructor = NameConstructor;
38 return new object[] { attribute.ContractName };
41 else if (attribute.ContractType != null)
43 constructor = TypeConstructor;
44 return new object[] { attribute.ContractType };
48 return new object[] { };
52 public override ConstructorInfo GetConstructor()
54 return typeof(ImportManyAttribute).GetConstructor(Type.EmptyTypes);
57 static ConstructorInfo NameConstructor
61 if (nameConstructor == null)
63 nameConstructor = typeof(ImportManyAttribute).GetConstructor(new Type[] { typeof(string) });
65 return nameConstructor;
69 static ConstructorInfo NameAndTypeConstructor
73 if (nameAndTypeConstructor == null)
75 nameAndTypeConstructor = typeof(ImportManyAttribute).GetConstructor(new Type[] { typeof(Type) });
77 return nameAndTypeConstructor;
81 static ConstructorInfo TypeConstructor
85 if (typeConstructor == null)
87 typeConstructor = typeof(ImportManyAttribute).GetConstructor(new Type[] { typeof(string), typeof(Type) });
89 return typeConstructor;