From: Kevin W. <kev...@us...> - 2005-01-01 02:38:48
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25743 Modified Files: ArrayHelper.cs IdentityMap.cs JoinedEnumerable.cs ObjectUtils.cs Log Message: fix xml documentation and allow ReSharper to reformat Index: JoinedEnumerable.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Util/JoinedEnumerable.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** JoinedEnumerable.cs 5 Jul 2004 20:34:59 -0000 1.2 --- JoinedEnumerable.cs 1 Jan 2005 02:38:35 -0000 1.3 *************** *** 1,13 **** - using System; using System.Collections; ! namespace NHibernate.Util { /// <summary> /// Combines multiple objects implementing <see cref="IEnumerable"/> into one. /// </summary> ! public class JoinedEnumerable : IEnumerable, IEnumerator { ! private IEnumerator[] _enumerators; private int _current; --- 1,12 ---- using System.Collections; ! namespace NHibernate.Util { /// <summary> /// Combines multiple objects implementing <see cref="IEnumerable"/> into one. /// </summary> ! public class JoinedEnumerable : IEnumerable, IEnumerator { ! private IEnumerator[ ] _enumerators; private int _current; *************** *** 16,25 **** /// </summary> /// <param name="enumerables">The IEnumerables to join together.</param> ! public JoinedEnumerable(IEnumerable[] enumerables) { _enumerators = new IEnumerator[enumerables.Length]; ! for (int i=0; i<enumerables.Length; i++) { ! _enumerators[i] = enumerables[i].GetEnumerator(); } _current = 0; --- 15,24 ---- /// </summary> /// <param name="enumerables">The IEnumerables to join together.</param> ! public JoinedEnumerable( IEnumerable[ ] enumerables ) { _enumerators = new IEnumerator[enumerables.Length]; ! for( int i = 0; i < enumerables.Length; i++ ) { ! _enumerators[ i ] = enumerables[ i ].GetEnumerator(); } _current = 0; *************** *** 28,54 **** #region System.Collections.IEnumerator Members ! public bool MoveNext() { ! for ( ; _current < _enumerators.Length; _current++ ) { ! if ( _enumerators[_current].MoveNext() ) return true; } return false; } ! ! public void Reset() { ! for (int i=0; i<_enumerators.Length; i++) { ! _enumerators[i].Reset(); } } ! public object Current { ! get ! { ! return _enumerators[_current].Current; ! } } --- 27,53 ---- #region System.Collections.IEnumerator Members ! /// <summary></summary> ! public bool MoveNext() { ! for(; _current < _enumerators.Length; _current++ ) { ! if( _enumerators[ _current ].MoveNext() ) return true; } return false; } ! ! /// <summary></summary> ! public void Reset() { ! for( int i = 0; i < _enumerators.Length; i++ ) { ! _enumerators[ i ].Reset(); } } ! /// <summary></summary> ! public object Current { ! get { return _enumerators[ _current ].Current; } } *************** *** 57,62 **** #region System.Collections.IEnumerable Members ! ! public IEnumerator GetEnumerator() { Reset(); --- 56,61 ---- #region System.Collections.IEnumerable Members ! /// <summary></summary> ! public IEnumerator GetEnumerator() { Reset(); *************** *** 65,70 **** #endregion - - } ! } --- 64,67 ---- #endregion } ! } \ No newline at end of file Index: IdentityMap.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Util/IdentityMap.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** IdentityMap.cs 4 Dec 2004 22:24:17 -0000 1.14 --- IdentityMap.cs 1 Jan 2005 02:38:35 -0000 1.15 *************** *** 1,9 **** using System; using System.Collections; ! using System.Runtime.Serialization; ! namespace NHibernate.Util { - /// <summary> /// An <see cref="IDictionary" /> where keys are compared by object identity, rather than <c>equals</c>. --- 1,9 ---- using System; using System.Collections; ! using HashCodeProvider; ! using log4net; ! namespace NHibernate.Util { /// <summary> /// An <see cref="IDictionary" /> where keys are compared by object identity, rather than <c>equals</c>. *************** *** 15,19 **** /// <para> /// Do NOT use a System.Value type as the key for this Hashtable - only classes. See ! /// the <a href="http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=bds2rm%24ruc%241%40charly.heeg.de&rnum=1&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26q%3DSystem.Runtime.CompilerServices.RuntimeHelpers.GetHashCode%26sa%3DN%26tab%3Dwg">google thread</a> /// about why using System.Value is a bad thing. /// </para> --- 15,19 ---- /// <para> /// Do NOT use a System.Value type as the key for this Hashtable - only classes. See ! /// the <a href="http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=bds2rm%24ruc%241%40charly.heeg.de&rnum=1&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26q%3DSystem.Runtime.CompilerServices.RuntimeHelpers.GetHashCode%26sa%3DN%26tab%3Dwg">google thread</a> /// about why using System.Value is a bad thing. /// </para> *************** *** 26,38 **** /// </para> /// </remarks> ! [Serializable] ! public sealed class IdentityMap : IDictionary { ! private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(IdentityMap)); ! // key = IdentityKey of the passed in Key // value = object passed in ! IDictionary map; ! /// <summary> /// Create a new instance of the IdentityMap that has no --- 26,38 ---- /// </para> /// </remarks> ! [ Serializable ] ! public sealed class IdentityMap : IDictionary { ! private static readonly ILog log = LogManager.GetLogger( typeof( IdentityMap ) ); ! // key = IdentityKey of the passed in Key // value = object passed in ! private IDictionary map; ! /// <summary> /// Create a new instance of the IdentityMap that has no *************** *** 40,48 **** /// </summary> /// <returns>A new IdentityMap based on a Hashtable.</returns> ! public static IDictionary Instantiate() { ! IHashCodeProvider ihcp = new HashCodeProvider.IdentityHashCodeProvider(); ! IComparer comp = new IdentityMap.IdentityComparer(); ! return new IdentityMap(new Hashtable(ihcp, comp)); } --- 40,48 ---- /// </summary> /// <returns>A new IdentityMap based on a Hashtable.</returns> ! public static IDictionary Instantiate() { ! IHashCodeProvider ihcp = new IdentityHashCodeProvider(); ! IComparer comp = new IdentityComparer(); ! return new IdentityMap( new Hashtable( ihcp, comp ) ); } *************** *** 53,63 **** /// </summary> /// <returns>A new IdentityMap based on ListDictionary.</returns> ! public static IDictionary InstantiateSequenced() { ! IHashCodeProvider ihcp = new HashCodeProvider.IdentityHashCodeProvider(); ! IComparer comp = new IdentityMap.IdentityComparer(); ! return new IdentityMap(new SequencedHashMap(ihcp, comp)); } ! /// <summary> /// Return the Dictionary Entries (as instances of <c>DictionaryEntry</c> in a collection --- 53,63 ---- /// </summary> /// <returns>A new IdentityMap based on ListDictionary.</returns> ! public static IDictionary InstantiateSequenced() { ! IHashCodeProvider ihcp = new IdentityHashCodeProvider(); ! IComparer comp = new IdentityComparer(); ! return new IdentityMap( new SequencedHashMap( ihcp, comp ) ); } ! /// <summary> /// Return the Dictionary Entries (as instances of <c>DictionaryEntry</c> in a collection *************** *** 67,73 **** /// <param name="map">The IDictionary to get the enumeration safe list.</param> /// <returns>A Collection of DictionaryEntries</returns> ! public static ICollection ConcurrentEntries(IDictionary map) { ! return ((IdentityMap)map).EntryList; } --- 67,73 ---- /// <param name="map">The IDictionary to get the enumeration safe list.</param> /// <returns>A Collection of DictionaryEntries</returns> ! public static ICollection ConcurrentEntries( IDictionary map ) { ! return ( ( IdentityMap ) map ).EntryList; } *************** *** 78,82 **** /// </summary> /// <param name="underlyingMap">A class that implements the IDictionary for storing the objects.</param> ! private IdentityMap(IDictionary underlyingMap) { this.map = underlyingMap; --- 78,82 ---- /// </summary> /// <param name="underlyingMap">A class that implements the IDictionary for storing the objects.</param> ! private IdentityMap( IDictionary underlyingMap ) { this.map = underlyingMap; *************** *** 86,90 **** /// <see cref="ICollection.Count"/> /// </summary> ! public int Count { get { return map.Count; } --- 86,90 ---- /// <see cref="ICollection.Count"/> /// </summary> ! public int Count { get { return map.Count; } *************** *** 94,98 **** /// <see cref="ICollection.IsSynchronized"/> /// </summary> ! public bool IsSynchronized { get { return map.IsSynchronized; } --- 94,98 ---- /// <see cref="ICollection.IsSynchronized"/> /// </summary> ! public bool IsSynchronized { get { return map.IsSynchronized; } *************** *** 102,106 **** /// <see cref="ICollection.SyncRoot"/> /// </summary> ! public object SyncRoot { get { return map.SyncRoot; } --- 102,106 ---- /// <see cref="ICollection.SyncRoot"/> /// </summary> ! public object SyncRoot { get { return map.SyncRoot; } *************** *** 110,116 **** /// <see cref="IDictionary.Add"/> /// </summary> ! public void Add(object key, object val) { ! map.Add(VerifyValidKey(key), val); } --- 110,116 ---- /// <see cref="IDictionary.Add"/> /// </summary> ! public void Add( object key, object val ) { ! map.Add( VerifyValidKey( key ), val ); } *************** *** 118,122 **** /// <see cref="IDictionary.Clear"/> /// </summary> ! public void Clear() { map.Clear(); --- 118,122 ---- /// <see cref="IDictionary.Clear"/> /// </summary> ! public void Clear() { map.Clear(); *************** *** 126,139 **** /// <see cref="IDictionary.Contains"/> /// </summary> ! public bool Contains(object key) { ! if(key==null) return false; ! return map.Contains(VerifyValidKey(key)); } /// <summary> ! /// <see cref="ICollection.GetEnumerator"/> /// </summary> ! IEnumerator IEnumerable.GetEnumerator() { return map.GetEnumerator(); --- 126,139 ---- /// <see cref="IDictionary.Contains"/> /// </summary> ! public bool Contains( object key ) { ! if( key == null ) return false; ! return map.Contains( VerifyValidKey( key ) ); } /// <summary> ! /// <see cref="IEnumerable.GetEnumerator"/> /// </summary> ! IEnumerator IEnumerable.GetEnumerator() { return map.GetEnumerator(); *************** *** 143,147 **** /// <see cref="IDictionary.GetEnumerator"/> /// </summary> ! public IDictionaryEnumerator GetEnumerator() { return map.GetEnumerator(); --- 143,147 ---- /// <see cref="IDictionary.GetEnumerator"/> /// </summary> ! public IDictionaryEnumerator GetEnumerator() { return map.GetEnumerator(); *************** *** 151,155 **** /// <see cref="IDictionary.IsFixedSize"/> /// </summary> ! public bool IsFixedSize { get { return map.IsFixedSize; } --- 151,155 ---- /// <see cref="IDictionary.IsFixedSize"/> /// </summary> ! public bool IsFixedSize { get { return map.IsFixedSize; } *************** *** 159,163 **** /// <see cref="IDictionary.IsReadOnly"/> /// </summary> ! public bool IsReadOnly { get { return map.IsReadOnly; } --- 159,163 ---- /// <see cref="IDictionary.IsReadOnly"/> /// </summary> ! public bool IsReadOnly { get { return map.IsReadOnly; } *************** *** 168,177 **** /// <see cref="IDictionary.IsReadOnly"/> /// </summary> ! public ICollection Keys { ! get ! { ! return map.Keys; ! } } --- 168,174 ---- /// <see cref="IDictionary.IsReadOnly"/> /// </summary> ! public ICollection Keys { ! get { return map.Keys; } } *************** *** 179,202 **** /// <see cref="IDictionary.Remove"/> /// </summary> ! public void Remove(object key) { ! if(key==null) return; ! map.Remove(VerifyValidKey(key)); } /// <summary> ! /// <see cref="IDictionary.Item"/> /// </summary> ! public object this [object key] { ! get ! { ! if(key==null) return null; ! return map[VerifyValidKey(key)]; ! } ! set { ! map[VerifyValidKey(key)] = value; } } --- 176,196 ---- /// <see cref="IDictionary.Remove"/> /// </summary> ! public void Remove( object key ) { ! if( key == null ) return; ! map.Remove( VerifyValidKey( key ) ); } /// <summary> ! /// <see cref="IDictionary.this"/> /// </summary> ! public object this[ object key ] { ! get { ! if( key == null ) return null; ! return map[ VerifyValidKey( key ) ]; } + set { map[ VerifyValidKey( key ) ] = value; } } *************** *** 204,222 **** /// <see cref="IDictionary.Values"/> /// </summary> ! public ICollection Values { get { return map.Values; } } - /// <summary> /// <see cref="ICollection.CopyTo"/> /// </summary> ! public void CopyTo(Array array, int i) { ! map.CopyTo(array, i); } ! /// <summary> /// Provides a snapshot VIEW in the form of a List of the contents of the IdentityMap. --- 198,217 ---- /// <see cref="IDictionary.Values"/> /// </summary> ! public ICollection Values { get { return map.Values; } } /// <summary> /// <see cref="ICollection.CopyTo"/> /// </summary> ! /// <param name="array"></param> ! /// <param name="i"></param> ! public void CopyTo( Array array, int i ) { ! map.CopyTo( array, i ); } ! /// <summary> /// Provides a snapshot VIEW in the form of a List of the contents of the IdentityMap. *************** *** 226,238 **** /// Contains a copy (not that actual instance stored) of the DictionaryEntries in a List. /// </summary> ! public IList EntryList { ! get { ! IList list = new ArrayList(map.Count); ! foreach(DictionaryEntry de in map) { ! DictionaryEntry newEntry = new DictionaryEntry(de.Key, de.Value); ! list.Add(newEntry); } --- 221,233 ---- /// Contains a copy (not that actual instance stored) of the DictionaryEntries in a List. /// </summary> ! public IList EntryList { ! get { ! IList list = new ArrayList( map.Count ); ! foreach( DictionaryEntry de in map ) { ! DictionaryEntry newEntry = new DictionaryEntry( de.Key, de.Value ); ! list.Add( newEntry ); } *************** *** 247,263 **** /// <returns>An object that is safe to be a key.</returns> /// <exception cref="ArgumentException">Thrown when the obj is a System.ValueType</exception> ! private object VerifyValidKey(object obj) { ! if(obj is System.ValueType) { throw new ArgumentException( ! "There is a problem with your mappings. You are probably trying to map a System.ValueType to " + ! "a <class> which NHibernate does not allow or you are incorrectly using the " + ! "IDictionary that is mapped to a <set>. \n\n" + ! "A ValueType can not be used with IdentityKey. " + ! "The thread at google has a good description about what happens with boxing " + ! "and unboxing ValueTypes and why they can not be used as an IdentityKey: " + ! "http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=bds2rm%24ruc%241%40charly.heeg.de&rnum=1&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26q%3DSystem.Runtime.CompilerServices.RuntimeHelpers.GetHashCode%26sa%3DN%26tab%3Dwg" ! ,"key"); } --- 242,258 ---- /// <returns>An object that is safe to be a key.</returns> /// <exception cref="ArgumentException">Thrown when the obj is a System.ValueType</exception> ! private object VerifyValidKey( object obj ) { ! if( obj is ValueType ) { throw new ArgumentException( ! "There is a problem with your mappings. You are probably trying to map a System.ValueType to " + ! "a <class> which NHibernate does not allow or you are incorrectly using the " + ! "IDictionary that is mapped to a <set>. \n\n" + ! "A ValueType can not be used with IdentityKey. " + ! "The thread at google has a good description about what happens with boxing " + ! "and unboxing ValueTypes and why they can not be used as an IdentityKey: " + ! "http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=bds2rm%24ruc%241%40charly.heeg.de&rnum=1&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26q%3DSystem.Runtime.CompilerServices.RuntimeHelpers.GetHashCode%26sa%3DN%26tab%3Dwg" ! , "key" ); } *************** *** 272,276 **** /// Only for use in IdentityMap. /// </remarks> ! [Serializable] private class IdentityComparer : IComparer { --- 267,271 ---- /// Only for use in IdentityMap. /// </remarks> ! [ Serializable ] private class IdentityComparer : IComparer { *************** *** 294,314 **** /// indicate the two are not Equal. /// </returns> ! public int Compare(object x, object y) { ! if(x==null && y==null) { return 0; } ! if(x==null || y==null) { return -1; } ! if(x==y) ! { return 0; } ! else { return -1; --- 289,309 ---- /// indicate the two are not Equal. /// </returns> ! public int Compare( object x, object y ) { ! if( x == null && y == null ) { return 0; } ! if( x == null || y == null ) { return -1; } ! if( x == y ) ! { return 0; } ! else { return -1; *************** *** 320,322 **** } ! } --- 315,317 ---- } ! } \ No newline at end of file Index: ArrayHelper.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Util/ArrayHelper.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ArrayHelper.cs 10 Feb 2004 18:42:01 -0000 1.3 --- ArrayHelper.cs 1 Jan 2005 02:38:35 -0000 1.4 *************** *** 1,13 **** using System; - using System.Data; using System.Collections; ! using NHibernate.SqlTypes; ! namespace NHibernate.Util { ! ! public sealed class ArrayHelper { ! private ArrayHelper() {} ! /// <summary> /// Compares two byte[] arrays for equality. --- 1,16 ---- using System; using System.Collections; ! using System.Data; using NHibernate.SqlTypes; ! namespace NHibernate.Util ! { ! /// <summary></summary> ! public sealed class ArrayHelper ! { ! private ArrayHelper() ! { ! } ! /// <summary> /// Compares two byte[] arrays for equality. *************** *** 16,36 **** /// <param name="rhs">The byte[] array on the Right Hand Side</param> /// <returns>true if they contain the same items</returns> ! public static bool Equals(byte[] lhs, byte[] rhs) { // just for luck, check for reference equality ! if(lhs==rhs) return true; // if they don't have the same reference and one of them // is null, then they are not Equal ! if(lhs==null || rhs==null) return false; // if they don't have the same length they are not equal ! if(lhs.Length != rhs.Length) return false; // move through every object in the array and hope that it // implements the Equals method correctly ! for(int i = 0; i < lhs.Length; i++) { ! if(lhs[i].Equals(rhs[i])==false) return false; } --- 19,39 ---- /// <param name="rhs">The byte[] array on the Right Hand Side</param> /// <returns>true if they contain the same items</returns> ! public static bool Equals( byte[ ] lhs, byte[ ] rhs ) { // just for luck, check for reference equality ! if( lhs == rhs ) return true; // if they don't have the same reference and one of them // is null, then they are not Equal ! if( lhs == null || rhs == null ) return false; // if they don't have the same length they are not equal ! if( lhs.Length != rhs.Length ) return false; // move through every object in the array and hope that it // implements the Equals method correctly ! for( int i = 0; i < lhs.Length; i++ ) { ! if( lhs[ i ].Equals( rhs[ i ] ) == false ) return false; } *************** *** 48,68 **** /// correctly. /// </remarks> ! public static bool Equals(Array lhs, Array rhs) { // just for luck, check for reference equality ! if(lhs==rhs) return true; // if they don't have the same reference and one of them // is null, then they are not Equal ! if(lhs==null || rhs==null) return false; // if they don't have the same length they are not equal ! if(lhs.Length != rhs.Length) return false; // move through every object in the array and hope that it // implements the Equals method correctly ! for(int i = 0; i < lhs.Length; i++) { ! if(lhs.GetValue(i).Equals(rhs.GetValue(i))==false) return false; } --- 51,71 ---- /// correctly. /// </remarks> ! public static bool Equals( Array lhs, Array rhs ) { // just for luck, check for reference equality ! if( lhs == rhs ) return true; // if they don't have the same reference and one of them // is null, then they are not Equal ! if( lhs == null || rhs == null ) return false; // if they don't have the same length they are not equal ! if( lhs.Length != rhs.Length ) return false; // move through every object in the array and hope that it // implements the Equals method correctly ! for( int i = 0; i < lhs.Length; i++ ) { ! if( lhs.GetValue( i ).Equals( rhs.GetValue( i ) ) == false ) return false; } *************** *** 71,146 **** } ! public static string[] ToStringArray(object[] objects) { int length = objects.Length; ! string[] result = new string[length]; ! for (int i=0; i<length; i++) { ! result[i] = objects[i].ToString(); } return result; } ! public static string[] FillArray(string str, int length) { ! string[] result = new string[length]; ! for (int i=0; i<length; i++) { ! result[i] = str; } return result; } ! public static string[] ToStringArray(ICollection coll) { ! string[] result = new string[coll.Count]; ! int i=0; ! foreach(object obj in coll) { ! result[i++] = obj.ToString(); } return result; } ! public static int[] ToIntArray(ICollection coll) { ! int[] result = new int[coll.Count]; ! int i=0; ! foreach(object obj in coll) { ! result[i++] = int.Parse(obj.ToString()); } return result; } ! public static string[] Slice(string[] strings, int begin, int length) { ! string[] result = new string[length]; ! for (int i=0; i<length; i++) { ! result[i] = strings[begin+i]; } return result; } ! public static object[] Slice(object[] objects, int begin, int length) { ! object[] result = new object[length]; ! for (int i=0; i<length; i++) { ! result[i] = objects[begin+i]; } return result; } ! public static string[] Join(string[] x, string[] y) { ! string[] result = new string[x.Length + y.Length]; ! for(int i=0; i<x.Length; i++) ! result[i] = x[i]; ! for(int i=0; i<y.Length; i++) ! result[i+x.Length] = y[i]; return result; } ! public static DbType[] Join(DbType[] x, DbType[] y) { ! DbType[] result = new DbType[ x.Length + y.Length ]; ! for ( int i=0; i<x.Length; i++ ) result[i] = x[i]; ! for ( int i=0; i<y.Length; i++ ) result[i+x.Length] = y[i]; ! return result; } ! public static SqlType[] Join(SqlType[] x, SqlType[] y) { ! SqlType[] result = new SqlType[ x.Length + y.Length ]; ! for ( int i=0; i<x.Length; i++ ) result[i] = x[i]; ! for ( int i=0; i<y.Length; i++ ) result[i+x.Length] = y[i]; ! return result; } } ! } --- 74,218 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="objects"></param> ! /// <returns></returns> ! public static string[ ] ToStringArray( object[ ] objects ) ! { int length = objects.Length; ! string[ ] result = new string[length]; ! for( int i = 0; i < length; i++ ) ! { ! result[ i ] = objects[ i ].ToString(); } return result; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="str"></param> ! /// <param name="length"></param> ! /// <returns></returns> ! public static string[ ] FillArray( string str, int length ) ! { ! string[ ] result = new string[length]; ! for( int i = 0; i < length; i++ ) ! { ! result[ i ] = str; } return result; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="coll"></param> ! /// <returns></returns> ! public static string[ ] ToStringArray( ICollection coll ) ! { ! string[ ] result = new string[coll.Count]; ! int i = 0; ! foreach( object obj in coll ) ! { ! result[ i++ ] = obj.ToString(); } return result; } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="coll"></param> ! /// <returns></returns> ! public static int[ ] ToIntArray( ICollection coll ) ! { ! int[ ] result = new int[coll.Count]; ! int i = 0; ! foreach( object obj in coll ) ! { ! result[ i++ ] = int.Parse( obj.ToString() ); } return result; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="strings"></param> ! /// <param name="begin"></param> ! /// <param name="length"></param> ! /// <returns></returns> ! public static string[ ] Slice( string[ ] strings, int begin, int length ) ! { ! string[ ] result = new string[length]; ! for( int i = 0; i < length; i++ ) ! { ! result[ i ] = strings[ begin + i ]; } return result; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="objects"></param> ! /// <param name="begin"></param> ! /// <param name="length"></param> ! /// <returns></returns> ! public static object[ ] Slice( object[ ] objects, int begin, int length ) ! { ! object[ ] result = new object[length]; ! for( int i = 0; i < length; i++ ) ! { ! result[ i ] = objects[ begin + i ]; } return result; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="x"></param> ! /// <param name="y"></param> ! /// <returns></returns> ! public static string[ ] Join( string[ ] x, string[ ] y ) ! { ! string[ ] result = new string[x.Length + y.Length]; ! for( int i = 0; i < x.Length; i++ ) ! result[ i ] = x[ i ]; ! for( int i = 0; i < y.Length; i++ ) ! result[ i + x.Length ] = y[ i ]; return result; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="x"></param> ! /// <param name="y"></param> ! /// <returns></returns> ! public static DbType[ ] Join( DbType[ ] x, DbType[ ] y ) ! { ! DbType[ ] result = new DbType[x.Length + y.Length]; ! for( int i = 0; i < x.Length; i++ ) result[ i ] = x[ i ]; ! for( int i = 0; i < y.Length; i++ ) result[ i + x.Length ] = y[ i ]; ! return result; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="x"></param> ! /// <param name="y"></param> ! /// <returns></returns> ! public static SqlType[ ] Join( SqlType[ ] x, SqlType[ ] y ) ! { ! SqlType[ ] result = new SqlType[x.Length + y.Length]; ! for( int i = 0; i < x.Length; i++ ) result[ i ] = x[ i ]; ! for( int i = 0; i < y.Length; i++ ) result[ i + x.Length ] = y[ i ]; ! return result; } } ! } \ No newline at end of file Index: ObjectUtils.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Util/ObjectUtils.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ObjectUtils.cs 22 Nov 2004 03:52:18 -0000 1.3 --- ObjectUtils.cs 1 Jan 2005 02:38:35 -0000 1.4 *************** *** 54,101 **** ! using System; ! namespace NHibernate.Util { /// <summary> /// Summary description for ObjectUtils. /// </summary> ! public sealed class ObjectUtils { ! ! private ObjectUtils() { // not creatable } ! ! public static object DefaultIfNull(object obj, object defaultVal) { ! return (obj != null ? obj : defaultVal); } ! public static new bool Equals(object obj1, object obj2) { ! if (obj1 == obj2) { return true; } ! if ( (obj1 == null) || (obj2 == null)) { return false; } ! return obj1.Equals(obj2); } ! public static string IdentityToString(object obj) { ! if (obj == null) { return null; } ! return new System.Text.StringBuilder() ! .Append(obj.GetType().FullName) ! .Append('@') ! .Append(obj.GetHashCode()) .ToString(); } - private class NullClass { } private static object theNull = new NullClass(); ! public static object Null { get { return theNull; } } } ! } --- 54,130 ---- ! using System.Text; ! namespace NHibernate.Util { /// <summary> /// Summary description for ObjectUtils. /// </summary> ! public sealed class ObjectUtils { ! private ObjectUtils() { // not creatable } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="obj"></param> ! /// <param name="defaultVal"></param> ! /// <returns></returns> ! public static object DefaultIfNull( object obj, object defaultVal ) ! { ! return ( obj != null ? obj : defaultVal ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="obj1"></param> ! /// <param name="obj2"></param> ! /// <returns></returns> ! new public static bool Equals( object obj1, object obj2 ) ! { ! if( obj1 == obj2 ) ! { return true; } ! if( ( obj1 == null ) || ( obj2 == null ) ) ! { return false; } ! return obj1.Equals( obj2 ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="obj"></param> ! /// <returns></returns> ! public static string IdentityToString( object obj ) ! { ! if( obj == null ) ! { return null; } ! return new StringBuilder() ! .Append( obj.GetType().FullName ) ! .Append( '@' ) ! .Append( obj.GetHashCode() ) .ToString(); } + private class NullClass + { + } private static object theNull = new NullClass(); ! ! /// <summary></summary> ! public static object Null ! { ! get { return theNull; } ! } } ! } \ No newline at end of file |