forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAbstractProxyFactory.cs
80 lines (73 loc) · 2.41 KB
/
AbstractProxyFactory.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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using System;
using System.Collections.Generic;
using System.Reflection;
using NHibernate.Engine;
using NHibernate.Type;
using NHibernate.Util;
namespace NHibernate.Proxy
{
/// <summary>
/// Convenient common implementation for ProxyFactory
/// </summary>
public abstract class AbstractProxyFactory: IProxyFactory
{
protected virtual string EntityName { get; private set; }
protected virtual System.Type PersistentClass { get; private set; }
protected virtual System.Type[] Interfaces { get; private set; }
protected virtual MethodInfo GetIdentifierMethod { get; private set; }
protected virtual MethodInfo SetIdentifierMethod { get; private set; }
protected virtual IAbstractComponentType ComponentIdType { get; private set; }
protected virtual bool IsClassProxy { get; private set; }
protected virtual bool OverridesEquals { get; set; }
public virtual void PostInstantiate(
string entityName,
System.Type persistentClass,
ISet<System.Type> interfaces,
MethodInfo getIdentifierMethod,
MethodInfo setIdentifierMethod,
IAbstractComponentType componentIdType,
bool isClassProxy)
{
#pragma warning disable 618
PostInstantiate(
entityName,
persistentClass,
interfaces,
getIdentifierMethod,
setIdentifierMethod,
componentIdType);
#pragma warning restore 618
IsClassProxy = isClassProxy;
}
// Since v5.3
[Obsolete("Override PostInstantiate method with isClassProxy parameter instead.")]
public virtual void PostInstantiate(
string entityName,
System.Type persistentClass,
ISet<System.Type> interfaces,
MethodInfo getIdentifierMethod,
MethodInfo setIdentifierMethod,
IAbstractComponentType componentIdType)
{
EntityName = entityName;
PersistentClass = persistentClass;
Interfaces = new System.Type[interfaces.Count];
if (interfaces.Count > 0)
{
interfaces.CopyTo(Interfaces, 0);
}
GetIdentifierMethod = getIdentifierMethod;
SetIdentifierMethod = setIdentifierMethod;
ComponentIdType = componentIdType;
OverridesEquals = ReflectHelper.OverridesEquals(persistentClass);
IsClassProxy = interfaces.Count == 1;
}
public abstract INHibernateProxy GetProxy(object id, ISessionImplementor session);
// Since 5.3
[Obsolete("Use ProxyFactoryExtensions.GetFieldInterceptionProxy extension method instead.")]
public virtual object GetFieldInterceptionProxy(object instanceToWrap)
{
throw new NotSupportedException();
}
}
}