From: Kevin W. <kev...@us...> - 2004-12-31 18:56:07
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Id In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2135 Modified Files: Assigned.cs CounterGenerator.cs ForeignGenerator.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: CounterGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/CounterGenerator.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CounterGenerator.cs 28 Mar 2004 06:06:40 -0000 1.2 --- CounterGenerator.cs 31 Dec 2004 18:55:56 -0000 1.3 *************** *** 2,6 **** using NHibernate.Engine; ! namespace NHibernate.Id { /// <summary> --- 2,6 ---- using NHibernate.Engine; ! namespace NHibernate.Id { /// <summary> *************** *** 8,23 **** /// time and a counter value. Not safe for use in a clustser! /// </summary> ! public class CounterGenerator : IIdentifierGenerator { ! ! private static short counter = (short)0; ! protected short Count { ! get { ! lock(typeof(CounterGenerator)) { ! if (counter<0) counter=0; return counter++; } --- 8,26 ---- /// time and a counter value. Not safe for use in a clustser! /// </summary> ! public class CounterGenerator : IIdentifierGenerator { ! private static short counter = ( short ) 0; ! /// <summary></summary> ! protected short Count { ! get { ! lock( typeof( CounterGenerator ) ) { ! if( counter < 0 ) ! { ! counter = 0; ! } return counter++; } *************** *** 25,29 **** } ! public object Generate(ISessionImplementor cache, object obj) { return ( DateTime.Now.Ticks << 16 ) + Count; --- 28,38 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="cache"></param> ! /// <param name="obj"></param> ! /// <returns></returns> ! public object Generate( ISessionImplementor cache, object obj ) { return ( DateTime.Now.Ticks << 16 ) + Count; *************** *** 31,33 **** } ! } --- 40,42 ---- } ! } \ No newline at end of file Index: Assigned.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/Assigned.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Assigned.cs 28 Mar 2004 06:06:40 -0000 1.2 --- Assigned.cs 31 Dec 2004 18:55:56 -0000 1.3 *************** *** 1,7 **** - using System; - using NHibernate.Engine; using NHibernate.Collection; ! namespace NHibernate.Id { /// <summary> --- 1,6 ---- using NHibernate.Collection; + using NHibernate.Engine; ! namespace NHibernate.Id { /// <summary> *************** *** 9,31 **** /// assigned to an instance /// </summary> ! public class Assigned : IIdentifierGenerator { ! public static readonly Assigned Instance = new Assigned(); ! public object Generate(ISessionImplementor session, object obj) { ! if ( obj is PersistentCollection) throw new IdentifierGenerationException( ! "Illegal use of assigned id generation fro a toplevel collection" ! ); ! ! object id = session.GetPersister(obj).GetIdentifier(obj); ! if (id==null) throw new IdentifierGenerationException( ! "ids for this class must be manually assigned before calling save(): " + obj.GetType().FullName ! ); return id; } } ! } --- 8,40 ---- /// assigned to an instance /// </summary> ! public class Assigned : IIdentifierGenerator { ! /// <summary></summary> public static readonly Assigned Instance = new Assigned(); ! /// <summary> ! /// ! /// </summary> ! /// <param name="session"></param> ! /// <param name="obj"></param> ! /// <returns></returns> ! public object Generate( ISessionImplementor session, object obj ) { ! if( obj is PersistentCollection ) ! { throw new IdentifierGenerationException( ! "Illegal use of assigned id generation fro a toplevel collection" ! ); ! } ! ! object id = session.GetPersister( obj ).GetIdentifier( obj ); ! if( id == null ) ! { throw new IdentifierGenerationException( ! "ids for this class must be manually assigned before calling save(): " + obj.GetType().FullName ! ); ! } return id; } } ! } \ No newline at end of file Index: ForeignGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/ForeignGenerator.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ForeignGenerator.cs 21 Sep 2004 09:58:24 -0000 1.3 --- ForeignGenerator.cs 31 Dec 2004 18:55:56 -0000 1.4 *************** *** 1,5 **** - using System; using System.Collections; - using NHibernate.Engine; using NHibernate.Type; --- 1,3 ---- *************** *** 16,29 **** private string propertyName; ! public object Generate(ISessionImplementor session, object obj) { object associatedObject = session.Factory .GetClassMetadata( obj.GetType() ) ! .GetPropertyValue(obj, propertyName); //return session.getEntityIdentifierIfNotUnsaved(associatedObject); ! object id = session.Save(associatedObject); ! if ( session.Contains(obj) ) { //abort the save (the object is already saved by a circular cascade) ! return IdentifierGeneratorFactory.ShortCircuitIndicator; //throw new IdentifierGenerationException("save associated object first, or disable cascade for inverse association"); } --- 14,34 ---- private string propertyName; ! /// <summary> ! /// ! /// </summary> ! /// <param name="session"></param> ! /// <param name="obj"></param> ! /// <returns></returns> ! public object Generate( ISessionImplementor session, object obj ) { object associatedObject = session.Factory .GetClassMetadata( obj.GetType() ) ! .GetPropertyValue( obj, propertyName ); //return session.getEntityIdentifierIfNotUnsaved(associatedObject); ! object id = session.Save( associatedObject ); ! if( session.Contains( obj ) ) ! { //abort the save (the object is already saved by a circular cascade) ! return IdentifierGeneratorFactory.ShortCircuitIndicator; //throw new IdentifierGenerationException("save associated object first, or disable cascade for inverse association"); } *************** *** 31,40 **** } ! public void Configure(IType type, IDictionary parms, Dialect.Dialect d) { ! propertyName = (string)parms["property"]; ! if(propertyName==null || propertyName.Length == 0) ! throw new MappingException("param named \"property\" is required for foreign id generation strategy"); } } ! } --- 36,53 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="type"></param> ! /// <param name="parms"></param> ! /// <param name="d"></param> ! public void Configure( IType type, IDictionary parms, Dialect.Dialect d ) { ! propertyName = ( string ) parms[ "property" ]; ! if( propertyName == null || propertyName.Length == 0 ) ! { ! throw new MappingException( "param named \"property\" is required for foreign id generation strategy" ); ! } } } ! } \ No newline at end of file |