Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added two more ToString methods, reformatted

SVN: trunk@1637
  • Loading branch information...
commit 55ee6761219277fcf4a091bc89b6dc9075eb6aca 1 parent de91085
Sergey Koshcheyev authored
Showing with 52 additions and 13 deletions.
  1. +52 −13 src/NHibernate/Impl/Printer.cs
View
65 src/NHibernate/Impl/Printer.cs
@@ -2,6 +2,7 @@
using System.Collections;
using log4net;
+
using NHibernate.Engine;
using NHibernate.Metadata;
using NHibernate.Type;
@@ -22,34 +23,37 @@ public sealed class Printer
public string ToString( object entity )
{
IClassMetadata cm = _factory.GetClassMetadata( entity.GetType() );
- if( cm == null ) return entity.GetType().FullName;
+ if( cm == null )
+ {
+ return entity.GetType().FullName;
+ }
IDictionary result = new Hashtable();
-
- if ( cm.HasIdentifierProperty )
+
+ if( cm.HasIdentifierProperty )
{
result[ cm.IdentifierPropertyName ] =
cm.IdentifierType.ToString( cm.GetIdentifier( entity ), _factory );
}
-
- IType[] types = cm.PropertyTypes;
- string[] names = cm.PropertyNames;
- object[] values = cm.GetPropertyValues( entity );
-
+
+ IType[ ] types = cm.PropertyTypes;
+ string[ ] names = cm.PropertyNames;
+ object[ ] values = cm.GetPropertyValues( entity );
+
for( int i = 0; i < types.Length; i++ )
{
- result[ names[i] ] = types[i].ToString( values[i], _factory );
+ result[ names[ i ] ] = types[ i ].ToString( values[ i ], _factory );
}
-
+
return cm.MappedClass.FullName + CollectionPrinter.ToString( result );
}
public string ToString( IType[ ] types, object[ ] values )
{
IList list = new ArrayList( types.Length );
- for ( int i = 0; i < types.Length; i++ )
+ for( int i = 0; i < types.Length; i++ )
{
- if( types[i] != null )
+ if( types[ i ] != null )
{
list.Add( types[ i ].ToString( values[ i ], _factory ) );
}
@@ -57,9 +61,44 @@ public string ToString( IType[ ] types, object[ ] values )
return CollectionPrinter.ToString( list );
}
+ public string ToString( IDictionary namedTypedValues )
+ {
+ IDictionary result = new Hashtable( namedTypedValues.Count );
+
+ foreach( DictionaryEntry me in namedTypedValues )
+ {
+ TypedValue tv = ( TypedValue ) me.Value;
+ result[ me.Key ] = tv.Type.ToString( tv.Value, _factory );
+ }
+
+ return CollectionPrinter.ToString( result );
+ }
+
+ public void ToString( IEnumerator enumerator )
+ {
+ if( !log.IsDebugEnabled || !enumerator.MoveNext() )
+ {
+ return;
+ }
+
+ log.Debug( "listing entities:" );
+ int i = 0;
+
+ do
+ {
+ if( i++ > 20 )
+ {
+ log.Debug( "more......" );
+ break;
+ }
+ log.Debug( ToString( enumerator.Current ) );
+ }
+ while( enumerator.MoveNext() );
+ }
+
public Printer( ISessionFactoryImplementor factory )
{
_factory = factory;
}
}
-}
+}
Please sign in to comment.
Something went wrong with that request. Please try again.