|
From: <fab...@us...> - 2011-03-20 17:43:32
|
Revision: 5478
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5478&view=rev
Author: fabiomaulo
Date: 2011-03-20 17:43:25 +0000 (Sun, 20 Mar 2011)
Log Message:
-----------
Changed IProxyFactory to get the instance to wrap, for proxy "field-interceptor"
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Proxy/AbstractProxyFactory.cs
trunk/nhibernate/src/NHibernate/Proxy/DefaultProxyFactory.cs
trunk/nhibernate/src/NHibernate/Proxy/IProxyFactory.cs
trunk/nhibernate/src/NHibernate/Proxy/Map/MapProxyFactory.cs
trunk/nhibernate/src/NHibernate/Tuple/PocoInstantiator.cs
trunk/nhibernate/src/NHibernate.ByteCode.Castle/ProxyFactory.cs
trunk/nhibernate/src/NHibernate.ByteCode.Castle.Tests/LazyFieldInterceptorSerializable.cs
Modified: trunk/nhibernate/src/NHibernate/Proxy/AbstractProxyFactory.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Proxy/AbstractProxyFactory.cs 2011-03-20 17:31:14 UTC (rev 5477)
+++ trunk/nhibernate/src/NHibernate/Proxy/AbstractProxyFactory.cs 2011-03-20 17:43:25 UTC (rev 5478)
@@ -44,7 +44,7 @@
public abstract INHibernateProxy GetProxy(object id, ISessionImplementor session);
- public virtual object GetFieldInterceptionProxy()
+ public virtual object GetFieldInterceptionProxy(object instanceToWrap)
{
throw new NotSupportedException();
}
Modified: trunk/nhibernate/src/NHibernate/Proxy/DefaultProxyFactory.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Proxy/DefaultProxyFactory.cs 2011-03-20 17:31:14 UTC (rev 5477)
+++ trunk/nhibernate/src/NHibernate/Proxy/DefaultProxyFactory.cs 2011-03-20 17:43:25 UTC (rev 5478)
@@ -30,10 +30,9 @@
}
}
- public override object GetFieldInterceptionProxy()
+ public override object GetFieldInterceptionProxy(object instanceToWrap)
{
- object targetInstance = Cfg.Environment.BytecodeProvider.ObjectsFactory.CreateInstance(PersistentClass, true);
- var interceptor = new DefaultDynamicLazyFieldInterceptor(targetInstance);
+ var interceptor = new DefaultDynamicLazyFieldInterceptor(instanceToWrap);
return factory.CreateProxy(PersistentClass, interceptor, new[] { typeof(IFieldInterceptorAccessor) });
}
}
Modified: trunk/nhibernate/src/NHibernate/Proxy/IProxyFactory.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Proxy/IProxyFactory.cs 2011-03-20 17:31:14 UTC (rev 5477)
+++ trunk/nhibernate/src/NHibernate/Proxy/IProxyFactory.cs 2011-03-20 17:43:25 UTC (rev 5478)
@@ -49,6 +49,6 @@
/// <exception cref="HibernateException">Indicates problems generating requested proxy.</exception>
INHibernateProxy GetProxy(object id, ISessionImplementor session);
- object GetFieldInterceptionProxy();
+ object GetFieldInterceptionProxy(object instanceToWrap);
}
}
Modified: trunk/nhibernate/src/NHibernate/Proxy/Map/MapProxyFactory.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Proxy/Map/MapProxyFactory.cs 2011-03-20 17:31:14 UTC (rev 5477)
+++ trunk/nhibernate/src/NHibernate/Proxy/Map/MapProxyFactory.cs 2011-03-20 17:43:25 UTC (rev 5478)
@@ -24,7 +24,7 @@
return new MapProxy(new MapLazyInitializer(entityName, id, session));
}
- public object GetFieldInterceptionProxy()
+ public object GetFieldInterceptionProxy(object getInstance)
{
throw new NotSupportedException();
}
Modified: trunk/nhibernate/src/NHibernate/Tuple/PocoInstantiator.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Tuple/PocoInstantiator.cs 2011-03-20 17:31:14 UTC (rev 5477)
+++ trunk/nhibernate/src/NHibernate/Tuple/PocoInstantiator.cs 2011-03-20 17:43:25 UTC (rev 5478)
@@ -90,8 +90,13 @@
}
if (generateFieldInterceptionProxy)
{
- return proxyFactory.GetFieldInterceptionProxy();
+ return proxyFactory.GetFieldInterceptionProxy(GetInstance());
}
+ return GetInstance();
+ }
+
+ private object GetInstance()
+ {
if (optimizer != null)
{
return optimizer.CreateInstance();
Modified: trunk/nhibernate/src/NHibernate.ByteCode.Castle/ProxyFactory.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.ByteCode.Castle/ProxyFactory.cs 2011-03-20 17:31:14 UTC (rev 5477)
+++ trunk/nhibernate/src/NHibernate.ByteCode.Castle/ProxyFactory.cs 2011-03-20 17:43:25 UTC (rev 5478)
@@ -44,7 +44,7 @@
}
- public override object GetFieldInterceptionProxy()
+ public override object GetFieldInterceptionProxy(object instanceToWrap)
{
var proxyGenerationOptions = new ProxyGenerationOptions();
var interceptor = new LazyFieldInterceptor();
Modified: trunk/nhibernate/src/NHibernate.ByteCode.Castle.Tests/LazyFieldInterceptorSerializable.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.ByteCode.Castle.Tests/LazyFieldInterceptorSerializable.cs 2011-03-20 17:31:14 UTC (rev 5477)
+++ trunk/nhibernate/src/NHibernate.ByteCode.Castle.Tests/LazyFieldInterceptorSerializable.cs 2011-03-20 17:43:25 UTC (rev 5478)
@@ -26,7 +26,7 @@
var pf = new ProxyFactory();
var propertyInfo = typeof(MyClass).GetProperty("Id");
pf.PostInstantiate("MyClass", typeof(MyClass), new HashedSet<System.Type>(), propertyInfo.GetGetMethod(), propertyInfo.GetSetMethod(), null);
- var fieldInterceptionProxy = (IFieldInterceptorAccessor)pf.GetFieldInterceptionProxy();
+ var fieldInterceptionProxy = (IFieldInterceptorAccessor)pf.GetFieldInterceptionProxy(new MyClass());
fieldInterceptionProxy.FieldInterceptor = new DefaultFieldInterceptor(null, null, null, "MyClass", typeof(MyClass));
fieldInterceptionProxy.Should().Be.BinarySerializable();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|