forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNHibernateProxyFactoryInfo.cs
83 lines (76 loc) · 2.97 KB
/
NHibernateProxyFactoryInfo.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
81
82
83
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.Serialization;
using System.Security;
using NHibernate.Type;
namespace NHibernate.Proxy
{
[Serializable]
public sealed class NHibernateProxyFactoryInfo : ISerializable
{
private readonly string _entityName;
private readonly System.Type _persistentClass;
private readonly System.Type[] _interfaces;
private readonly MethodInfo _getIdentifierMethod;
private readonly MethodInfo _setIdentifierMethod;
private readonly IAbstractComponentType _componentIdType;
private readonly bool _isClassProxy;
internal NHibernateProxyFactoryInfo(
string entityName,
System.Type persistentClass,
System.Type[] interfaces,
MethodInfo getIdentifierMethod,
MethodInfo setIdentifierMethod,
IAbstractComponentType componentIdType,
bool isClassProxy)
{
_entityName = entityName;
_persistentClass = persistentClass;
_interfaces = interfaces;
_getIdentifierMethod = getIdentifierMethod;
_setIdentifierMethod = setIdentifierMethod;
_componentIdType = componentIdType;
_isClassProxy = isClassProxy;
}
internal System.Type PersistentClass => _persistentClass;
public IProxyFactory CreateProxyFactory()
{
var factory = new StaticProxyFactory();
factory.PostInstantiate(
_entityName,
_persistentClass,
new HashSet<System.Type>(_interfaces),
_getIdentifierMethod,
_setIdentifierMethod,
_componentIdType,
_isClassProxy);
return factory;
}
private NHibernateProxyFactoryInfo(SerializationInfo info, StreamingContext context)
{
_entityName = (string) info.GetValue(nameof(_entityName), typeof(string));
_persistentClass = (System.Type) info.GetValue(nameof(_persistentClass), typeof(System.Type));
_interfaces = (System.Type[]) info.GetValue(nameof(_interfaces), typeof(System.Type[]));
_getIdentifierMethod = (MethodInfo) info.GetValue(nameof(_getIdentifierMethod), typeof(MethodInfo));
_setIdentifierMethod = (MethodInfo) info.GetValue(nameof(_setIdentifierMethod), typeof(MethodInfo));
_componentIdType = (IAbstractComponentType) info.GetValue(nameof(_componentIdType), typeof(IAbstractComponentType));
_isClassProxy = (bool) info.GetValue(nameof(_isClassProxy), typeof(bool));
}
[SecurityCritical]
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue(nameof(_entityName), _entityName);
info.AddValue(nameof(_persistentClass), _persistentClass);
info.AddValue(nameof(_interfaces), _interfaces);
info.AddValue(nameof(_getIdentifierMethod), _getIdentifierMethod);
info.AddValue(nameof(_setIdentifierMethod), _setIdentifierMethod);
info.AddValue(nameof(_componentIdType), _componentIdType);
info.AddValue(nameof(_isClassProxy), _isClassProxy);
}
internal NHibernateProxyFactoryInfo Clone()
{
return new NHibernateProxyFactoryInfo(_entityName, _persistentClass, _interfaces, _getIdentifierMethod, _setIdentifierMethod, _componentIdType, _isClassProxy);
}
}
}