C# Class NHibernate.Type.TypeFactory

Used internally to obtain instances of IType.
Applications should use static methods and constants on NHibernate.NHibernateUtil if the default IType is good enough. For example, the TypeFactory should only be used when the String needs to have a length of 300 instead of 255. At this point NHibernateUtil.String does not get you the correct IType. Instead use TypeFactory.GetString(300) and keep a local variable that holds a reference to the IType.
Show file Open project: nhibernate/nhibernate-core Class Usage Examples

Public Methods

Method Description
Array ( string role, string propertyRef, bool embedded, System elementClass ) : NHibernate.Type.CollectionType
Basic ( string name ) : IType

Given the name of a Hibernate type such as Decimal, Decimal(19,0) , Int32, or even NHibernate.Type.DecimalType, NHibernate.Type.DecimalType(19,0), NHibernate.Type.Int32Type, then return an instance of NHibernate.Type.IType

This method will return null if the name is not found in the basicNameMap.

CustomCollection ( string typeName, string>.IDictionary typeParameters, string role, string propertyRef, bool embedded ) : NHibernate.Type.CollectionType
GenericBag ( string role, string propertyRef, System elementClass ) : NHibernate.Type.CollectionType
GenericIdBag ( string role, string propertyRef, System elementClass ) : NHibernate.Type.CollectionType
GenericList ( string role, string propertyRef, System elementClass ) : NHibernate.Type.CollectionType
GenericMap ( string role, string propertyRef, System indexClass, System elementClass ) : NHibernate.Type.CollectionType
GenericOrderedSet ( string role, string propertyRef, System elementClass ) : NHibernate.Type.CollectionType
GenericSet ( string role, string propertyRef, System elementClass ) : NHibernate.Type.CollectionType
GenericSortedDictionary ( string role, string propertyRef, object comparer, System indexClass, System elementClass ) : NHibernate.Type.CollectionType
GenericSortedList ( string role, string propertyRef, object comparer, System indexClass, System elementClass ) : NHibernate.Type.CollectionType
GenericSortedSet ( string role, string propertyRef, object comparer, System elementClass ) : NHibernate.Type.CollectionType
HeuristicType ( string typeName ) : IType

Uses heuristics to deduce a NHibernate type given a string naming the type.

When looking for the NHibernate type it will look in the cache of the Basic types first. If it doesn't find it in the cache then it uses the typeName to get a reference to the Class (Type in .NET). Once we get the reference to the .NET class we check to see if it implements IType, ICompositeUserType, IUserType, ILifecycle (Association), or IPersistentEnum. If none of those are implemented then we will serialize the Type to the database using NHibernate.Type.SerializableType(typeName)

HeuristicType ( string typeName, string>.IDictionary parameters ) : IType

Uses heuristics to deduce a NHibernate type given a string naming the type.

HeuristicType ( string typeName, string>.IDictionary parameters, int length ) : IType

Uses heuristics to deduce a NHibernate type given a string naming the type.

InjectParameters ( Object type, string>.IDictionary parameters ) : void
ManyToOne ( string persistentClass ) : EntityType

A many-to-one association type for the given class and cascade style.

ManyToOne ( string persistentClass, bool lazy ) : EntityType

A many-to-one association type for the given class and cascade style.

ManyToOne ( string persistentClass, string uniqueKeyPropertyName, bool lazy, bool unwrapProxy, bool isEmbeddedInXML, bool ignoreNotFound, bool isLogicalOneToOne ) : EntityType

A many-to-one association type for the given class and cascade style.

OneToOne ( string persistentClass, ForeignKeyDirection foreignKeyType, string uniqueKeyPropertyName, bool lazy, bool unwrapProxy, bool isEmbeddedInXML, string entityName, string propertyName ) : EntityType

A one-to-one association type for the given class and cascade style.

Private Methods

Method Description
AddToTypeOfName ( string key, IType type ) : void
AddToTypeOfNameWithLength ( string key, IType type ) : void
AddToTypeOfNameWithPrecision ( string key, IType type ) : void
BuiltInType ( string typeName, byte precision, byte scale ) : IType
BuiltInType ( string typeName, int length ) : IType
GetAnsiStringType ( int length ) : NullableType
GetBinaryType ( int length ) : NullableType
GetClrTypeAliases ( System systemType ) : IEnumerable
GetKeyForLengthBased ( string name, int length ) : string
GetKeyForPrecisionScaleBased ( string name, byte precision, byte scale ) : string
GetSerializableType ( System serializableType ) : NullableType
GetSerializableType ( System serializableType, int length ) : NullableType
GetSerializableType ( int length ) : NullableType
GetStringType ( int length ) : NullableType
GetType ( NullableType defaultUnqualifiedType, byte precision, byte scale, NullableTypeCreatorDelegate ctor ) : NullableType
GetType ( NullableType defaultUnqualifiedType, int length, GetNullableTypeWithLength ctorDelegate ) : NullableType
GetTypeClassification ( string typeName ) : TypeClassification

Gets the classification of the Type based on the string.

This parses through the string and makes the assumption that no class name and no assembly name will contain the "(".

If it finds the "(" and then finds a "," afterwards then it is a TypeClassification.PrecisionScale.

If it finds the "(" and doesn't find a "," afterwards, then it is a TypeClassification.Length.

If it doesn't find the "(" then it assumes that it is a TypeClassification.Plain.

GetTypeType ( int length ) : NullableType
RegisterBuiltInTypes ( ) : void

Register other NO Default .NET type

These type will be used only when the "type" attribute was is specified in the mapping. These are in here because needed to NO override default CLR types and be available in mappings

RegisterDefaultNetTypes ( ) : void

Register other Default .NET type

These type will be used, as default, even when the "type" attribute was NOT specified in the mapping

RegisterType ( IType nhibernateType, IEnumerable aliases ) : void
RegisterType ( IType nhibernateType, IEnumerable aliases, GetNullableTypeWithLength ctorLength ) : void
RegisterType ( IType nhibernateType, IEnumerable aliases, GetNullableTypeWithPrecision ctorPrecision ) : void
RegisterType ( System systemType, IType nhibernateType, IEnumerable aliases ) : void
RegisterType ( System systemType, IType nhibernateType, IEnumerable aliases, GetNullableTypeWithLength ctorLength ) : void
RegisterType ( System systemType, IType nhibernateType, IEnumerable aliases, GetNullableTypeWithPrecision ctorPrecision ) : void
TypeFactory ( ) : System

Method Details

Array() public static method

public static Array ( string role, string propertyRef, bool embedded, System elementClass ) : NHibernate.Type.CollectionType
role string
propertyRef string
embedded bool
elementClass System
return NHibernate.Type.CollectionType

Basic() public static method

Given the name of a Hibernate type such as Decimal, Decimal(19,0) , Int32, or even NHibernate.Type.DecimalType, NHibernate.Type.DecimalType(19,0), NHibernate.Type.Int32Type, then return an instance of NHibernate.Type.IType
This method will return null if the name is not found in the basicNameMap.
public static Basic ( string name ) : IType
name string The name of the type.
return IType

CustomCollection() public static method

public static CustomCollection ( string typeName, string>.IDictionary typeParameters, string role, string propertyRef, bool embedded ) : NHibernate.Type.CollectionType
typeName string
typeParameters string>.IDictionary
role string
propertyRef string
embedded bool
return NHibernate.Type.CollectionType

GenericBag() public static method

public static GenericBag ( string role, string propertyRef, System elementClass ) : NHibernate.Type.CollectionType
role string
propertyRef string
elementClass System
return NHibernate.Type.CollectionType

GenericIdBag() public static method

public static GenericIdBag ( string role, string propertyRef, System elementClass ) : NHibernate.Type.CollectionType
role string
propertyRef string
elementClass System
return NHibernate.Type.CollectionType

GenericList() public static method

public static GenericList ( string role, string propertyRef, System elementClass ) : NHibernate.Type.CollectionType
role string
propertyRef string
elementClass System
return NHibernate.Type.CollectionType

GenericMap() public static method

public static GenericMap ( string role, string propertyRef, System indexClass, System elementClass ) : NHibernate.Type.CollectionType
role string
propertyRef string
indexClass System
elementClass System
return NHibernate.Type.CollectionType

GenericOrderedSet() public static method

public static GenericOrderedSet ( string role, string propertyRef, System elementClass ) : NHibernate.Type.CollectionType
role string
propertyRef string
elementClass System
return NHibernate.Type.CollectionType

GenericSet() public static method

public static GenericSet ( string role, string propertyRef, System elementClass ) : NHibernate.Type.CollectionType
role string
propertyRef string
elementClass System
return NHibernate.Type.CollectionType

GenericSortedDictionary() public static method

public static GenericSortedDictionary ( string role, string propertyRef, object comparer, System indexClass, System elementClass ) : NHibernate.Type.CollectionType
role string
propertyRef string
comparer object
indexClass System
elementClass System
return NHibernate.Type.CollectionType

GenericSortedList() public static method

public static GenericSortedList ( string role, string propertyRef, object comparer, System indexClass, System elementClass ) : NHibernate.Type.CollectionType
role string
propertyRef string
comparer object
indexClass System
elementClass System
return NHibernate.Type.CollectionType

GenericSortedSet() public static method

public static GenericSortedSet ( string role, string propertyRef, object comparer, System elementClass ) : NHibernate.Type.CollectionType
role string
propertyRef string
comparer object
elementClass System
return NHibernate.Type.CollectionType

HeuristicType() public static method

Uses heuristics to deduce a NHibernate type given a string naming the type.
When looking for the NHibernate type it will look in the cache of the Basic types first. If it doesn't find it in the cache then it uses the typeName to get a reference to the Class (Type in .NET). Once we get the reference to the .NET class we check to see if it implements IType, ICompositeUserType, IUserType, ILifecycle (Association), or IPersistentEnum. If none of those are implemented then we will serialize the Type to the database using NHibernate.Type.SerializableType(typeName)
public static HeuristicType ( string typeName ) : IType
typeName string
return IType

HeuristicType() public static method

Uses heuristics to deduce a NHibernate type given a string naming the type.
public static HeuristicType ( string typeName, string>.IDictionary parameters ) : IType
typeName string the type name
parameters string>.IDictionary parameters for the type
return IType

HeuristicType() public static method

Uses heuristics to deduce a NHibernate type given a string naming the type.
public static HeuristicType ( string typeName, string>.IDictionary parameters, int length ) : IType
typeName string the type name
parameters string>.IDictionary parameters for the type
length int optionally, the size of the type
return IType

InjectParameters() public static method

public static InjectParameters ( Object type, string>.IDictionary parameters ) : void
type Object
parameters string>.IDictionary
return void

ManyToOne() public static method

A many-to-one association type for the given class and cascade style.
public static ManyToOne ( string persistentClass ) : EntityType
persistentClass string
return EntityType

ManyToOne() public static method

A many-to-one association type for the given class and cascade style.
public static ManyToOne ( string persistentClass, bool lazy ) : EntityType
persistentClass string
lazy bool
return EntityType

ManyToOne() public static method

A many-to-one association type for the given class and cascade style.
public static ManyToOne ( string persistentClass, string uniqueKeyPropertyName, bool lazy, bool unwrapProxy, bool isEmbeddedInXML, bool ignoreNotFound, bool isLogicalOneToOne ) : EntityType
persistentClass string
uniqueKeyPropertyName string
lazy bool
unwrapProxy bool
isEmbeddedInXML bool
ignoreNotFound bool
isLogicalOneToOne bool
return EntityType

OneToOne() public static method

A one-to-one association type for the given class and cascade style.
public static OneToOne ( string persistentClass, ForeignKeyDirection foreignKeyType, string uniqueKeyPropertyName, bool lazy, bool unwrapProxy, bool isEmbeddedInXML, string entityName, string propertyName ) : EntityType
persistentClass string
foreignKeyType ForeignKeyDirection
uniqueKeyPropertyName string
lazy bool
unwrapProxy bool
isEmbeddedInXML bool
entityName string
propertyName string
return EntityType