forked from ranzlee/NHibernate.Extensions
/
Extensions.cs
24 lines (22 loc) · 862 Bytes
/
Extensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using System.Collections.Generic;
using NHibernate.DataAnnotations;
using NHibernate.DataAnnotations.Core;
// ReSharper disable CheckNamespace
namespace NHibernate
// ReSharper restore CheckNamespace
{
public static class Extensions
{
public static ISessionValidator GetValidator(this ISession session)
{
var interceptor = session.GetSessionImplementation().Interceptor as ValidationInterceptor;
if (interceptor == null) return null;
return interceptor.GetSessionAuditor();
}
public static EntityPersistenceContext GetEntityPersistenceContext(this IDictionary<object, object> dictionary)
{
if (!dictionary.ContainsKey(EntityValidator.ContextKey)) return null;
return dictionary[EntityValidator.ContextKey] as EntityPersistenceContext;
}
}
}