diff --git a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/AdvisedProxy.cs b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/AdvisedProxy.cs
index 55b7b4b7..0e7f8d1a 100644
--- a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/AdvisedProxy.cs
+++ b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/AdvisedProxy.cs
@@ -23,12 +23,14 @@
using System;
using System.Collections;
using System.Collections.Specialized;
+using System.Diagnostics;
using System.Reflection;
using System.Runtime.Serialization;
using System.Security.Permissions;
using AopAlliance.Aop;
using AopAlliance.Intercept;
+using Spring.Aop.Target;
using Spring.Util;
#endregion
@@ -426,6 +428,62 @@ namespace Spring.Aop.Framework.DynamicProxy
get { return m_targetType; }
}
+ #endregion
+
+ #region Equal, HashCode and ToString overrides
+
+ ///
+ /// Delegate to target object handling of equals method.
+ ///
+ /// The object to compare with the current target object
+ /// true if the specified Object is equal to the current target object; otherwise, false
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ AdvisedProxy otherProxy = obj as AdvisedProxy;
+ if (otherProxy != null)
+ {
+ using (m_targetSourceWrapper)
+ using (otherProxy.m_targetSourceWrapper)
+ {
+ return m_targetSourceWrapper.GetTarget().Equals(otherProxy.m_targetSourceWrapper.GetTarget());
+ }
+ }
+
+ using (m_targetSourceWrapper)
+ {
+ return m_targetSourceWrapper.GetTarget().Equals(obj);
+ }
+ }
+
+ ///
+ /// Delgate to the target object generation of the hash code.
+ ///
+ /// A hash code for the target object.
+ public override int GetHashCode()
+ {
+ using (m_targetSourceWrapper)
+ {
+ return m_targetSourceWrapper.GetTarget().GetHashCode();
+ }
+ }
+
+ ///
+ /// Returns a String the represents the target object.
+ ///
+ /// A String that represents the target object
+ public override string ToString()
+ {
+ using (m_targetSourceWrapper)
+ {
+ return m_targetSourceWrapper.GetTarget().ToString();
+ }
+ }
+
#endregion
- }
+ }
}
\ No newline at end of file
diff --git a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/BaseCompositionAopProxy.cs b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/BaseCompositionAopProxy.cs
index 7de3460a..7e79d85c 100644
--- a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/BaseCompositionAopProxy.cs
+++ b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/BaseCompositionAopProxy.cs
@@ -84,46 +84,5 @@ namespace Spring.Aop.Framework.DynamicProxy
}
#endregion
-
- #region Equal, HashCode and ToString overrides
-
- ///
- /// Delegate to target object handling of equals method.
- ///
- /// The object to compare with the current target object
- /// true if the specified Object is equal to the current target object; otherwise, false
- public override bool Equals(object obj)
- {
- using (m_targetSourceWrapper)
- {
- return m_targetSourceWrapper.GetTarget().Equals(obj);
- }
- }
-
- ///
- /// Delgate to the target object generation of the hash code.
- ///
- /// A hash code for the target object.
- public override int GetHashCode()
- {
- using (m_targetSourceWrapper)
- {
- return m_targetSourceWrapper.GetTarget().GetHashCode();
- }
- }
-
- ///
- /// Returns a String the represents the target object.
- ///
- /// A String that represents the target object
- public override string ToString()
- {
- using (m_targetSourceWrapper)
- {
- return m_targetSourceWrapper.GetTarget().ToString();
- }
- }
-
- #endregion
}
}
\ No newline at end of file
diff --git a/test/Spring/Spring.Aop.Tests/Aop/Framework/DynamicProxy/AbstractAopProxyTests.cs b/test/Spring/Spring.Aop.Tests/Aop/Framework/DynamicProxy/AbstractAopProxyTests.cs
index db84f77c..16908ddc 100644
--- a/test/Spring/Spring.Aop.Tests/Aop/Framework/DynamicProxy/AbstractAopProxyTests.cs
+++ b/test/Spring/Spring.Aop.Tests/Aop/Framework/DynamicProxy/AbstractAopProxyTests.cs
@@ -263,6 +263,24 @@ namespace Spring.Aop.Framework.DynamicProxy
string Company { get; set; }
}
+ public class TestCustomer : ITestCustomer
+ {
+ public long Id
+ {
+ get; set;
+ }
+
+ public string Name
+ {
+ get; set;
+ }
+
+ public string Company
+ {
+ get; set;
+ }
+ }
+
#endregion
[Test(Description = "http://jira.springframework.org/browse/SPRNET-1174")]
@@ -290,6 +308,22 @@ namespace Spring.Aop.Framework.DynamicProxy
mocks.VerifyAll();
}
+ [Test]
+ public void Equality()
+ {
+ TestCustomer customer = new TestCustomer();
+
+ AdvisedSupport advised = new AdvisedSupport();
+ advised.Target = customer;
+ advised.Interfaces = new Type[] { typeof(ITestCustomer) };
+
+ ITestCustomer to = CreateProxy(advised) as ITestCustomer;
+ Assert.IsNotNull(to);
+ Assert.IsTrue( to.Equals(to), "identity must be equal" );
+ Assert.AreEqual(to, to);
+ Assert.AreEqual(to, ((IAdvised)to).TargetSource.GetTarget());
+ }
+
[Test]
[ExpectedException(typeof(NotSupportedException)
, ExpectedMessage = "Target 'target' is null.")]
diff --git a/test/Spring/Spring.Aop.Tests/Spring.Aop.Tests.2008.csproj b/test/Spring/Spring.Aop.Tests/Spring.Aop.Tests.2008.csproj
index 3dce2ff2..ae656671 100644
--- a/test/Spring/Spring.Aop.Tests/Spring.Aop.Tests.2008.csproj
+++ b/test/Spring/Spring.Aop.Tests/Spring.Aop.Tests.2008.csproj
@@ -44,7 +44,7 @@
3
full
prompt
- true
+ false
..\..\..\build\VS.Net.2008\Spring.Aop.Tests\Release\