From: <te...@us...> - 2008-12-13 22:06:44
|
Revision: 3950 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3950&view=rev Author: tehlike Date: 2008-12-13 22:06:37 +0000 (Sat, 13 Dec 2008) Log Message: ----------- Fix for NH-1607 by Chaviv Weinberg with some modifications to increase readability Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Impl/SessionFactoryObjectFactory.cs Modified: trunk/nhibernate/src/NHibernate/Impl/SessionFactoryObjectFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/SessionFactoryObjectFactory.cs 2008-12-12 15:56:00 UTC (rev 3949) +++ trunk/nhibernate/src/NHibernate/Impl/SessionFactoryObjectFactory.cs 2008-12-13 22:06:37 UTC (rev 3950) @@ -21,7 +21,7 @@ /// TODO: verify that the AppDomain statements are correct. /// </para> /// </remarks> - public sealed class SessionFactoryObjectFactory + public static class SessionFactoryObjectFactory { // to stop this class from being unloaded - this is a comment // from h2.0.3 - is this applicable to .net also??? @@ -38,11 +38,6 @@ log.Debug("initializing class SessionFactoryObjectFactory"); } - private SessionFactoryObjectFactory() - { - // should not be created - } - /// <summary> /// Adds an Instance of the SessionFactory to the local "cache". /// </summary> @@ -82,10 +77,8 @@ if (!string.IsNullOrEmpty(name)) { log.Info("unbinding factory: " + name); - NamedInstances.Remove(name); } - Instances.Remove(uid); } @@ -97,8 +90,9 @@ public static ISessionFactory GetNamedInstance(string name) { log.Debug("lookup: name=" + name); - ISessionFactory factory = NamedInstances[name]; - if (factory == null) + ISessionFactory factory; + bool found=NamedInstances.TryGetValue(name, out factory); + if (!found) { log.Warn("Not found: " + name); } @@ -113,8 +107,9 @@ public static ISessionFactory GetInstance(string uid) { log.Debug("lookup: uid=" + uid); - ISessionFactory factory = Instances[uid]; - if (factory == null) + ISessionFactory factory; + bool found = Instances.TryGetValue(uid, out factory); + if (!found) { log.Warn("Not found: " + uid); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |