From: Kevin W. <kev...@us...> - 2004-12-31 18:57:02
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Id In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2270 Modified Files: IdentifierGenerationException.cs IdentifierGeneratorFactory.cs IdentityGenerator.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: IdentifierGeneratorFactory.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/IdentifierGeneratorFactory.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** IdentifierGeneratorFactory.cs 1 Nov 2004 16:26:04 -0000 1.12 --- IdentifierGeneratorFactory.cs 31 Dec 2004 18:56:49 -0000 1.13 *************** *** 1,100 **** using System; - using System.Data; using System.Collections; ! using NHibernate.Type; ! namespace NHibernate.Id { /// <summary> /// Factory methods for <c>IdentifierGenerator</c> framework. /// </summary> ! public sealed class IdentifierGeneratorFactory { ! public static object Get(IDataReader rs, System.Type clazz) { // here is an interesting one: // - MsSql's @@identity returns a numeric - which translates to a C# decimal type. // - MySql LAST_IDENITY() returns an Int64 ! try { ! object identityValue = rs[0]; return Convert.ChangeType( identityValue, clazz ); } ! catch( Exception e ) { ! throw new IdentifierGenerationException("this id generator generates Int64, Int32, Int16", e); } } private static readonly Hashtable idgenerators = new Hashtable(); public static readonly string ShortCircuitIndicator = String.Empty; ! static IdentifierGeneratorFactory() { ! idgenerators.Add( "uuid.hex", typeof(UUIDHexGenerator) ); ! idgenerators.Add( "uuid.string", typeof(UUIDStringGenerator) ); ! idgenerators.Add( "hilo", typeof(TableHiLoGenerator) ); ! idgenerators.Add( "assigned", typeof(Assigned) ); ! idgenerators.Add( "identity", typeof(IdentityGenerator) ); ! idgenerators.Add( "sequence", typeof(SequenceGenerator) ); ! idgenerators.Add( "seqhilo", typeof(SequenceHiLoGenerator) ); ! idgenerators.Add( "vm", typeof(CounterGenerator) ); ! idgenerators.Add( "foreign", typeof(ForeignGenerator) ); ! idgenerators.Add( "guid", typeof(GuidGenerator) ); ! idgenerators.Add( "guid.comb", typeof(GuidCombGenerator) ); } ! private IdentifierGeneratorFactory() {} //cannot be instantiated ! public static IIdentifierGenerator Create(string strategy, IType type, IDictionary parms, Dialect.Dialect dialect) { ! try { ! System.Type clazz = (System.Type) idgenerators[strategy]; ! if ( "native".Equals(strategy) ) { ! if ( dialect.SupportsIdentityColumns ) { ! clazz = typeof(IdentityGenerator); } ! else if ( dialect.SupportsSequences ) { ! clazz = typeof(SequenceGenerator); } ! else { ! clazz = typeof(TableHiLoGenerator); } } ! if (clazz==null) clazz = System.Type.GetType(strategy); ! IIdentifierGenerator idgen = (IIdentifierGenerator) Activator.CreateInstance(clazz); ! if (idgen is IConfigurable) ((IConfigurable) idgen).Configure(type, parms, dialect); return idgen; ! } ! catch (Exception e) { ! throw new MappingException("could not instantiate id generator", e); } } ! internal static object CreateNumber(long value, System.Type type) { ! if (type==typeof(long)) { return value; ! } ! else if ( type==typeof(int)) { ! return (int) value; ! } ! else if ( type==typeof(short)) { ! return (short) value; ! } ! else { ! throw new IdentifierGenerationException("this id generator generates Int64, Int32, Int16"); } } } ! } --- 1,131 ---- using System; using System.Collections; ! using System.Data; using NHibernate.Type; ! namespace NHibernate.Id { /// <summary> /// Factory methods for <c>IdentifierGenerator</c> framework. /// </summary> ! public sealed class IdentifierGeneratorFactory { ! /// <summary> ! /// ! /// </summary> ! /// <param name="rs"></param> ! /// <param name="clazz"></param> ! /// <returns></returns> ! public static object Get( IDataReader rs, System.Type clazz ) { // here is an interesting one: // - MsSql's @@identity returns a numeric - which translates to a C# decimal type. // - MySql LAST_IDENITY() returns an Int64 ! try { ! object identityValue = rs[ 0 ]; return Convert.ChangeType( identityValue, clazz ); } ! catch( Exception e ) { ! throw new IdentifierGenerationException( "this id generator generates Int64, Int32, Int16", e ); } } private static readonly Hashtable idgenerators = new Hashtable(); + + /// <summary></summary> public static readonly string ShortCircuitIndicator = String.Empty; ! /// <summary></summary> ! static IdentifierGeneratorFactory() { ! idgenerators.Add( "uuid.hex", typeof( UUIDHexGenerator ) ); ! idgenerators.Add( "uuid.string", typeof( UUIDStringGenerator ) ); ! idgenerators.Add( "hilo", typeof( TableHiLoGenerator ) ); ! idgenerators.Add( "assigned", typeof( Assigned ) ); ! idgenerators.Add( "identity", typeof( IdentityGenerator ) ); ! idgenerators.Add( "sequence", typeof( SequenceGenerator ) ); ! idgenerators.Add( "seqhilo", typeof( SequenceHiLoGenerator ) ); ! idgenerators.Add( "vm", typeof( CounterGenerator ) ); ! idgenerators.Add( "foreign", typeof( ForeignGenerator ) ); ! idgenerators.Add( "guid", typeof( GuidGenerator ) ); ! idgenerators.Add( "guid.comb", typeof( GuidCombGenerator ) ); } ! private IdentifierGeneratorFactory() ! { ! } //cannot be instantiated ! /// <summary> ! /// ! /// </summary> ! /// <param name="strategy"></param> ! /// <param name="type"></param> ! /// <param name="parms"></param> ! /// <param name="dialect"></param> ! /// <returns></returns> ! public static IIdentifierGenerator Create( string strategy, IType type, IDictionary parms, Dialect.Dialect dialect ) { ! try { ! System.Type clazz = ( System.Type ) idgenerators[ strategy ]; ! if( "native".Equals( strategy ) ) { ! if( dialect.SupportsIdentityColumns ) { ! clazz = typeof( IdentityGenerator ); } ! else if( dialect.SupportsSequences ) { ! clazz = typeof( SequenceGenerator ); } ! else { ! clazz = typeof( TableHiLoGenerator ); } } ! if( clazz == null ) ! { ! clazz = System.Type.GetType( strategy ); ! } ! IIdentifierGenerator idgen = ( IIdentifierGenerator ) Activator.CreateInstance( clazz ); ! if( idgen is IConfigurable ) ! { ! ( ( IConfigurable ) idgen ).Configure( type, parms, dialect ); ! } return idgen; ! } ! catch( Exception e ) { ! throw new MappingException( "could not instantiate id generator", e ); } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="value"></param> ! /// <param name="type"></param> ! /// <returns></returns> ! internal static object CreateNumber( long value, System.Type type ) ! { ! if( type == typeof( long ) ) { return value; ! } ! else if( type == typeof( int ) ) { ! return ( int ) value; ! } ! else if( type == typeof( short ) ) { ! return ( short ) value; ! } ! else { ! throw new IdentifierGenerationException( "this id generator generates Int64, Int32, Int16" ); } } } ! } \ No newline at end of file Index: IdentifierGenerationException.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/IdentifierGenerationException.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** IdentifierGenerationException.cs 22 Nov 2004 03:53:59 -0000 1.4 --- IdentifierGenerationException.cs 31 Dec 2004 18:56:49 -0000 1.5 *************** *** 1,5 **** using System; ! namespace NHibernate.Id { /// <summary> --- 1,5 ---- using System; ! namespace NHibernate.Id { /// <summary> *************** *** 7,15 **** /// </summary> [Serializable] ! public class IdentifierGenerationException : HibernateException { ! public IdentifierGenerationException(string message) : base(message) {} ! public IdentifierGenerationException(string message, Exception e) : base(message, e) {} } ! } --- 7,28 ---- /// </summary> [Serializable] ! public class IdentifierGenerationException : HibernateException { ! /// <summary> ! /// ! /// </summary> ! /// <param name="message"></param> ! public IdentifierGenerationException( string message ) : base( message ) ! { ! } ! /// <summary> ! /// ! /// </summary> ! /// <param name="message"></param> ! /// <param name="e"></param> ! public IdentifierGenerationException( string message, Exception e ) : base( message, e ) ! { ! } } ! } \ No newline at end of file Index: IdentityGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/IdentityGenerator.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IdentityGenerator.cs 9 Dec 2004 17:53:14 -0000 1.3 --- IdentityGenerator.cs 31 Dec 2004 18:56:49 -0000 1.4 *************** *** 1,6 **** - using System; using NHibernate.Engine; ! namespace NHibernate.Id { /// <summary> --- 1,5 ---- using NHibernate.Engine; ! namespace NHibernate.Id { /// <summary> *************** *** 18,22 **** /// </para> /// </remarks> ! public class IdentityGenerator : IIdentifierGenerator { /// <summary> --- 17,21 ---- /// </para> /// </remarks> ! public class IdentityGenerator : IIdentifierGenerator { /// <summary> *************** *** 31,38 **** /// generated id. /// </returns> ! public object Generate(ISessionImplementor s, object obj) { return null; } } ! } --- 30,37 ---- /// generated id. /// </returns> ! public object Generate( ISessionImplementor s, object obj ) { return null; } } ! } \ No newline at end of file |