|
From: <fab...@us...> - 2009-06-11 21:49:58
|
Revision: 4457
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4457&view=rev
Author: fabiomaulo
Date: 2009-06-11 21:49:52 +0000 (Thu, 11 Jun 2009)
Log Message:
-----------
One more step for injectable ICollectionTypeFactory
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Bytecode/AbstractBytecodeProvider.cs
trunk/nhibernate/src/NHibernate/Bytecode/IBytecodeProvider.cs
trunk/nhibernate/src/NHibernate/Bytecode/IObjectsFactory.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Bytecode/ICollectionTypeFactory.cs
trunk/nhibernate/src/NHibernate/Type/DefaultCollectionTypeFactory.cs
Removed Paths:
-------------
trunk/nhibernate/src/NHibernate/Type/CollectionTypeFactory.cs
trunk/nhibernate/src/NHibernate/Type/ICollectionTypeFactory.cs
Modified: trunk/nhibernate/src/NHibernate/Bytecode/AbstractBytecodeProvider.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Bytecode/AbstractBytecodeProvider.cs 2009-06-11 19:17:20 UTC (rev 4456)
+++ trunk/nhibernate/src/NHibernate/Bytecode/AbstractBytecodeProvider.cs 2009-06-11 21:49:52 UTC (rev 4457)
@@ -8,6 +8,7 @@
{
private readonly IObjectsFactory objectsFactory = new ActivatorObjectsFactory();
protected System.Type proxyFactoryFactory;
+ private ICollectionTypeFactory collectionTypeFactory;
#region IBytecodeProvider Members
@@ -38,6 +39,34 @@
get { return objectsFactory; }
}
+ public ICollectionTypeFactory CollectionTypeFactory
+ {
+ get
+ {
+ if (collectionTypeFactory == null)
+ {
+ try
+ {
+ collectionTypeFactory =
+ (ICollectionTypeFactory) ObjectsFactory.CreateInstance(typeof (Type.DefaultCollectionTypeFactory));
+ }
+ catch (Exception e)
+ {
+ throw new HibernateByteCodeException("Failed to create an instance of CollectionTypeFactory!", e);
+ }
+ }
+ return collectionTypeFactory;
+ }
+ protected set
+ {
+ if(value == null)
+ {
+ throw new InvalidOperationException("The CollectionTypeFactory can't be null.");
+ }
+ collectionTypeFactory = value;
+ }
+ }
+
#endregion
#region IInjectableProxyFactoryFactory Members
Modified: trunk/nhibernate/src/NHibernate/Bytecode/IBytecodeProvider.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Bytecode/IBytecodeProvider.cs 2009-06-11 19:17:20 UTC (rev 4456)
+++ trunk/nhibernate/src/NHibernate/Bytecode/IBytecodeProvider.cs 2009-06-11 21:49:52 UTC (rev 4457)
@@ -20,8 +20,19 @@
/// <returns>The reflection optimization delegate.</returns>
IReflectionOptimizer GetReflectionOptimizer(System.Type clazz, IGetter[] getters, ISetter[] setters);
+ /// <summary>
+ /// NHibernate's object instaciator.
+ /// </summary>
+ /// <remarks>
+ /// For entities <see cref="IReflectionOptimizer"/> and its implementations.
+ /// </remarks>
IObjectsFactory ObjectsFactory { get; }
+ /// <summary>
+ /// Instanciator of NHibernate's collections default types.
+ /// </summary>
+ ICollectionTypeFactory CollectionTypeFactory { get; }
+
// <summary> Generate a ClassTransformer capable of performing bytecode manipulation. </summary>
// <param name="classFilter">
// filter used to limit which classes are to be instrumented via this ClassTransformer.
Copied: trunk/nhibernate/src/NHibernate/Bytecode/ICollectionTypeFactory.cs (from rev 4455, trunk/nhibernate/src/NHibernate/Type/ICollectionTypeFactory.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate/Bytecode/ICollectionTypeFactory.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Bytecode/ICollectionTypeFactory.cs 2009-06-11 21:49:52 UTC (rev 4457)
@@ -0,0 +1,250 @@
+using System.Collections;
+using System.Collections.Generic;
+using NHibernate.Type;
+
+namespace NHibernate.Bytecode
+{
+ /// <summary>
+ /// Type factory for collections types.
+ /// </summary>
+ public interface ICollectionTypeFactory
+ {
+ /// <summary>
+ /// Creates a new <see cref="CollectionType"/> for an <see cref="System.Array"/>.
+ /// </summary>
+ /// <param name="role">The role the collection is in.</param>
+ /// <param name="propertyRef">The name of the property in the
+ /// owner object containing the collection ID, or <see langword="null" /> if it is
+ /// the primary key.</param>
+ /// <param name="elementClass">The <see cref="System.Type"/> to use to create the array.</param>
+ /// <param name="embedded">Is embedded in XML (not supported yet)</param>
+ /// <returns>
+ /// An <see cref="ArrayType"/> for the specified role.
+ /// </returns>
+ CollectionType Array(string role, string propertyRef, bool embedded, System.Type elementClass);
+
+ /// <summary>
+ /// Creates a new <see cref="CollectionType"/> for an <see cref="IList"/>
+ /// with bag semantics.
+ /// </summary>
+ /// <param name="role">The role the collection is in.</param>
+ /// <param name="propertyRef">The name of the property in the
+ /// owner object containing the collection ID, or <see langword="null" /> if it is
+ /// the primary key.</param>
+ /// <param name="embedded">Is embedded in XML (not supported yet)</param>
+ /// <returns>
+ /// A <see cref="BagType"/> for the specified role.
+ /// </returns>
+ CollectionType Bag(string role, string propertyRef, bool embedded);
+
+ /// <summary>
+ /// Creates a new <see cref="CollectionType"/> for an
+ /// <see cref="System.Collections.Generic.IList{T}"/> with bag semantics.
+ /// </summary>
+ /// <typeparam name="T">The type of elements in the list.</typeparam>
+ /// <param name="role">The role the collection is in.</param>
+ /// <param name="propertyRef">
+ /// The name of the property in the owner object containing the collection ID,
+ /// or <see langword="null" /> if it is the primary key.
+ /// </param>
+ /// <param name="embedded">Is embedded in XML (not supported yet)</param>
+ /// <returns>
+ /// A <see cref="GenericBagType{T}"/> for the specified role.
+ /// </returns>
+ CollectionType Bag<T>(string role, string propertyRef, bool embedded);
+
+ /// <summary>
+ /// Creates a new <see cref="CollectionType"/> for an <see cref="IList"/>.
+ /// </summary>
+ /// <param name="role">The role the collection is in.</param>
+ /// <param name="propertyRef">The name of the property in the
+ /// owner object containing the collection ID, or <see langword="null" /> if it is
+ /// the primary key.</param>
+ /// <param name="embedded">Is embedded in XML (not supported yet)</param>
+ /// <returns>
+ /// A <see cref="ListType"/> for the specified role.
+ /// </returns>
+ CollectionType List(string role, string propertyRef, bool embedded);
+
+ /// <summary>
+ /// Creates a new <see cref="CollectionType"/> for an
+ /// <see cref="System.Collections.Generic.IList<T>"/> with list
+ /// semantics.
+ /// </summary>
+ /// <typeparam name="T">The type of elements in the list.</typeparam>
+ /// <param name="role">The role the collection is in.</param>
+ /// <param name="propertyRef">
+ /// The name of the property in the
+ /// owner object containing the collection ID, or <see langword="null" /> if it is
+ /// the primary key.
+ /// </param>
+ /// <param name="embedded">Is embedded in XML (not supported yet)</param>
+ /// <returns>
+ /// A <see cref="ListType"/> for the specified role.
+ /// </returns>
+ CollectionType List<T>(string role, string propertyRef, bool embedded);
+
+ /// <summary>
+ /// Creates a new <see cref="CollectionType"/> for an <see cref="IList"/>
+ /// with id-bag semantics.
+ /// </summary>
+ /// <param name="role">The role the collection is in.</param>
+ /// <param name="propertyRef">The name of the property in the
+ /// owner object containing the collection ID, or <see langword="null" /> if it is
+ /// the primary key.</param>
+ /// <param name="embedded">Is embedded in XML (not supported yet)</param>
+ /// <returns>
+ /// A <see cref="IdentifierBagType"/> for the specified role.
+ /// </returns>
+ CollectionType IdBag(string role, string propertyRef, bool embedded);
+
+ /// <summary>
+ /// Creates a new <see cref="CollectionType"/> for an
+ /// <see cref="System.Collections.Generic.IList{T}"/> with identifier
+ /// bag semantics.
+ /// </summary>
+ /// <typeparam name="T">The type of elements in the list.</typeparam>
+ /// <param name="role">The role the collection is in.</param>
+ /// <param name="propertyRef">The name of the property in the
+ /// owner object containing the collection ID, or <see langword="null" /> if it is
+ /// the primary key.
+ /// </param>
+ /// <param name="embedded">Is embedded in XML (not supported yet)</param>
+ /// <returns>
+ /// A <see cref="GenericIdentifierBagType{T}"/> for the specified role.
+ /// </returns>
+ CollectionType IdBag<T>(string role, string propertyRef, bool embedded);
+
+ /// <summary>
+ /// Creates a new <see cref="CollectionType"/> for an <see cref="Iesi.Collections.ISet"/>.
+ /// </summary>
+ /// <param name="role">The role the collection is in.</param>
+ /// <param name="propertyRef">The name of the property in the
+ /// owner object containing the collection ID, or <see langword="null" /> if it is
+ /// the primary key.</param>
+ /// <param name="embedded">Is embedded in XML (not supported yet)</param>
+ /// <returns>
+ /// A <see cref="SetType"/> for the specified role.
+ /// </returns>
+ CollectionType Set(string role, string propertyRef, bool embedded);
+
+ CollectionType OrderedSet(string role, string propertyRef, bool embedded);
+
+ /// <summary>
+ /// Creates a new <see cref="CollectionType"/> for an <see cref="Iesi.Collections.ISet"/>
+ /// that is sorted by an <see cref="IComparer"/>.
+ /// </summary>
+ /// <param name="role">The role the collection is in.</param>
+ /// <param name="propertyRef">The name of the property in the
+ /// owner object containing the collection ID, or <see langword="null" /> if it is
+ /// the primary key.</param>
+ /// <param name="comparer">The <see cref="IComparer"/> that does the sorting.</param>
+ /// <param name="embedded">Is embedded in XML (not supported yet)</param>
+ /// <returns>
+ /// A <see cref="SortedSetType"/> for the specified role.
+ /// </returns>
+ CollectionType SortedSet(string role, string propertyRef, bool embedded, IComparer comparer);
+
+ /// <summary>
+ /// Creates a new <see cref="CollectionType"/> for an <see cref="Iesi.Collections.Generic.ISet{T}" />.
+ /// </summary>
+ /// <typeparam name="T">The type of elements in the collection.</typeparam>
+ /// <param name="role">The role the collection is in.</param>
+ /// <param name="propertyRef">The name of the property in the
+ /// owner object containing the collection ID, or <see langword="null" /> if it is
+ /// the primary key.</param>
+ /// <param name="embedded">Is embedded in XML (not supported yet)</param>
+ /// <returns>A <see cref="GenericSetType{T}" /> for the specified role.</returns>
+ CollectionType Set<T>(string role, string propertyRef, bool embedded);
+
+ /// <summary>
+ /// Creates a new <see cref="CollectionType"/> for a sorted <see cref="Iesi.Collections.Generic.ISet{T}" />.
+ /// </summary>
+ /// <typeparam name="T">The type of elements in the collection.</typeparam>
+ /// <param name="role">The role the collection is in.</param>
+ /// <param name="propertyRef">The name of the property in the
+ /// owner object containing the collection ID, or <see langword="null" /> if it is
+ /// the primary key.</param>
+ /// <param name="embedded">Is embedded in XML (not supported yet)</param>
+ /// <param name="comparer">The <see cref="System.Collections.Generic.IComparer{T}" /> to use for the set.</param>
+ /// <returns>A <see cref="GenericSetType{T}" /> for the specified role.</returns>
+ CollectionType SortedSet<T>(string role, string propertyRef, bool embedded, IComparer<T> comparer);
+
+ /// <summary>
+ /// Creates a new <see cref="CollectionType"/> for an ordered <see cref="Iesi.Collections.Generic.ISet{T}" />.
+ /// </summary>
+ /// <typeparam name="T">The type of elements in the collection.</typeparam>
+ /// <param name="role">The role the collection is in.</param>
+ /// <param name="propertyRef">
+ /// The name of the property in the owner object containing the collection ID,
+ /// or <see langword="null" /> if it is the primary key.
+ /// </param>
+ /// <param name="embedded">Is embedded in XML (not supported yet)</param>
+ /// <returns>A <see cref="GenericSetType{T}" /> for the specified role.</returns>
+ CollectionType OrderedSet<T>(string role, string propertyRef, bool embedded);
+
+ /// <summary>
+ /// Creates a new <see cref="CollectionType"/> for an <see cref="IDictionary"/>.
+ /// </summary>
+ /// <param name="role">The role the collection is in.</param>
+ /// <param name="propertyRef">
+ /// The name of the property in the
+ /// owner object containing the collection ID, or <see langword="null" /> if it is
+ /// the primary key.</param>
+ /// <param name="embedded">Is embedded in XML (not supported yet)</param>
+ /// <returns>
+ /// A <see cref="MapType"/> for the specified role.
+ /// </returns>
+ CollectionType Map(string role, string propertyRef, bool embedded);
+
+ /// <summary>
+ /// Creates a new <see cref="CollectionType"/> for an <see cref="IDictionary"/>
+ /// that maintains insertion order of elements.
+ /// </summary>
+ /// <param name="role">The role the collection is in.</param>
+ /// <param name="propertyRef">The name of the property in the
+ /// owner object containing the collection ID, or <see langword="null" /> if it is
+ /// the primary key.</param>
+ /// <param name="embedded">Is embedded in XML (not supported yet)</param>
+ /// <returns>
+ /// A <see cref="OrderedMapType"/> for the specified role.
+ /// </returns>
+ CollectionType OrderedMap(string role, string propertyRef, bool embedded);
+
+ /// <summary>
+ /// Creates a new <see cref="CollectionType"/> for an <see cref="IDictionary"/>
+ /// that is sorted by an <see cref="IComparer"/>.
+ /// </summary>
+ /// <param name="role">The role the collection is in.</param>
+ /// <param name="propertyRef">The name of the property in the
+ /// owner object containing the collection ID, or <see langword="null" /> if it is
+ /// the primary key.</param>
+ /// <param name="comparer">The <see cref="IComparer"/> that does the sorting.</param>
+ /// <param name="embedded">Is embedded in XML (not supported yet)</param>
+ /// <returns>
+ /// A <see cref="SortedMapType"/> for the specified role.
+ /// </returns>
+ CollectionType SortedMap(string role, string propertyRef, bool embedded, IComparer comparer);
+
+ /// <summary>
+ /// Creates a new <see cref="CollectionType"/> for an
+ /// <see cref="System.Collections.Generic.IDictionary<TKey,TValue>"/>.
+ /// </summary>
+ /// <typeparam name="TKey">The type of keys in the dictionary.</typeparam>
+ /// <typeparam name="TValue">The type of values in the dictionary.</typeparam>
+ /// <param name="role">The role the collection is in.</param>
+ /// <param name="propertyRef">The name of the property in the
+ /// owner object containing the collection ID, or <see langword="null" /> if it is
+ /// the primary key.<
+ /// /param>
+ /// <param name="embedded">Is embedded in XML (not supported yet)</param>
+ /// <returns>
+ /// A <see cref="MapType"/> for the specified role.
+ /// </returns>
+ CollectionType Map<TKey, TValue>(string role, string propertyRef, bool embedded);
+
+
+ CollectionType SortedDictionary<TKey, TValue>(string role, string propertyRef, bool embedded, IComparer<TKey> comparer);
+ CollectionType SortedList<TKey, TValue>(string role, string propertyRef, bool embedded, IComparer<TKey> comparer);
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Bytecode/IObjectsFactory.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Bytecode/IObjectsFactory.cs 2009-06-11 19:17:20 UTC (rev 4456)
+++ trunk/nhibernate/src/NHibernate/Bytecode/IObjectsFactory.cs 2009-06-11 21:49:52 UTC (rev 4457)
@@ -1,5 +1,8 @@
namespace NHibernate.Bytecode
{
+ /// <summary>
+ /// Interface for instanciate all NHibernate objects.
+ /// </summary>
public interface IObjectsFactory
{
/// <summary>
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-06-11 19:17:20 UTC (rev 4456)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-06-11 21:49:52 UTC (rev 4457)
@@ -603,8 +603,8 @@
<Compile Include="Tool\hbm2ddl\SchemaMetadataUpdater.cs" />
<Compile Include="Transaction\AdoNetWithDistrubtedTransactionFactory.cs" />
<Compile Include="Transform\ToListResultTransformer.cs" />
- <Compile Include="Type\CollectionTypeFactory.cs" />
- <Compile Include="Type\ICollectionTypeFactory.cs" />
+ <Compile Include="Type\DefaultCollectionTypeFactory.cs" />
+ <Compile Include="Bytecode\ICollectionTypeFactory.cs" />
<Compile Include="Util\NullableDictionary.cs" />
<Compile Include="Hql\Ast\ANTLR\Util\PathHelper.cs" />
<Compile Include="Hql\Ast\ANTLR\Util\SyntheticAndFactory.cs" />
Deleted: trunk/nhibernate/src/NHibernate/Type/CollectionTypeFactory.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/CollectionTypeFactory.cs 2009-06-11 19:17:20 UTC (rev 4456)
+++ trunk/nhibernate/src/NHibernate/Type/CollectionTypeFactory.cs 2009-06-11 21:49:52 UTC (rev 4457)
@@ -1,103 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-
-namespace NHibernate.Type
-{
- public class CollectionTypeFactory : ICollectionTypeFactory
- {
- public virtual CollectionType Array(string role, string propertyRef, bool embedded, System.Type elementClass)
- {
- return new ArrayType(role, propertyRef, elementClass, embedded);
- }
-
- public virtual CollectionType Bag(string role, string propertyRef, bool embedded)
- {
- return new BagType(role, propertyRef, embedded);
- }
-
- public virtual CollectionType Bag<T>(string role, string propertyRef, bool embedded)
- {
- return new GenericBagType<T>(role, propertyRef);
- }
-
- public virtual CollectionType List(string role, string propertyRef, bool embedded)
- {
- return new ListType(role, propertyRef, embedded);
- }
-
- public virtual CollectionType List<T>(string role, string propertyRef, bool embedded)
- {
- return new GenericListType<T>(role, propertyRef);
- }
-
- public virtual CollectionType IdBag(string role, string propertyRef, bool embedded)
- {
- return new IdentifierBagType(role, propertyRef, embedded);
- }
-
- public virtual CollectionType IdBag<T>(string role, string propertyRef, bool embedded)
- {
- return new GenericIdentifierBagType<T>(role, propertyRef);
- }
-
- public virtual CollectionType Set(string role, string propertyRef, bool embedded)
- {
- return new SetType(role, propertyRef, embedded);
- }
-
- public virtual CollectionType OrderedSet(string role, string propertyRef, bool embedded)
- {
- return new OrderedSetType(role, propertyRef, embedded);
- }
-
- public virtual CollectionType SortedSet(string role, string propertyRef, bool embedded, IComparer comparer)
- {
- return new SortedSetType(role, propertyRef, comparer, embedded);
- }
-
- public virtual CollectionType Set<T>(string role, string propertyRef, bool embedded)
- {
- return new GenericSetType<T>(role, propertyRef);
- }
-
- public virtual CollectionType SortedSet<T>(string role, string propertyRef, bool embedded, IComparer<T> comparer)
- {
- return new GenericSortedSetType<T>(role, propertyRef, comparer);
- }
-
- public virtual CollectionType OrderedSet<T>(string role, string propertyRef, bool embedded)
- {
- return new GenericOrderedSetType<T>(role, propertyRef);
- }
-
- public virtual CollectionType Map(string role, string propertyRef, bool embedded)
- {
- return new MapType(role, propertyRef, embedded);
- }
-
- public virtual CollectionType OrderedMap(string role, string propertyRef, bool embedded)
- {
- return new OrderedMapType(role, propertyRef, embedded);
- }
-
- public virtual CollectionType SortedMap(string role, string propertyRef, bool embedded, IComparer comparer)
- {
- return new SortedMapType(role, propertyRef, comparer, embedded);
- }
-
- public virtual CollectionType Map<TKey, TValue>(string role, string propertyRef, bool embedded)
- {
- return new GenericMapType<TKey, TValue>(role, propertyRef);
- }
-
- public virtual CollectionType SortedDictionary<TKey, TValue>(string role, string propertyRef, bool embedded, IComparer<TKey> comparer)
- {
- return new GenericSortedDictionaryType<TKey, TValue>(role, propertyRef, comparer);
- }
-
- public virtual CollectionType SortedList<TKey, TValue>(string role, string propertyRef, bool embedded, IComparer<TKey> comparer)
- {
- return new GenericSortedListType<TKey, TValue>(role, propertyRef, comparer);
- }
- }
-}
\ No newline at end of file
Copied: trunk/nhibernate/src/NHibernate/Type/DefaultCollectionTypeFactory.cs (from rev 4455, trunk/nhibernate/src/NHibernate/Type/CollectionTypeFactory.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/DefaultCollectionTypeFactory.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Type/DefaultCollectionTypeFactory.cs 2009-06-11 21:49:52 UTC (rev 4457)
@@ -0,0 +1,104 @@
+using System.Collections;
+using System.Collections.Generic;
+using NHibernate.Bytecode;
+
+namespace NHibernate.Type
+{
+ public class DefaultCollectionTypeFactory : ICollectionTypeFactory
+ {
+ public virtual CollectionType Array(string role, string propertyRef, bool embedded, System.Type elementClass)
+ {
+ return new ArrayType(role, propertyRef, elementClass, embedded);
+ }
+
+ public virtual CollectionType Bag(string role, string propertyRef, bool embedded)
+ {
+ return new BagType(role, propertyRef, embedded);
+ }
+
+ public virtual CollectionType Bag<T>(string role, string propertyRef, bool embedded)
+ {
+ return new GenericBagType<T>(role, propertyRef);
+ }
+
+ public virtual CollectionType List(string role, string propertyRef, bool embedded)
+ {
+ return new ListType(role, propertyRef, embedded);
+ }
+
+ public virtual CollectionType List<T>(string role, string propertyRef, bool embedded)
+ {
+ return new GenericListType<T>(role, propertyRef);
+ }
+
+ public virtual CollectionType IdBag(string role, string propertyRef, bool embedded)
+ {
+ return new IdentifierBagType(role, propertyRef, embedded);
+ }
+
+ public virtual CollectionType IdBag<T>(string role, string propertyRef, bool embedded)
+ {
+ return new GenericIdentifierBagType<T>(role, propertyRef);
+ }
+
+ public virtual CollectionType Set(string role, string propertyRef, bool embedded)
+ {
+ return new SetType(role, propertyRef, embedded);
+ }
+
+ public virtual CollectionType OrderedSet(string role, string propertyRef, bool embedded)
+ {
+ return new OrderedSetType(role, propertyRef, embedded);
+ }
+
+ public virtual CollectionType SortedSet(string role, string propertyRef, bool embedded, IComparer comparer)
+ {
+ return new SortedSetType(role, propertyRef, comparer, embedded);
+ }
+
+ public virtual CollectionType Set<T>(string role, string propertyRef, bool embedded)
+ {
+ return new GenericSetType<T>(role, propertyRef);
+ }
+
+ public virtual CollectionType SortedSet<T>(string role, string propertyRef, bool embedded, IComparer<T> comparer)
+ {
+ return new GenericSortedSetType<T>(role, propertyRef, comparer);
+ }
+
+ public virtual CollectionType OrderedSet<T>(string role, string propertyRef, bool embedded)
+ {
+ return new GenericOrderedSetType<T>(role, propertyRef);
+ }
+
+ public virtual CollectionType Map(string role, string propertyRef, bool embedded)
+ {
+ return new MapType(role, propertyRef, embedded);
+ }
+
+ public virtual CollectionType OrderedMap(string role, string propertyRef, bool embedded)
+ {
+ return new OrderedMapType(role, propertyRef, embedded);
+ }
+
+ public virtual CollectionType SortedMap(string role, string propertyRef, bool embedded, IComparer comparer)
+ {
+ return new SortedMapType(role, propertyRef, comparer, embedded);
+ }
+
+ public virtual CollectionType Map<TKey, TValue>(string role, string propertyRef, bool embedded)
+ {
+ return new GenericMapType<TKey, TValue>(role, propertyRef);
+ }
+
+ public virtual CollectionType SortedDictionary<TKey, TValue>(string role, string propertyRef, bool embedded, IComparer<TKey> comparer)
+ {
+ return new GenericSortedDictionaryType<TKey, TValue>(role, propertyRef, comparer);
+ }
+
+ public virtual CollectionType SortedList<TKey, TValue>(string role, string propertyRef, bool embedded, IComparer<TKey> comparer)
+ {
+ return new GenericSortedListType<TKey, TValue>(role, propertyRef, comparer);
+ }
+ }
+}
\ No newline at end of file
Deleted: trunk/nhibernate/src/NHibernate/Type/ICollectionTypeFactory.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/ICollectionTypeFactory.cs 2009-06-11 19:17:20 UTC (rev 4456)
+++ trunk/nhibernate/src/NHibernate/Type/ICollectionTypeFactory.cs 2009-06-11 21:49:52 UTC (rev 4457)
@@ -1,248 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-namespace NHibernate.Type
-{
- /// <summary>
- /// Type factory for collections types.
- /// </summary>
- public interface ICollectionTypeFactory
- {
- /// <summary>
- /// Creates a new <see cref="CollectionType"/> for an <see cref="System.Array"/>.
- /// </summary>
- /// <param name="role">The role the collection is in.</param>
- /// <param name="propertyRef">The name of the property in the
- /// owner object containing the collection ID, or <see langword="null" /> if it is
- /// the primary key.</param>
- /// <param name="elementClass">The <see cref="System.Type"/> to use to create the array.</param>
- /// <param name="embedded">Is embedded in XML (not supported yet)</param>
- /// <returns>
- /// An <see cref="ArrayType"/> for the specified role.
- /// </returns>
- CollectionType Array(string role, string propertyRef, bool embedded, System.Type elementClass);
-
- /// <summary>
- /// Creates a new <see cref="CollectionType"/> for an <see cref="IList"/>
- /// with bag semantics.
- /// </summary>
- /// <param name="role">The role the collection is in.</param>
- /// <param name="propertyRef">The name of the property in the
- /// owner object containing the collection ID, or <see langword="null" /> if it is
- /// the primary key.</param>
- /// <param name="embedded">Is embedded in XML (not supported yet)</param>
- /// <returns>
- /// A <see cref="BagType"/> for the specified role.
- /// </returns>
- CollectionType Bag(string role, string propertyRef, bool embedded);
-
- /// <summary>
- /// Creates a new <see cref="CollectionType"/> for an
- /// <see cref="System.Collections.Generic.IList{T}"/> with bag semantics.
- /// </summary>
- /// <typeparam name="T">The type of elements in the list.</typeparam>
- /// <param name="role">The role the collection is in.</param>
- /// <param name="propertyRef">
- /// The name of the property in the owner object containing the collection ID,
- /// or <see langword="null" /> if it is the primary key.
- /// </param>
- /// <param name="embedded">Is embedded in XML (not supported yet)</param>
- /// <returns>
- /// A <see cref="GenericBagType{T}"/> for the specified role.
- /// </returns>
- CollectionType Bag<T>(string role, string propertyRef, bool embedded);
-
- /// <summary>
- /// Creates a new <see cref="CollectionType"/> for an <see cref="IList"/>.
- /// </summary>
- /// <param name="role">The role the collection is in.</param>
- /// <param name="propertyRef">The name of the property in the
- /// owner object containing the collection ID, or <see langword="null" /> if it is
- /// the primary key.</param>
- /// <param name="embedded">Is embedded in XML (not supported yet)</param>
- /// <returns>
- /// A <see cref="ListType"/> for the specified role.
- /// </returns>
- CollectionType List(string role, string propertyRef, bool embedded);
-
- /// <summary>
- /// Creates a new <see cref="CollectionType"/> for an
- /// <see cref="System.Collections.Generic.IList<T>"/> with list
- /// semantics.
- /// </summary>
- /// <typeparam name="T">The type of elements in the list.</typeparam>
- /// <param name="role">The role the collection is in.</param>
- /// <param name="propertyRef">
- /// The name of the property in the
- /// owner object containing the collection ID, or <see langword="null" /> if it is
- /// the primary key.
- /// </param>
- /// <param name="embedded">Is embedded in XML (not supported yet)</param>
- /// <returns>
- /// A <see cref="ListType"/> for the specified role.
- /// </returns>
- CollectionType List<T>(string role, string propertyRef, bool embedded);
-
- /// <summary>
- /// Creates a new <see cref="CollectionType"/> for an <see cref="IList"/>
- /// with id-bag semantics.
- /// </summary>
- /// <param name="role">The role the collection is in.</param>
- /// <param name="propertyRef">The name of the property in the
- /// owner object containing the collection ID, or <see langword="null" /> if it is
- /// the primary key.</param>
- /// <param name="embedded">Is embedded in XML (not supported yet)</param>
- /// <returns>
- /// A <see cref="IdentifierBagType"/> for the specified role.
- /// </returns>
- CollectionType IdBag(string role, string propertyRef, bool embedded);
-
- /// <summary>
- /// Creates a new <see cref="CollectionType"/> for an
- /// <see cref="System.Collections.Generic.IList{T}"/> with identifier
- /// bag semantics.
- /// </summary>
- /// <typeparam name="T">The type of elements in the list.</typeparam>
- /// <param name="role">The role the collection is in.</param>
- /// <param name="propertyRef">The name of the property in the
- /// owner object containing the collection ID, or <see langword="null" /> if it is
- /// the primary key.
- /// </param>
- /// <param name="embedded">Is embedded in XML (not supported yet)</param>
- /// <returns>
- /// A <see cref="GenericIdentifierBagType{T}"/> for the specified role.
- /// </returns>
- CollectionType IdBag<T>(string role, string propertyRef, bool embedded);
-
- /// <summary>
- /// Creates a new <see cref="CollectionType"/> for an <see cref="Iesi.Collections.ISet"/>.
- /// </summary>
- /// <param name="role">The role the collection is in.</param>
- /// <param name="propertyRef">The name of the property in the
- /// owner object containing the collection ID, or <see langword="null" /> if it is
- /// the primary key.</param>
- /// <param name="embedded">Is embedded in XML (not supported yet)</param>
- /// <returns>
- /// A <see cref="SetType"/> for the specified role.
- /// </returns>
- CollectionType Set(string role, string propertyRef, bool embedded);
-
- CollectionType OrderedSet(string role, string propertyRef, bool embedded);
-
- /// <summary>
- /// Creates a new <see cref="CollectionType"/> for an <see cref="Iesi.Collections.ISet"/>
- /// that is sorted by an <see cref="IComparer"/>.
- /// </summary>
- /// <param name="role">The role the collection is in.</param>
- /// <param name="propertyRef">The name of the property in the
- /// owner object containing the collection ID, or <see langword="null" /> if it is
- /// the primary key.</param>
- /// <param name="comparer">The <see cref="IComparer"/> that does the sorting.</param>
- /// <param name="embedded">Is embedded in XML (not supported yet)</param>
- /// <returns>
- /// A <see cref="SortedSetType"/> for the specified role.
- /// </returns>
- CollectionType SortedSet(string role, string propertyRef, bool embedded, IComparer comparer);
-
- /// <summary>
- /// Creates a new <see cref="CollectionType"/> for an <see cref="Iesi.Collections.Generic.ISet{T}" />.
- /// </summary>
- /// <typeparam name="T">The type of elements in the collection.</typeparam>
- /// <param name="role">The role the collection is in.</param>
- /// <param name="propertyRef">The name of the property in the
- /// owner object containing the collection ID, or <see langword="null" /> if it is
- /// the primary key.</param>
- /// <param name="embedded">Is embedded in XML (not supported yet)</param>
- /// <returns>A <see cref="GenericSetType{T}" /> for the specified role.</returns>
- CollectionType Set<T>(string role, string propertyRef, bool embedded);
-
- /// <summary>
- /// Creates a new <see cref="CollectionType"/> for a sorted <see cref="Iesi.Collections.Generic.ISet{T}" />.
- /// </summary>
- /// <typeparam name="T">The type of elements in the collection.</typeparam>
- /// <param name="role">The role the collection is in.</param>
- /// <param name="propertyRef">The name of the property in the
- /// owner object containing the collection ID, or <see langword="null" /> if it is
- /// the primary key.</param>
- /// <param name="embedded">Is embedded in XML (not supported yet)</param>
- /// <param name="comparer">The <see cref="System.Collections.Generic.IComparer{T}" /> to use for the set.</param>
- /// <returns>A <see cref="GenericSetType{T}" /> for the specified role.</returns>
- CollectionType SortedSet<T>(string role, string propertyRef, bool embedded, IComparer<T> comparer);
-
- /// <summary>
- /// Creates a new <see cref="CollectionType"/> for an ordered <see cref="Iesi.Collections.Generic.ISet{T}" />.
- /// </summary>
- /// <typeparam name="T">The type of elements in the collection.</typeparam>
- /// <param name="role">The role the collection is in.</param>
- /// <param name="propertyRef">
- /// The name of the property in the owner object containing the collection ID,
- /// or <see langword="null" /> if it is the primary key.
- /// </param>
- /// <param name="embedded">Is embedded in XML (not supported yet)</param>
- /// <returns>A <see cref="GenericSetType{T}" /> for the specified role.</returns>
- CollectionType OrderedSet<T>(string role, string propertyRef, bool embedded);
-
- /// <summary>
- /// Creates a new <see cref="CollectionType"/> for an <see cref="IDictionary"/>.
- /// </summary>
- /// <param name="role">The role the collection is in.</param>
- /// <param name="propertyRef">
- /// The name of the property in the
- /// owner object containing the collection ID, or <see langword="null" /> if it is
- /// the primary key.</param>
- /// <param name="embedded">Is embedded in XML (not supported yet)</param>
- /// <returns>
- /// A <see cref="MapType"/> for the specified role.
- /// </returns>
- CollectionType Map(string role, string propertyRef, bool embedded);
-
- /// <summary>
- /// Creates a new <see cref="CollectionType"/> for an <see cref="IDictionary"/>
- /// that maintains insertion order of elements.
- /// </summary>
- /// <param name="role">The role the collection is in.</param>
- /// <param name="propertyRef">The name of the property in the
- /// owner object containing the collection ID, or <see langword="null" /> if it is
- /// the primary key.</param>
- /// <param name="embedded">Is embedded in XML (not supported yet)</param>
- /// <returns>
- /// A <see cref="OrderedMapType"/> for the specified role.
- /// </returns>
- CollectionType OrderedMap(string role, string propertyRef, bool embedded);
-
- /// <summary>
- /// Creates a new <see cref="CollectionType"/> for an <see cref="IDictionary"/>
- /// that is sorted by an <see cref="IComparer"/>.
- /// </summary>
- /// <param name="role">The role the collection is in.</param>
- /// <param name="propertyRef">The name of the property in the
- /// owner object containing the collection ID, or <see langword="null" /> if it is
- /// the primary key.</param>
- /// <param name="comparer">The <see cref="IComparer"/> that does the sorting.</param>
- /// <param name="embedded">Is embedded in XML (not supported yet)</param>
- /// <returns>
- /// A <see cref="SortedMapType"/> for the specified role.
- /// </returns>
- CollectionType SortedMap(string role, string propertyRef, bool embedded, IComparer comparer);
-
- /// <summary>
- /// Creates a new <see cref="CollectionType"/> for an
- /// <see cref="System.Collections.Generic.IDictionary<TKey,TValue>"/>.
- /// </summary>
- /// <typeparam name="TKey">The type of keys in the dictionary.</typeparam>
- /// <typeparam name="TValue">The type of values in the dictionary.</typeparam>
- /// <param name="role">The role the collection is in.</param>
- /// <param name="propertyRef">The name of the property in the
- /// owner object containing the collection ID, or <see langword="null" /> if it is
- /// the primary key.<
- /// /param>
- /// <param name="embedded">Is embedded in XML (not supported yet)</param>
- /// <returns>
- /// A <see cref="MapType"/> for the specified role.
- /// </returns>
- CollectionType Map<TKey, TValue>(string role, string propertyRef, bool embedded);
-
-
- CollectionType SortedDictionary<TKey, TValue>(string role, string propertyRef, bool embedded, IComparer<TKey> comparer);
- CollectionType SortedList<TKey, TValue>(string role, string propertyRef, bool embedded, IComparer<TKey> comparer);
- }
-}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2009-06-11 19:17:20 UTC (rev 4456)
+++ trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2009-06-11 21:49:52 UTC (rev 4457)
@@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.Globalization;
using System.Reflection;
+using NHibernate.Bytecode;
using NHibernate.Classic;
using NHibernate.Engine;
using NHibernate.Intercept;
@@ -95,10 +96,7 @@
/// <summary></summary>
static TypeFactory()
{
- Instance =
- new TypeFactory(
- (ICollectionTypeFactory)
- Cfg.Environment.BytecodeProvider.ObjectsFactory.CreateInstance(typeof (CollectionTypeFactory)));
+ Instance = new TypeFactory();
//basicTypes.Add(NHibernate.Blob.Name, NHibernate.Blob);
//basicTypes.Add(NHibernate.Clob.Name, NHibernate.Clob);
@@ -184,11 +182,16 @@
getTypeDelegatesWithPrecision.Add(NHibernateUtil.Decimal.Name, GetDecimalType);
}
- public ICollectionTypeFactory CollectionTypeFactory { get; private set; }
+ public ICollectionTypeFactory CollectionTypeFactory
+ {
+ get
+ {
+ return Cfg.Environment.BytecodeProvider.CollectionTypeFactory;
+ }
+ }
- private TypeFactory(ICollectionTypeFactory collectionTypeFactory)
+ private TypeFactory()
{
- CollectionTypeFactory = collectionTypeFactory;
}
/// <summary>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|