33using System . Collections . Generic ;
44using System . Globalization ;
55using System . Reflection ;
6+ using System . Runtime . CompilerServices ;
67using System . Xml ;
78using System . Xml . Linq ;
89using NHibernate . Bytecode ;
910using NHibernate . Classic ;
11+ using NHibernate . Linq ;
1012using NHibernate . SqlTypes ;
1113using NHibernate . UserTypes ;
1214using NHibernate . Util ;
13- using System . Runtime . CompilerServices ;
1415
1516namespace NHibernate . Type
1617{
@@ -37,7 +38,25 @@ private enum TypeClassification
3738 private static readonly char [ ] PrecisionScaleSplit = new [ ] { '(' , ')' , ',' } ;
3839 private static readonly char [ ] LengthSplit = new [ ] { '(' , ')' } ;
3940 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 ) ) ;
4160
4261 /*
4362 * 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
767786
768787 public static CollectionType GenericBag ( string role , string propertyRef , System . Type elementClass )
769788 {
770- MethodInfo mi = ReflectHelper . GetGenericMethodFrom < ICollectionTypeFactory > ( "Bag" , new [ ] { elementClass } ,
771- GenericCollectionSimpleSignature ) ;
789+ MethodInfo mi = BagDefinition . MakeGenericMethod ( new [ ] { elementClass } ) ;
772790
773791 return ( CollectionType ) mi . Invoke ( Instance . CollectionTypeFactory , new object [ ] { role , propertyRef , false } ) ;
774792 }
775793
776794 public static CollectionType GenericIdBag ( string role , string propertyRef , System . Type elementClass )
777795 {
778- MethodInfo mi = ReflectHelper . GetGenericMethodFrom < ICollectionTypeFactory > ( "IdBag" , new [ ] { elementClass } ,
779- GenericCollectionSimpleSignature ) ;
796+ MethodInfo mi = IdBagDefinition . MakeGenericMethod ( new [ ] { elementClass } ) ;
780797
781798 return ( CollectionType ) mi . Invoke ( Instance . CollectionTypeFactory , new object [ ] { role , propertyRef , false } ) ;
782799 }
783800
784801 public static CollectionType GenericList ( string role , string propertyRef , System . Type elementClass )
785802 {
786- MethodInfo mi = ReflectHelper . GetGenericMethodFrom < ICollectionTypeFactory > ( "List" , new [ ] { elementClass } ,
787- GenericCollectionSimpleSignature ) ;
803+ MethodInfo mi = ListDefinition . MakeGenericMethod ( new [ ] { elementClass } ) ;
788804
789805 return ( CollectionType ) mi . Invoke ( Instance . CollectionTypeFactory , new object [ ] { role , propertyRef , false } ) ;
790806 }
791807
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 )
794809 {
795- MethodInfo mi = ReflectHelper . GetGenericMethodFrom < ICollectionTypeFactory > ( "Map" , new [ ] { indexClass , elementClass } ,
796- GenericCollectionSimpleSignature ) ;
810+ MethodInfo mi = MapDefinition . MakeGenericMethod ( new [ ] { indexClass , elementClass } ) ;
797811
798812 return ( CollectionType ) mi . Invoke ( Instance . CollectionTypeFactory , new object [ ] { role , propertyRef , false } ) ;
799813 }
800814
801815 public static CollectionType GenericSortedList ( string role , string propertyRef , object comparer ,
802- System . Type indexClass , System . Type elementClass )
816+ System . Type indexClass , System . Type elementClass )
803817 {
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 } ) ;
807819
808820 return ( CollectionType ) mi . Invoke ( Instance . CollectionTypeFactory , new object [ ] { role , propertyRef , false , comparer } ) ;
809821 }
810822
811823 public static CollectionType GenericSortedDictionary ( string role , string propertyRef , object comparer ,
812- System . Type indexClass , System . Type elementClass )
824+ System . Type indexClass , System . Type elementClass )
813825 {
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 } ) ;
817827
818828 return ( CollectionType ) mi . Invoke ( Instance . CollectionTypeFactory , new object [ ] { role , propertyRef , false , comparer } ) ;
819829 }
820830
821831 public static CollectionType GenericSet ( string role , string propertyRef , System . Type elementClass )
822832 {
823- MethodInfo mi = ReflectHelper . GetGenericMethodFrom < ICollectionTypeFactory > ( "Set" , new [ ] { elementClass } ,
824- GenericCollectionSimpleSignature ) ;
833+ MethodInfo mi = SetDefinition . MakeGenericMethod ( new [ ] { elementClass } ) ;
825834
826835 return ( CollectionType ) mi . Invoke ( Instance . CollectionTypeFactory , new object [ ] { role , propertyRef , false } ) ;
827836 }
828837
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 )
831839 {
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 } ) ;
835841
836842 return ( CollectionType ) mi . Invoke ( Instance . CollectionTypeFactory , new object [ ] { role , propertyRef , false , comparer } ) ;
837843 }
838844
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 )
841846 {
842- MethodInfo mi = ReflectHelper . GetGenericMethodFrom < ICollectionTypeFactory > ( "OrderedSet" , new [ ] { elementClass } ,
843- GenericCollectionSimpleSignature ) ;
847+ MethodInfo mi = OrderedSetDefinition . MakeGenericMethod ( new [ ] { elementClass } ) ;
844848
845849 return ( CollectionType ) mi . Invoke ( Instance . CollectionTypeFactory , new object [ ] { role , propertyRef , false } ) ;
846850 }
0 commit comments