Skip to content

Commit 23f5058

Browse files
committed
Changing throwing indexer to TryGetValue
SVN: trunk@4912
1 parent c52d259 commit 23f5058

File tree

1 file changed

+10
-22
lines changed

1 file changed

+10
-22
lines changed

src/NHibernate/Impl/SessionFactoryImpl.cs

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -465,14 +465,10 @@ public ISession OpenSession(IDbConnection connection, bool flushBeforeCompletion
465465

466466
public IEntityPersister GetEntityPersister(string entityName)
467467
{
468-
try
469-
{
470-
return entityPersisters[entityName];
471-
}
472-
catch (KeyNotFoundException)
473-
{
474-
throw new MappingException("No persister for: " + entityName);
475-
}
468+
IEntityPersister value;
469+
if (entityPersisters.TryGetValue(entityName, out value) == false)
470+
throw new MappingException("No persister for: " + entityName);
471+
return value;
476472
}
477473

478474
public IEntityPersister TryGetEntityPersister(string entityName)
@@ -484,14 +480,10 @@ public IEntityPersister TryGetEntityPersister(string entityName)
484480

485481
public ICollectionPersister GetCollectionPersister(string role)
486482
{
487-
try
488-
{
489-
return collectionPersisters[role];
490-
}
491-
catch (KeyNotFoundException)
492-
{
483+
ICollectionPersister value;
484+
if(collectionPersisters.TryGetValue(role, out value) == false)
493485
throw new MappingException("Unknown collection role: " + role);
494-
}
486+
return value;
495487
}
496488

497489
public ISet<string> GetCollectionRolesByEntityParticipant(string entityName)
@@ -979,14 +971,10 @@ public ResultSetMappingDefinition GetResultSetMapping(string resultSetName)
979971

980972
public FilterDefinition GetFilterDefinition(string filterName)
981973
{
982-
try
983-
{
984-
return filters[filterName];
985-
}
986-
catch (KeyNotFoundException)
987-
{
974+
FilterDefinition value;
975+
if(filters.TryGetValue(filterName,out value)==false)
988976
throw new HibernateException("No such filter configured [" + filterName + "]");
989-
}
977+
return value;
990978
}
991979

992980
public ICollection<string> DefinedFilterNames

0 commit comments

Comments
 (0)