From: <fab...@us...> - 2009-12-02 05:10:32
|
Revision: 4891 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4891&view=rev Author: fabiomaulo Date: 2009-12-02 05:10:21 +0000 (Wed, 02 Dec 2009) Log Message: ----------- binders refactoring - minor logging Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassCompositeIdBinder.cs trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingLogExtensions.cs Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-12-02 04:56:46 UTC (rev 4890) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-12-02 05:10:21 UTC (rev 4891) @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; using System.Xml; using NHibernate.Cfg.MappingSchema; using NHibernate.Engine; @@ -511,18 +510,8 @@ "\" for property: " + propName); } - if (log.IsDebugEnabled) - { - string msg = "Mapped property: " + property.Name; - string columns = Columns(property.Value); - if (columns.Length > 0) - msg += " -> " + columns; - if (property.Type != null) - msg += ", type: " + property.Type.Name; - log.Debug(msg); - } - property.MetaAttributes = GetMetas(node.SelectNodes(HbmConstants.nsMeta, namespaceManager), inheritedMetas); + property.LogMapped(log); } protected static PropertyGeneration ParsePropertyGeneration(string name) @@ -538,21 +527,6 @@ } } - protected static string Columns(IValue val) - { - StringBuilder columns = new StringBuilder(); - bool first = true; - foreach (ISelectable col in val.ColumnIterator) - { - if (first) - first = false; - else - columns.Append(", "); - columns.Append(col.Text); - } - return columns.ToString(); - } - //automatically makes a column with the default name if none is specified by XML protected void BindSimpleValue(XmlNode node, SimpleValue model, bool isNullable, string path) { @@ -1078,23 +1052,6 @@ return null; } - protected static void LogMappedProperty(Mapping.Property property) - { - if (log.IsDebugEnabled) - { - string msg = "Mapped property: " + property.Name; - string columns = Columns(property.Value); - - if (columns.Length > 0) - msg += " -> " + columns; - - if (property.Type != null) - msg += ", type: " + property.Type.Name; - - log.Debug(msg); - } - } - protected static void BindIndex(string indexAttribute, Table table, Column column) { if (indexAttribute != null && table != null) Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassCompositeIdBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassCompositeIdBinder.cs 2009-12-02 04:56:46 UTC (rev 4890) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassCompositeIdBinder.cs 2009-12-02 05:10:21 UTC (rev 4891) @@ -122,7 +122,7 @@ property.Generation = PropertyGeneration.Never; property.MetaAttributes = new Dictionary<string, MetaAttribute>(); - LogMappedProperty(property); + property.LogMapped(log); } private System.Type GetPropertyType(System.Type containingType, string propertyName, HbmCompositeId idSchema) @@ -212,7 +212,7 @@ property.Generation = PropertyGeneration.Never; property.MetaAttributes = new Dictionary<string, MetaAttribute>(); - LogMappedProperty(property); + property.LogMapped(log); } private void BindSimpleValue(HbmKeyProperty keyPropertySchema, SimpleValue model, bool isNullable, string path) @@ -268,7 +268,7 @@ property.IsOptimisticLocked = true; property.Generation = PropertyGeneration.Never; property.MetaAttributes = new Dictionary<string, MetaAttribute>(); - LogMappedProperty(property); + property.LogMapped(log); } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs 2009-12-02 04:56:46 UTC (rev 4890) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs 2009-12-02 05:10:21 UTC (rev 4891) @@ -60,7 +60,7 @@ rootClass.IdentifierProperty = property; - LogMappedProperty(property); + property.LogMapped(log); } } Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs 2009-12-02 04:56:46 UTC (rev 4890) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs 2009-12-02 05:10:21 UTC (rev 4891) @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Xml; using NHibernate.Mapping; @@ -479,14 +480,14 @@ if (log.IsDebugEnabled) { - string msg = "Mapped collection key: " + Columns(collection.Key); + string msg = "Mapped collection key: " + string.Join(",", collection.Key.ColumnIterator.Select(c => c.Text).ToArray()); if (collection.IsIndexed) - msg += ", index: " + Columns(((IndexedCollection)collection).Index); + msg += ", index: " + string.Join(",", ((IndexedCollection)collection).Index.ColumnIterator.Select(c => c.Text).ToArray()); if (collection.IsOneToMany) msg += ", one-to-many: " + collection.Element.Type.Name; else { - msg += ", element: " + Columns(collection.Element); + msg += ", element: " + string.Join(",", collection.Element.ColumnIterator.Select(c => c.Text).ToArray()); msg += ", type: " + collection.Element.Type.Name; } log.Debug(msg); Added: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingLogExtensions.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingLogExtensions.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingLogExtensions.cs 2009-12-02 05:10:21 UTC (rev 4891) @@ -0,0 +1,22 @@ +using System.Linq; +using log4net; + +namespace NHibernate.Cfg.XmlHbmBinding +{ + public static class MappingLogExtensions + { + public static void LogMapped(this Mapping.Property property, ILog log) + { + if (log.IsDebugEnabled) + { + string msg = "Mapped property: " + property.Name; + string columns = string.Join(",", property.Value.ColumnIterator.Select(c => c.Text).ToArray()); + if (columns.Length > 0) + msg += " -> " + columns; + if (property.Type != null) + msg += ", type: " + property.Type.Name; + log.Debug(msg); + } + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs 2009-12-02 04:56:46 UTC (rev 4890) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs 2009-12-02 05:10:21 UTC (rev 4891) @@ -172,7 +172,7 @@ property.MetaAttributes = GetMetas(timestampSchema, inheritedMetas); - LogMappedProperty(property); + property.LogMapped(log); } private static PropertyGeneration Convert(HbmVersionGeneration versionGeneration) @@ -253,7 +253,7 @@ property.MetaAttributes = GetMetas(versionSchema, inheritedMetas); - LogMappedProperty(property); + property.LogMapped(log); } private static void BindCache(HbmCache cacheSchema, RootClass rootClass) Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-12-02 04:56:46 UTC (rev 4890) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-12-02 05:10:21 UTC (rev 4891) @@ -548,6 +548,7 @@ <Compile Include="Cfg\MappingSchema\IDecoratable.cs" /> <Compile Include="Cfg\XmlHbmBinding\ColumnsBinder.cs" /> <Compile Include="Cfg\XmlHbmBinding\FiltersBinder.cs" /> + <Compile Include="Cfg\XmlHbmBinding\MappingLogExtensions.cs" /> <Compile Include="Cfg\XmlHbmBinding\PropertiesBinder.cs"> <SubType>Code</SubType> </Compile> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |