From: <fab...@us...> - 2009-06-24 03:58:14
|
Revision: 4523 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4523&view=rev Author: fabiomaulo Date: 2009-06-24 03:57:43 +0000 (Wed, 24 Jun 2009) Log Message: ----------- Refactoring (extracted base class) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/ConfigurationSchema/SessionFactoryConfiguration.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Cfg/SessionFactoryConfigurationBase.cs Modified: trunk/nhibernate/src/NHibernate/Cfg/ConfigurationSchema/SessionFactoryConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/ConfigurationSchema/SessionFactoryConfiguration.cs 2009-06-23 23:23:33 UTC (rev 4522) +++ trunk/nhibernate/src/NHibernate/Cfg/ConfigurationSchema/SessionFactoryConfiguration.cs 2009-06-24 03:57:43 UTC (rev 4523) @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Xml.XPath; namespace NHibernate.Cfg.ConfigurationSchema @@ -7,7 +6,7 @@ /// <summary> /// Configuration parsed values for a session-factory XML node. /// </summary> - public class SessionFactoryConfiguration : ISessionFactoryConfiguration + public class SessionFactoryConfiguration : SessionFactoryConfigurationBase { //private static readonly ILog log = LogManager.GetLogger(typeof(SessionFactoryConfiguration)); @@ -24,7 +23,7 @@ /// <param name="name">The session factory name. Null or empty string are allowed.</param> public SessionFactoryConfiguration(string name) { - this.name = name; + Name = name; } private void Parse(XPathNavigator navigator) @@ -44,7 +43,7 @@ if (xpn != null) { if (xpn.MoveToFirstAttribute()) - name = xpn.Value; + Name = xpn.Value; } } @@ -53,21 +52,12 @@ XPathNodeIterator xpni = navigator.Select(CfgXmlHelper.SessionFactoryPropertiesExpression); while (xpni.MoveNext()) { - string propName; - string propValue; - if(xpni.Current.Value!=null) - { - propValue = xpni.Current.Value.Trim(); - } - else - { - propValue = string.Empty; - } + string propValue = xpni.Current.Value!=null ? xpni.Current.Value.Trim() : string.Empty; XPathNavigator pNav = xpni.Current.Clone(); pNav.MoveToFirstAttribute(); - propName= pNav.Value; + string propName = pNav.Value; if (!string.IsNullOrEmpty(propName)) - properties[propName] = propValue; + Properties[propName] = propValue; } } @@ -76,29 +66,10 @@ XPathNodeIterator xpni = navigator.Select(CfgXmlHelper.SessionFactoryMappingsExpression); while (xpni.MoveNext()) { - MappingConfiguration mc = new MappingConfiguration(xpni.Current); + var mc = new MappingConfiguration(xpni.Current); if (!mc.IsEmpty()) { - // Workaround add first an assembly&resource and then only the same assembly. - // the <mapping> of whole assembly is ignored (included only sigles resources) - // The "ignore" log, is enough ? - // Perhaps we can add some intelligence to remove single resource reference when a whole assembly is referenced - //if (!mappings.Contains(mc)) - //{ - // mappings.Add(mc); - //} - //else - //{ - // string logMessage = "Ignored mapping -> " + mc.ToString(); - // if (log.IsDebugEnabled) - // log.Debug(logMessage); - // if (log.IsWarnEnabled) - // log.Warn(logMessage); - //} - - // The control to prevent mappings duplication was removed since the engine do the right thing - // for this issue (simple is better) - mappings.Add(mc); + Mappings.Add(mc); } } } @@ -108,7 +79,7 @@ XPathNodeIterator xpni = navigator.Select(CfgXmlHelper.SessionFactoryClassesCacheExpression); while (xpni.MoveNext()) { - classesCache.Add(new ClassCacheConfiguration(xpni.Current)); + ClassesCache.Add(new ClassCacheConfiguration(xpni.Current)); } } @@ -118,7 +89,7 @@ XPathNodeIterator xpni = navigator.Select(CfgXmlHelper.SessionFactoryCollectionsCacheExpression); while (xpni.MoveNext()) { - collectionsCache.Add(new CollectionCacheConfiguration(xpni.Current)); + CollectionsCache.Add(new CollectionCacheConfiguration(xpni.Current)); } } @@ -128,7 +99,7 @@ XPathNodeIterator xpni = navigator.Select(CfgXmlHelper.SessionFactoryListenersExpression); while (xpni.MoveNext()) { - listeners.Add(new ListenerConfiguration(xpni.Current)); + Listeners.Add(new ListenerConfiguration(xpni.Current)); } } @@ -137,72 +108,8 @@ XPathNodeIterator xpni = navigator.Select(CfgXmlHelper.SessionFactoryEventsExpression); while (xpni.MoveNext()) { - events.Add(new EventConfiguration(xpni.Current)); + Events.Add(new EventConfiguration(xpni.Current)); } } - - private string name = string.Empty; - /// <summary> - /// The session factory name. - /// </summary> - public string Name - { - get { return name; } - } - - private IDictionary<string, string> properties = new Dictionary<string, string>(); - /// <summary> - /// Session factory propeties bag. - /// </summary> - public IDictionary<string,string> Properties - { - get { return properties; } - } - - private IList<MappingConfiguration> mappings = new List<MappingConfiguration>(); - /// <summary> - /// Session factory mapping configuration. - /// </summary> - public IList<MappingConfiguration> Mappings - { - get { return mappings; } - } - - private IList<ClassCacheConfiguration> classesCache= new List<ClassCacheConfiguration>(); - /// <summary> - /// Session factory class-cache configurations. - /// </summary> - public IList<ClassCacheConfiguration> ClassesCache - { - get { return classesCache; } - } - - private IList<CollectionCacheConfiguration> collectionsCache= new List<CollectionCacheConfiguration>(); - /// <summary> - /// Session factory collection-cache configurations. - /// </summary> - public IList<CollectionCacheConfiguration> CollectionsCache - { - get { return collectionsCache; } - } - - private IList<EventConfiguration> events= new List<EventConfiguration>(); - /// <summary> - /// Session factory event configurations. - /// </summary> - public IList<EventConfiguration> Events - { - get { return events; } - } - - private IList<ListenerConfiguration> listeners= new List<ListenerConfiguration>(); - /// <summary> - /// Session factory listener configurations. - /// </summary> - public IList<ListenerConfiguration> Listeners - { - get { return listeners; } - } - } } Added: trunk/nhibernate/src/NHibernate/Cfg/SessionFactoryConfigurationBase.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/SessionFactoryConfigurationBase.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Cfg/SessionFactoryConfigurationBase.cs 2009-06-24 03:57:43 UTC (rev 4523) @@ -0,0 +1,73 @@ +using System.Collections.Generic; +using NHibernate.Cfg.ConfigurationSchema; + +namespace NHibernate.Cfg +{ + public class SessionFactoryConfigurationBase : ISessionFactoryConfiguration + { + private string name = string.Empty; + private readonly IDictionary<string, string> properties = new Dictionary<string, string>(); + private readonly IList<MappingConfiguration> mappings = new List<MappingConfiguration>(); + private readonly IList<ClassCacheConfiguration> classesCache= new List<ClassCacheConfiguration>(); + private readonly IList<CollectionCacheConfiguration> collectionsCache= new List<CollectionCacheConfiguration>(); + private readonly IList<EventConfiguration> events= new List<EventConfiguration>(); + private readonly IList<ListenerConfiguration> listeners= new List<ListenerConfiguration>(); + + /// <summary> + /// The session factory name. + /// </summary> + public string Name + { + get { return name; } + protected set { name = value; } + } + + /// <summary> + /// Session factory propeties bag. + /// </summary> + public IDictionary<string,string> Properties + { + get { return properties; } + } + + /// <summary> + /// Session factory mapping configuration. + /// </summary> + public IList<MappingConfiguration> Mappings + { + get { return mappings; } + } + + /// <summary> + /// Session factory class-cache configurations. + /// </summary> + public IList<ClassCacheConfiguration> ClassesCache + { + get { return classesCache; } + } + + /// <summary> + /// Session factory collection-cache configurations. + /// </summary> + public IList<CollectionCacheConfiguration> CollectionsCache + { + get { return collectionsCache; } + } + + /// <summary> + /// Session factory event configurations. + /// </summary> + public IList<EventConfiguration> Events + { + get { return events; } + } + + /// <summary> + /// Session factory listener configurations. + /// </summary> + public IList<ListenerConfiguration> Listeners + { + get { return listeners; } + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-06-23 23:23:33 UTC (rev 4522) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-06-24 03:57:43 UTC (rev 4523) @@ -459,6 +459,7 @@ <Compile Include="Bytecode\ProxyFactoryFactoryNotConfiguredException.cs" /> <Compile Include="Bytecode\UnableToLoadProxyFactoryFactoryException.cs" /> <Compile Include="Cache\FakeCache.cs" /> + <Compile Include="Cfg\SessionFactoryConfigurationBase.cs" /> <Compile Include="Cfg\ISessionFactoryConfiguration.cs" /> <Compile Include="Cfg\MappingSchema\AbstractDecoratable.cs" /> <Compile Include="Cfg\MappingSchema\HbmTimestamp.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |