Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Proxy
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv26076/Proxy
Modified Files:
AbstractProxyTypeBuilder.cs
Log Message:
SPRNET-606 - Fix in .NET 2.0 for problems with attributes in proxy generation.
Index: AbstractProxyTypeBuilder.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Proxy/AbstractProxyTypeBuilder.cs,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** AbstractProxyTypeBuilder.cs 31 Jul 2007 18:16:25 -0000 1.28
--- AbstractProxyTypeBuilder.cs 11 Oct 2007 05:57:25 -0000 1.29
***************
*** 68,71 ****
--- 68,72 ----
private IList _typeAttributes = new ArrayList();
private IDictionary _memberAttributes = new Hashtable();
+ private readonly IList _typeAttributesToExclude = new ArrayList();
#endregion
***************
*** 280,283 ****
--- 281,293 ----
if (this.ProxyTargetAttributes)
{
+ #if !NET_1_0 && !NET_1_1
+ // First, try to apply the CustomAttributeData approach
+ if (SafeAttributeUtils.ApplyMethodReturnTypeAttributes(methodBuilder, targetMethod))
+ {
+ // if succeeded with CustomAttributeData solution, return.
+ return;
+ }
+ #endif
+ // If didn't succeed with the CustomAttributeData, apply the old approach
foreach (Attribute attr in targetMethod.ReturnTypeCustomAttributes.GetCustomAttributes(true))
{
***************
*** 302,305 ****
--- 312,326 ----
foreach (ParameterInfo paramInfo in targetMethod.GetParameters())
{
+ #if !NET_1_0 && !NET_1_1
+ // First, try to apply the CustomAttributeData approach
+ if (SafeAttributeUtils.ApplyMethodParameterAttributes(methodBuilder, targetMethod,
+ paramInfo))
+ {
+ // if succeeded with CustomAttributeData solution, continue with the
+ // next parameter.
+ continue;
+ }
+ #endif
+ // If didn't succeed with the CustomAttributeData, apply the old approach
foreach (Attribute attr in paramInfo.GetCustomAttributes(true))
{
***************
*** 330,335 ****
if (this.ProxyTargetAttributes)
{
! // add attributes that apply to the target type
attributes.AddRange(type.GetCustomAttributes(false));
}
--- 351,373 ----
if (this.ProxyTargetAttributes)
{
! #if !NET_1_0 && !NET_1_1
! // Try the CustomAttributeData approach first
! CustomAttributeBuilder[] attrBuilders =
! SafeAttributeUtils.GetMemberAttributes(type, TypeAttributesToExclude);
!
! if (attrBuilders != null)
! {
! attributes.AddRange(attrBuilders);
! }
! else // If CustomAttributeData approach failed use the old solution
! {
!
! // add attributes that apply to the target type
! attributes.AddRange(type.GetCustomAttributes(false));
! }
! #else
attributes.AddRange(type.GetCustomAttributes(false));
+ #endif
+
}
***************
*** 358,363 ****
if (this.ProxyTargetAttributes)
{
! // add attributes that apply to the target method
attributes.AddRange(method.GetCustomAttributes(false));
}
--- 396,416 ----
if (this.ProxyTargetAttributes)
{
! #if !NET_1_0 && !NET_1_1
! // Try the CustomAttributeData approach first
! CustomAttributeBuilder[] attrBuilders =
! SafeAttributeUtils.GetMemberAttributes(method);
!
! if (attrBuilders != null)
! {
! attributes.AddRange(attrBuilders);
! }
! else // If CustomAttributeData approach failed use the old solution
! {
! // add attributes that apply to the target method
! attributes.AddRange(method.GetCustomAttributes(false));
! }
! #else
attributes.AddRange(method.GetCustomAttributes(false));
+ #endif
}
***************
*** 752,755 ****
--- 805,825 ----
#endregion
+
+ #region Protected Properties
+
+ /// <summary>
+ /// Gets the type attributes to exclude.
+ /// </summary>
+ /// <value>The type attributes to exclude.</value>
+ protected virtual IList TypeAttributesToExclude
+ {
+ get
+ {
+ return _typeAttributesToExclude;
+ }
+ }
+
+ #endregion
+
}
}
\ No newline at end of file
|