@@ -27,23 +27,6 @@ namespace Xtensive.Reflection
2727 /// </summary>
2828 public static class TypeHelper
2929 {
30- private const string invokeMethodName = "Invoke" ;
31-
32- private static readonly object emitLock = new object ( ) ;
33- private static readonly int NullableTypeMetadataToken = WellKnownTypes . NullableOfT . MetadataToken ;
34- private static readonly Module NullableTypeModule = WellKnownTypes . NullableOfT . Module ;
35- private static readonly Type CompilerGeneratedAttributeType = typeof ( CompilerGeneratedAttribute ) ;
36- private static readonly string TypeHelperNamespace = typeof ( TypeHelper ) . Namespace ;
37-
38- private static readonly ConcurrentDictionary < Type , Type [ ] > orderedInterfaces =
39- new ConcurrentDictionary < Type , Type [ ] > ( ) ;
40-
41- private static readonly ConcurrentDictionary < Type , Type [ ] > orderedCompatibles =
42- new ConcurrentDictionary < Type , Type [ ] > ( ) ;
43-
44- private static readonly ConcurrentDictionary < Pair < Type , Type > , InterfaceMapping > interfaceMaps =
45- new ConcurrentDictionary < Pair < Type , Type > , InterfaceMapping > ( ) ;
46-
4730 private class TypesEqualityComparer : IEqualityComparer < ( Type , Type [ ] ) >
4831 {
4932 public bool Equals ( ( Type , Type [ ] ) x , ( Type , Type [ ] ) y ) =>
@@ -59,9 +42,26 @@ public int GetHashCode((Type, Type[]) obj)
5942 }
6043 }
6144
45+ private const string invokeMethodName = "Invoke" ;
46+
6247 private static readonly ConcurrentDictionary < ( Type , Type [ ] ) , ConstructorInfo > constructorInfoByTypes =
6348 new ConcurrentDictionary < ( Type , Type [ ] ) , ConstructorInfo > ( new TypesEqualityComparer ( ) ) ;
6449
50+ private static readonly object emitLock = new object ( ) ;
51+ private static readonly int NullableTypeMetadataToken = WellKnownTypes . NullableOfT . MetadataToken ;
52+ private static readonly Module NullableTypeModule = WellKnownTypes . NullableOfT . Module ;
53+ private static readonly Type CompilerGeneratedAttributeType = typeof ( CompilerGeneratedAttribute ) ;
54+ private static readonly string TypeHelperNamespace = typeof ( TypeHelper ) . Namespace ;
55+
56+ private static readonly ConcurrentDictionary < Type , Type [ ] > orderedInterfaces =
57+ new ConcurrentDictionary < Type , Type [ ] > ( ) ;
58+
59+ private static readonly ConcurrentDictionary < Type , Type [ ] > orderedCompatibles =
60+ new ConcurrentDictionary < Type , Type [ ] > ( ) ;
61+
62+ private static readonly ConcurrentDictionary < Pair < Type , Type > , InterfaceMapping > interfaceMaps =
63+ new ConcurrentDictionary < Pair < Type , Type > , InterfaceMapping > ( ) ;
64+
6565 private static int createDummyTypeNumber = 0 ;
6666 private static AssemblyBuilder assemblyBuilder ;
6767 private static ModuleBuilder moduleBuilder ;
@@ -610,14 +610,17 @@ public static object Activate(this Type type, Type[] genericArguments, params ob
610610
611611 /// <summary>
612612 /// Gets the public constructor of type <paramref name="type"/>
613- /// accepting specified <paramref name="argumentTypes "/>.
613+ /// accepting specified <paramref name="arguments "/>.
614614 /// </summary>
615615 /// <param name="type">The type to get the constructor for.</param>
616- /// <param name="argumentTypes ">The argument types .</param>
616+ /// <param name="arguments ">The arguments .</param>
617617 /// <returns>
618618 /// Appropriate constructor, if a single match is found;
619619 /// otherwise, <see langword="null"/>.
620620 /// </returns>
621+ public static ConstructorInfo GetConstructor ( this Type type , object [ ] arguments ) =>
622+ GetSingleConstructor ( type , arguments . Select ( a => a ? . GetType ( ) ) . ToArray ( ) ) ;
623+
621624 public static ConstructorInfo GetSingleConstructor ( this Type type , Type [ ] argumentTypes ) =>
622625 constructorInfoByTypes . GetOrAdd ( ( type , argumentTypes ) , ConstructorExtractor ) ;
623626
0 commit comments