forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNullBytecodeProvider.cs
67 lines (58 loc) · 1.64 KB
/
NullBytecodeProvider.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
using System;
using NHibernate.Properties;
using NHibernate.Util;
namespace NHibernate.Bytecode
{
/// <summary>
/// A <see cref="IBytecodeProvider" /> implementation that returns
/// <see langword="null" />, disabling reflection optimization.
/// </summary>
public class NullBytecodeProvider : IBytecodeProvider, IInjectableProxyFactoryFactory
{
private System.Type proxyFactoryFactory;
#region IBytecodeProvider Members
public IProxyFactoryFactory ProxyFactoryFactory
{
get
{
if (proxyFactoryFactory != null)
{
try
{
return (IProxyFactoryFactory) Activator.CreateInstance(proxyFactoryFactory);
}
catch (Exception e)
{
throw new HibernateByteCodeException("Failed to create an instance of '" + proxyFactoryFactory.FullName + "'!", e);
}
}
throw new ProxyFactoryFactoryNotConfiguredException();
}
}
public IReflectionOptimizer GetReflectionOptimizer(System.Type clazz, IGetter[] getters, ISetter[] setters)
{
return null;
}
#endregion
#region Implementation of IInjectableProxyFactoryFactory
public void SetProxyFactoryFactory(string typeName)
{
System.Type pffc;
try
{
pffc = ReflectHelper.ClassForName(typeName);
}
catch (Exception he)
{
throw new UnableToLoadProxyFactoryFactoryException(typeName, he);
}
if (typeof (IProxyFactoryFactory).IsAssignableFrom(pffc) == false)
{
var he = new HibernateByteCodeException(pffc.FullName + " does not implement " + typeof(IProxyFactoryFactory).FullName);
throw he;
}
proxyFactoryFactory = pffc;
}
#endregion
}
}