3
3
using System . Collections . Generic ;
4
4
using System . Globalization ;
5
5
using System . Reflection ;
6
+ using System . Runtime . CompilerServices ;
6
7
using System . Xml ;
7
8
using System . Xml . Linq ;
8
9
using NHibernate . Bytecode ;
9
10
using NHibernate . Classic ;
11
+ using NHibernate . Linq ;
10
12
using NHibernate . SqlTypes ;
11
13
using NHibernate . UserTypes ;
12
14
using NHibernate . Util ;
13
- using System . Runtime . CompilerServices ;
14
15
15
16
namespace NHibernate . Type
16
17
{
@@ -37,7 +38,25 @@ private enum TypeClassification
37
38
private static readonly char [ ] PrecisionScaleSplit = new [ ] { '(' , ')' , ',' } ;
38
39
private static readonly char [ ] LengthSplit = new [ ] { '(' , ')' } ;
39
40
private static readonly TypeFactory Instance ;
40
- private static readonly System . Type [ ] GenericCollectionSimpleSignature = new [ ] { typeof ( string ) , typeof ( string ) , typeof ( bool ) } ;
41
+
42
+ private static readonly MethodInfo BagDefinition = ReflectionHelper . GetMethodDefinition < ICollectionTypeFactory > (
43
+ f => f . Bag < object > ( null , null , false ) ) ;
44
+ private static readonly MethodInfo IdBagDefinition = ReflectionHelper . GetMethodDefinition < ICollectionTypeFactory > (
45
+ f => f . IdBag < object > ( null , null , false ) ) ;
46
+ private static readonly MethodInfo ListDefinition = ReflectionHelper . GetMethodDefinition < ICollectionTypeFactory > (
47
+ f => f . List < object > ( null , null , false ) ) ;
48
+ private static readonly MethodInfo MapDefinition = ReflectionHelper . GetMethodDefinition < ICollectionTypeFactory > (
49
+ f => f . Map < object , object > ( null , null , false ) ) ;
50
+ private static readonly MethodInfo SortedListDefinition = ReflectionHelper . GetMethodDefinition < ICollectionTypeFactory > (
51
+ f => f . SortedList < object , object > ( null , null , false , null ) ) ;
52
+ private static readonly MethodInfo SortedDictionaryDefinition = ReflectionHelper . GetMethodDefinition < ICollectionTypeFactory > (
53
+ f => f . SortedDictionary < object , object > ( null , null , false , null ) ) ;
54
+ private static readonly MethodInfo SetDefinition = ReflectionHelper . GetMethodDefinition < ICollectionTypeFactory > (
55
+ f => f . Set < object > ( null , null , false ) ) ;
56
+ private static readonly MethodInfo SortedSetDefinition = ReflectionHelper . GetMethodDefinition < ICollectionTypeFactory > (
57
+ f => f . SortedSet < object > ( null , null , false , null ) ) ;
58
+ private static readonly MethodInfo OrderedSetDefinition = ReflectionHelper . GetMethodDefinition < ICollectionTypeFactory > (
59
+ f => f . OrderedSet < object > ( null , null , false ) ) ;
41
60
42
61
/*
43
62
* Maps the string representation of the type to the IType. The string
@@ -767,80 +786,65 @@ public static CollectionType Array(string role, string propertyRef, bool embedde
767
786
768
787
public static CollectionType GenericBag ( string role , string propertyRef , System . Type elementClass )
769
788
{
770
- MethodInfo mi = ReflectHelper . GetGenericMethodFrom < ICollectionTypeFactory > ( "Bag" , new [ ] { elementClass } ,
771
- GenericCollectionSimpleSignature ) ;
789
+ MethodInfo mi = BagDefinition . MakeGenericMethod ( new [ ] { elementClass } ) ;
772
790
773
791
return ( CollectionType ) mi . Invoke ( Instance . CollectionTypeFactory , new object [ ] { role , propertyRef , false } ) ;
774
792
}
775
793
776
794
public static CollectionType GenericIdBag ( string role , string propertyRef , System . Type elementClass )
777
795
{
778
- MethodInfo mi = ReflectHelper . GetGenericMethodFrom < ICollectionTypeFactory > ( "IdBag" , new [ ] { elementClass } ,
779
- GenericCollectionSimpleSignature ) ;
796
+ MethodInfo mi = IdBagDefinition . MakeGenericMethod ( new [ ] { elementClass } ) ;
780
797
781
798
return ( CollectionType ) mi . Invoke ( Instance . CollectionTypeFactory , new object [ ] { role , propertyRef , false } ) ;
782
799
}
783
800
784
801
public static CollectionType GenericList ( string role , string propertyRef , System . Type elementClass )
785
802
{
786
- MethodInfo mi = ReflectHelper . GetGenericMethodFrom < ICollectionTypeFactory > ( "List" , new [ ] { elementClass } ,
787
- GenericCollectionSimpleSignature ) ;
803
+ MethodInfo mi = ListDefinition . MakeGenericMethod ( new [ ] { elementClass } ) ;
788
804
789
805
return ( CollectionType ) mi . Invoke ( Instance . CollectionTypeFactory , new object [ ] { role , propertyRef , false } ) ;
790
806
}
791
807
792
- public static CollectionType GenericMap ( string role , string propertyRef , System . Type indexClass ,
793
- System . Type elementClass )
808
+ public static CollectionType GenericMap ( string role , string propertyRef , System . Type indexClass , System . Type elementClass )
794
809
{
795
- MethodInfo mi = ReflectHelper . GetGenericMethodFrom < ICollectionTypeFactory > ( "Map" , new [ ] { indexClass , elementClass } ,
796
- GenericCollectionSimpleSignature ) ;
810
+ MethodInfo mi = MapDefinition . MakeGenericMethod ( new [ ] { indexClass , elementClass } ) ;
797
811
798
812
return ( CollectionType ) mi . Invoke ( Instance . CollectionTypeFactory , new object [ ] { role , propertyRef , false } ) ;
799
813
}
800
814
801
815
public static CollectionType GenericSortedList ( string role , string propertyRef , object comparer ,
802
- System . Type indexClass , System . Type elementClass )
816
+ System . Type indexClass , System . Type elementClass )
803
817
{
804
- var signature = new [ ] { typeof ( string ) , typeof ( string ) , typeof ( bool ) , typeof ( IComparer < > ) . MakeGenericType ( indexClass ) } ;
805
- MethodInfo mi = ReflectHelper . GetGenericMethodFrom < ICollectionTypeFactory > ( "SortedList" , new [ ] { indexClass , elementClass } ,
806
- signature ) ;
818
+ MethodInfo mi = SortedListDefinition . MakeGenericMethod ( new [ ] { indexClass , elementClass } ) ;
807
819
808
820
return ( CollectionType ) mi . Invoke ( Instance . CollectionTypeFactory , new object [ ] { role , propertyRef , false , comparer } ) ;
809
821
}
810
822
811
823
public static CollectionType GenericSortedDictionary ( string role , string propertyRef , object comparer ,
812
- System . Type indexClass , System . Type elementClass )
824
+ System . Type indexClass , System . Type elementClass )
813
825
{
814
- var signature = new [ ] { typeof ( string ) , typeof ( string ) , typeof ( bool ) , typeof ( IComparer < > ) . MakeGenericType ( indexClass ) } ;
815
- MethodInfo mi = ReflectHelper . GetGenericMethodFrom < ICollectionTypeFactory > ( "SortedDictionary" , new [ ] { indexClass , elementClass } ,
816
- signature ) ;
826
+ MethodInfo mi = SortedDictionaryDefinition . MakeGenericMethod ( new [ ] { indexClass , elementClass } ) ;
817
827
818
828
return ( CollectionType ) mi . Invoke ( Instance . CollectionTypeFactory , new object [ ] { role , propertyRef , false , comparer } ) ;
819
829
}
820
830
821
831
public static CollectionType GenericSet ( string role , string propertyRef , System . Type elementClass )
822
832
{
823
- MethodInfo mi = ReflectHelper . GetGenericMethodFrom < ICollectionTypeFactory > ( "Set" , new [ ] { elementClass } ,
824
- GenericCollectionSimpleSignature ) ;
833
+ MethodInfo mi = SetDefinition . MakeGenericMethod ( new [ ] { elementClass } ) ;
825
834
826
835
return ( CollectionType ) mi . Invoke ( Instance . CollectionTypeFactory , new object [ ] { role , propertyRef , false } ) ;
827
836
}
828
837
829
- public static CollectionType GenericSortedSet ( string role , string propertyRef , object comparer ,
830
- System . Type elementClass )
838
+ public static CollectionType GenericSortedSet ( string role , string propertyRef , object comparer , System . Type elementClass )
831
839
{
832
- var signature = new [ ] { typeof ( string ) , typeof ( string ) , typeof ( bool ) , typeof ( IComparer < > ) . MakeGenericType ( elementClass ) } ;
833
- MethodInfo mi = ReflectHelper . GetGenericMethodFrom < ICollectionTypeFactory > ( "SortedSet" , new [ ] { elementClass } ,
834
- signature ) ;
840
+ MethodInfo mi = SortedSetDefinition . MakeGenericMethod ( new [ ] { elementClass } ) ;
835
841
836
842
return ( CollectionType ) mi . Invoke ( Instance . CollectionTypeFactory , new object [ ] { role , propertyRef , false , comparer } ) ;
837
843
}
838
844
839
- public static CollectionType GenericOrderedSet ( string role , string propertyRef ,
840
- System . Type elementClass )
845
+ public static CollectionType GenericOrderedSet ( string role , string propertyRef , System . Type elementClass )
841
846
{
842
- MethodInfo mi = ReflectHelper . GetGenericMethodFrom < ICollectionTypeFactory > ( "OrderedSet" , new [ ] { elementClass } ,
843
- GenericCollectionSimpleSignature ) ;
847
+ MethodInfo mi = OrderedSetDefinition . MakeGenericMethod ( new [ ] { elementClass } ) ;
844
848
845
849
return ( CollectionType ) mi . Invoke ( Instance . CollectionTypeFactory , new object [ ] { role , propertyRef , false } ) ;
846
850
}
0 commit comments