User: xtoff
Date: 2009/12/29 08:29 AM

Removed:
 /DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/
  IProxyMethod.cs

Modified:
 /DynamicProxy/trunk/src/Castle.DynamicProxy.Tests/
  ExplicitInterfaceTestCase.cs
 /DynamicProxy/trunk/src/Castle.DynamicProxy/
  Castle.DynamicProxy-vs2008.csproj
 /DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/
  ClassMembersCollector.cs, ClassProxyTargetContributor.cs, 
CompositeTypeContributor.cs, InterfaceMembersCollector.cs, 
InterfaceMembersOnClassCollector.cs, InterfaceProxyTargetContributor.cs, 
InterfaceProxyWithTargetInterfaceTargetContributor.cs, MembersCollector.cs
 /DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/
  ClassInvocationTypeGenerator.cs, ClassProxyGenerator.cs, 
InterfaceInvocationTypeGenerator.cs, InterfaceProxyWithTargetGenerator.cs, 
InterfaceProxyWithTargetInterfaceGenerator.cs, 
InterfaceProxyWithoutTargetGenerator.cs, InvocationTypeGenerator.cs, 
MethodToGenerate.cs, PropertyToGenerate.cs

Log:
 - removed IProxyMethod interface as it was not used anywhere anyway
 - removed some duplication and not needed code
 - added logger to all contributors/collectors and now logger gets populated 
onto them as they are created

File Changes:

Directory: /DynamicProxy/trunk/src/Castle.DynamicProxy/
=======================================================

File [modified]: Castle.DynamicProxy-vs2008.csproj
Delta lines: +4 -10
===================================================================

--- 
DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/ClassMembersCollector.cs
    2009-12-29 13:06:00 UTC (rev 6537)
+++ 
DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/ClassMembersCollector.cs
    2009-12-29 15:29:22 UTC (rev 6538)
@@ -20,8 +20,8 @@
 
        public class ClassMembersCollector : MembersCollector
        {
-               public ClassMembersCollector(Type targetType, ITypeContributor 
targetContributor)
-                       : base(targetType, targetContributor, true, new 
InterfaceMapping())
+               public ClassMembersCollector(Type targetType)
+                       : base(targetType)
                {
                }
 
@@ -32,20 +32,14 @@
                                return null;
                        }
 
-                       var accepted = AcceptMethod(method, onlyProxyVirtual, 
hook);
+                       var accepted = AcceptMethod(method, true, hook);
                        if (!accepted && !method.IsAbstract)
                        {
                                //we don't need to do anything...
                                return null;
                        }
 
-                       ITypeContributor target = null;
-                       if(!method.IsAbstract)
-                       {
-                               target = contributor;
-                       }
-
-                       return new MethodToGenerate(method, isStandalone, 
target, method, accepted);
+                       return new MethodToGenerate(method, method, 
isStandalone, accepted, !method.IsAbstract);
                }
        }
 }

Directory: /DynamicProxy/trunk/src/Castle.DynamicProxy.Tests/
=============================================================

File [modified]: ExplicitInterfaceTestCase.cs
Delta lines: +0 -0
===================================================================

Directory: /DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/
====================================================================

File [modified]: ClassMembersCollector.cs
Delta lines: +14 -23
===================================================================

--- 
DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/ClassProxyTargetContributor.cs
      2009-12-29 13:06:00 UTC (rev 6537)
+++ 
DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/ClassProxyTargetContributor.cs
      2009-12-29 15:29:22 UTC (rev 6538)
@@ -19,14 +19,13 @@
        using System.Diagnostics;
        using System.Reflection;
        using System.Reflection.Emit;
-       using Castle.Core.Logging;
+
        using Castle.DynamicProxy.Generators;
        using Castle.DynamicProxy.Generators.Emitters;
        using Castle.DynamicProxy.Generators.Emitters.SimpleAST;
 
        public class ClassProxyTargetContributor : CompositeTypeContributor
        {
-               private ILogger logger = NullLogger.Instance;
                private readonly Type targetType;
                private readonly IList<MethodInfo> methodsToSkip;
 
@@ -36,26 +35,19 @@
                        this.methodsToSkip = methodsToSkip;
                }
 
-               public ILogger Logger
-               {
-                       get { return logger; }
-                       set { logger = value; }
-               }
-
                public override void 
CollectElementsToProxy(IProxyGenerationHook hook)
                {
                        Debug.Assert(hook != null, "hook != null");
 
-                       var targetItem = new ClassMembersCollector(targetType, 
this) { Logger = logger };
+                       var targetItem = new ClassMembersCollector(targetType) 
{ Logger = Logger };
                        targetItem.CollectMembersToProxy(hook);
                        targets.Add(targetItem);
 
                        foreach (var @interface in interfaces)
                        {
                                var item = new 
InterfaceMembersOnClassCollector(@interface,
-                                                                               
this,
                                                                                
true,
-                                                                               
targetType.GetInterfaceMap(@interface));
+                                                                               
targetType.GetInterfaceMap(@interface)) { Logger = Logger };
                                item.CollectMembersToProxy(hook);
                                targets.Add(item);
                        }
@@ -91,23 +83,22 @@
                private Type BuildInvocationType(MethodToGenerate method, 
ClassEmitter @class, ProxyGenerationOptions options)
                {
                        var methodInfo = method.Method;
-                       var callback = default(MethodInfo);
-                       var targetForInvocation = targetType;
-                       if (!method.MethodOnTarget.IsAbstract && 
!IsExplicitInterfaceImplementation(method.MethodOnTarget))
+                       if (!method.HasTarget)
                        {
-                               callback = CreateCallbackMethod(@class, 
methodInfo, method.MethodOnTarget);
-                               targetForInvocation = callback.DeclaringType;
+                               return new 
ClassInvocationTypeGenerator(targetType,
+                                                                       method,
+                                                                       null)
+                                       .Generate(@class, options, namingScope)
+                                       .BuildType();
                        }
-                       return new 
ClassInvocationTypeGenerator(targetForInvocation,
+                       var callback = CreateCallbackMethod(@class, methodInfo, 
method.MethodOnTarget);
+                       return new 
ClassInvocationTypeGenerator(callback.DeclaringType,
                                                                method,
-                                                               
callback).Generate(@class, options, namingScope).BuildType();
+                                                               callback)
+                               .Generate(@class, options, namingScope)
+                               .BuildType();
                }
 
-               private bool IsExplicitInterfaceImplementation(MethodInfo 
methodInfo)
-               {
-                       return methodInfo.IsPrivate && methodInfo.IsFinal;
-               }
-
                private MethodBuilder CreateCallbackMethod(ClassEmitter 
emitter, MethodInfo methodInfo, MethodInfo methodOnTarget)
                {

File [modified]: ClassProxyTargetContributor.cs
Delta lines: +8 -0
===================================================================

--- 
DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/CompositeTypeContributor.cs
 2009-12-29 13:06:00 UTC (rev 6537)
+++ 
DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/CompositeTypeContributor.cs
 2009-12-29 15:29:22 UTC (rev 6538)
@@ -18,6 +18,7 @@
        using System.Collections.Generic;
        using System.Diagnostics;
 
+       using Castle.Core.Logging;
        using Castle.DynamicProxy.Generators;
        using Castle.DynamicProxy.Generators.Emitters;
 
@@ -26,12 +27,19 @@
                protected readonly INamingScope namingScope;
                protected readonly ICollection<Type> interfaces = new 
List<Type>();
                protected readonly ICollection<MembersCollector> targets = new 
List<MembersCollector>();
+               private ILogger logger = NullLogger.Instance;
 
                protected CompositeTypeContributor(INamingScope namingScope)
                {
                        this.namingScope = namingScope;
                }
 
+               public ILogger Logger
+               {
+                       get { return logger; }
+                       set { logger = value; }
+               }
+
                public abstract void 
CollectElementsToProxy(IProxyGenerationHook hook);
 

File [modified]: CompositeTypeContributor.cs
Delta lines: +3 -15
===================================================================

--- 
DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/InterfaceMembersCollector.cs
        2009-12-29 13:06:00 UTC (rev 6537)
+++ 
DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/InterfaceMembersCollector.cs
        2009-12-29 15:29:22 UTC (rev 6538)
@@ -20,24 +20,12 @@
 
        public class InterfaceMembersCollector : MembersCollector
        {
-               private static readonly InterfaceMapping EmptyInterfaceMapping 
= new InterfaceMapping { InterfaceMethods = new MethodInfo[0] };
                public InterfaceMembersCollector(Type @interface)
-                       : this(@interface, null, EmptyInterfaceMapping)
+                       : base(@interface)
                {
 
                }
 
-               public InterfaceMembersCollector(Type @interface, 
ITypeContributor contributor, InterfaceMapping map)
-                       : base(@interface, contributor, false, map)
-               {
-               }
-
-
-               protected override MethodInfo GetMethodOnTarget(MethodInfo 
method)
-               {
-                       return method;
-               }
-
                protected override MethodToGenerate 
GetMethodToGenerate(MethodInfo method, IProxyGenerationHook hook, bool 
isStandalone)
                {
                        if (!IsAccessible(method))
@@ -45,8 +33,8 @@
                                return null;
                        }
 
-                       var proxyable = AcceptMethod(method, onlyProxyVirtual, 
hook);
-                       return new MethodToGenerate(method, isStandalone, 
contributor, GetMethodOnTarget(method), proxyable);
+                       var proxyable = AcceptMethod(method, false, hook);
+                       return new MethodToGenerate(method, method, 
isStandalone, proxyable, false);
                }
 

File [modified]: InterfaceMembersCollector.cs
Delta lines: +19 -13
===================================================================

--- 
DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/InterfaceMembersOnClassCollector.cs
 2009-12-29 13:06:00 UTC (rev 6537)
+++ 
DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/InterfaceMembersOnClassCollector.cs
 2009-12-29 15:29:22 UTC (rev 6538)
@@ -6,13 +6,17 @@
 
        public class InterfaceMembersOnClassCollector : MembersCollector
        {
-               public InterfaceMembersOnClassCollector(Type type, 
ITypeContributor contributor, bool onlyProxyVirtual, InterfaceMapping map) : 
base(type, contributor, onlyProxyVirtual, map)
+               private readonly bool onlyProxyVirtual;
+               private readonly InterfaceMapping map;
+
+               public InterfaceMembersOnClassCollector(Type type, bool 
onlyProxyVirtual, InterfaceMapping map) : base(type)
                {
+                       this.onlyProxyVirtual = onlyProxyVirtual;
+                       this.map = map;
                }
 
                protected override MethodToGenerate 
GetMethodToGenerate(MethodInfo method, IProxyGenerationHook hook, bool 
isStandalone)
                {
-                       // This is here, so that we don't add multiple times 
property getters/setters and event add/remove methods
                        if (!IsAccessible(method))
                        {
                                return null;
@@ -24,24 +28,26 @@
                        }
 
                        var methodOnTarget = GetMethodOnTarget(method);
-                       ITypeContributor target;
-                       if (methodOnTarget.IsPrivate)//explicitly implemented
+
+                       var proxyable = AcceptMethod(method, onlyProxyVirtual, 
hook);
+                       return new MethodToGenerate(method, methodOnTarget, 
isStandalone, proxyable, methodOnTarget.IsPrivate == false);
+               }
+
+               private MethodInfo GetMethodOnTarget(MethodInfo method)
+               {
+                       int index = Array.IndexOf(map.InterfaceMethods, method);
+                       if (index == -1)
                        {
-                               target = null;
+                               return null;
                        }
-                       else
-                       {
-                               target = contributor;
-                       }
 
-                       var proxyable = AcceptMethod(method, onlyProxyVirtual, 
hook);
-                       return new MethodToGenerate(method, isStandalone, 
target, methodOnTarget, proxyable);
+                       return map.TargetMethods[index];
                }
 
                private bool IsVirtuallyImplementedInterfaceMethod(MethodInfo 
method)
                {
-                       var index = Array.IndexOf(map.InterfaceMethods, method);
-                       return index != -1 && map.TargetMethods[index].IsFinal 
== false;
+                       var info = GetMethodOnTarget(method);
+                       return info != null && info.IsFinal == false;
                }
        }
 }

File [modified]: InterfaceMembersOnClassCollector.cs
Delta lines: +4 -4
===================================================================

--- 
DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/InterfaceProxyTargetContributor.cs
  2009-12-29 13:06:00 UTC (rev 6537)
+++ 
DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/InterfaceProxyTargetContributor.cs
  2009-12-29 15:29:22 UTC (rev 6538)
@@ -16,7 +16,6 @@
 {
        using System;
        using System.Diagnostics;
-       using System.Reflection;
 
        using Castle.Core.Interceptor;
        using Castle.DynamicProxy.Generators;
@@ -40,15 +39,16 @@
 
                        foreach (var @interface in interfaces)
                        {
-                               var item = new 
InterfaceMembersOnClassCollector(@interface, this, false, 
GetMapping(@interface));
+                               var item = GetCollectorForInterface(@interface);
+                               item.Logger = Logger;
                                item.CollectMembersToProxy(hook);
                                targets.Add(item);
                        }
                }
 
-               protected virtual InterfaceMapping GetMapping(Type @interface)
+               protected virtual MembersCollector 
GetCollectorForInterface(Type @interface)
                {
-                       return proxyTargetType.GetInterfaceMap(@interface);
+                       return new InterfaceMembersOnClassCollector(@interface, 
false, proxyTargetType.GetInterfaceMap(@interface));
                }
 

File [modified]: InterfaceProxyTargetContributor.cs
Delta lines: +3 -7
===================================================================

--- 
DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/InterfaceProxyWithTargetInterfaceTargetContributor.cs
       2009-12-29 13:06:00 UTC (rev 6537)
+++ 
DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/InterfaceProxyWithTargetInterfaceTargetContributor.cs
       2009-12-29 15:29:22 UTC (rev 6538)
@@ -15,18 +15,14 @@
 namespace Castle.DynamicProxy.Contributors
 {
        using System;
-       using System.Reflection;
+
        using Generators;
 
        public class InterfaceProxyWithTargetInterfaceTargetContributor : 
InterfaceProxyTargetContributor
        {
-               protected override InterfaceMapping GetMapping(Type @interface)
+               protected override MembersCollector 
GetCollectorForInterface(Type @interface)
                {
-                       var mapping = new InterfaceMapping();
-                       var methods = 
MethodFinder.GetAllInstanceMethods(@interface, BindingFlags.Public | 
BindingFlags.Instance);
-                       mapping.InterfaceMethods = methods;
-                       mapping.TargetMethods = methods;
-                       return mapping;
+                       return new InterfaceMembersCollector(@interface);
                }
 

File [modified]: InterfaceProxyWithTargetInterfaceTargetContributor.cs
Delta lines: +2 -20
===================================================================

--- DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/MembersCollector.cs 
2009-12-29 13:06:00 UTC (rev 6537)
+++ DynamicProxy/trunk/src/Castle.DynamicProxy/Contributors/MembersCollector.cs 
2009-12-29 15:29:22 UTC (rev 6538)
@@ -24,8 +24,6 @@
        {
                private const BindingFlags Flags = BindingFlags.Public | 
BindingFlags.NonPublic | BindingFlags.Instance;
 
-               protected readonly bool onlyProxyVirtual;
-               protected readonly InterfaceMapping map;
                private ILogger logger = NullLogger.Instance;
                private IList<MethodInfo> checkedMethods = new 
List<MethodInfo>();
                private readonly IDictionary<PropertyInfo, PropertyToGenerate> 
properties = new Dictionary<PropertyInfo, PropertyToGenerate>();
@@ -33,14 +31,9 @@
                private readonly IDictionary<MethodInfo, MethodToGenerate> 
methodsToProxy = new Dictionary<MethodInfo, MethodToGenerate>();
                private readonly Type type;
 
-               protected readonly ITypeContributor contributor;
-
-               protected MembersCollector(Type type, ITypeContributor 
contributor, bool onlyProxyVirtual, InterfaceMapping map)
+               protected MembersCollector(Type type)
                {
                        this.type = type;
-                       this.contributor = contributor;
-                       this.onlyProxyVirtual = onlyProxyVirtual;
-                       this.map = map;
                }
 
                public ILogger Logger
@@ -66,7 +59,7 @@
 
                public void CollectMembersToProxy(IProxyGenerationHook hook)
                {
-                       if(checkedMethods==null)// this method was already 
called!
+                       if (checkedMethods == null)// this method was already 
called!
                        {
                                throw new InvalidOperationException("Can't call 
CollectMembersToProxy twice");
                        }
@@ -187,17 +180,6 @@
 
                protected abstract MethodToGenerate 
GetMethodToGenerate(MethodInfo method, IProxyGenerationHook hook, bool 
isStandalone);
 
-               protected virtual MethodInfo GetMethodOnTarget(MethodInfo 
method)
-               {
-                       int index = Array.IndexOf(map.InterfaceMethods, method);
-                       if (index == -1)
-                       {
-                               return null;
-                       }
-
-                       return map.TargetMethods[index];
-               }
-
                /// <summary>
                /// Checks if the method is public or protected.

File [modified]: MembersCollector.cs
Delta lines: +1 -1
===================================================================

--- 
DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/ClassInvocationTypeGenerator.cs
       2009-12-29 13:06:00 UTC (rev 6537)
+++ 
DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/ClassInvocationTypeGenerator.cs
       2009-12-29 15:29:22 UTC (rev 6538)
@@ -25,7 +25,7 @@
        {
                public static readonly Type BaseType = 
typeof(InheritanceInvocation);
 
-               public ClassInvocationTypeGenerator(Type targetType, 
IProxyMethod method, MethodInfo callback)
+               public ClassInvocationTypeGenerator(Type targetType, 
MethodToGenerate method, MethodInfo callback)
                        : base(targetType, method, callback, false)
                {

Directory: /DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/
==================================================================

File [modified]: ClassInvocationTypeGenerator.cs
Delta lines: +4 -2
===================================================================

--- 
DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/ClassProxyGenerator.cs    
    2009-12-29 13:06:00 UTC (rev 6537)
+++ 
DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/ClassProxyGenerator.cs    
    2009-12-29 15:29:22 UTC (rev 6538)
@@ -168,7 +168,7 @@
                        var targetInterfaces = 
TypeUtil.GetAllInterfaces(targetType);
                        var additionalInterfaces = 
TypeUtil.GetAllInterfaces(interfaces);
                        // 2. then mixins
-                       var mixins = new MixinContributor(namingScope, false);
+                       var mixins = new MixinContributor(namingScope, false) { 
Logger = Logger };
                        if (ProxyGenerationOptions.HasMixins)
                        {
                                foreach (var mixinInterface in 
ProxyGenerationOptions.MixinData.MixinInterfaces)
@@ -194,7 +194,9 @@
                                        }
                                }
                        }
-                       var additionalInterfacesContributor = new 
InterfaceProxyWithoutTargetContributor(namingScope, (c, m) => 
NullExpression.Instance);
+                       var additionalInterfacesContributor = new 
InterfaceProxyWithoutTargetContributor(namingScope,
+                                                                               
                         (c, m) => NullExpression.Instance)
+                       { Logger = Logger };
                        // 3. then additional interfaces
                        foreach (var @interface in additionalInterfaces)

File [modified]: ClassProxyGenerator.cs
Delta lines: +0 -25
===================================================================

--- DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/IProxyMethod.cs       
2009-12-29 13:06:00 UTC (rev 6537)
+++ DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/IProxyMethod.cs       
2009-12-29 15:29:22 UTC (rev 6538)
@@ -1,25 +0,0 @@
-// Copyright 2004-2009 Castle Project - http://www.castleproject.org/
-// 
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-// 
-//     http://www.apache.org/licenses/LICENSE-2.0
-// 
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-namespace Castle.DynamicProxy.Generators
-{
-       using System.Reflection;
-
-       public interface IProxyMethod
-       {
-               MethodInfo Method { get; }
-
-               bool HasTarget { get; }
-       }
-}

File [removed]: IProxyMethod.cs
Delta lines: +1 -1
===================================================================

--- 
DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/InterfaceInvocationTypeGenerator.cs
   2009-12-29 13:06:00 UTC (rev 6537)
+++ 
DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/InterfaceInvocationTypeGenerator.cs
   2009-12-29 15:29:22 UTC (rev 6538)
@@ -27,7 +27,7 @@
        {
                public static readonly Type BaseType = 
typeof(CompositionInvocation);
 
-               public InterfaceInvocationTypeGenerator(Type target, 
IProxyMethod method, MethodInfo callback, bool canChangeTarget)
+               public InterfaceInvocationTypeGenerator(Type target, 
MethodToGenerate method, MethodInfo callback, bool canChangeTarget)
                        : base(target, method, callback, canChangeTarget)
                {

File [modified]: InterfaceInvocationTypeGenerator.cs
Delta lines: +4 -3
===================================================================

--- 
DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/InterfaceProxyWithTargetGenerator.cs
  2009-12-29 13:06:00 UTC (rev 6537)
+++ 
DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/InterfaceProxyWithTargetGenerator.cs
  2009-12-29 15:29:22 UTC (rev 6538)
@@ -227,7 +227,7 @@
                protected virtual IDictionary<Type, ITypeContributor> 
GetTypeImplementerMapping(Type[] interfaces, Type proxyTargetType, out 
IEnumerable<ITypeContributor> contributors, INamingScope namingScope)
                {
                        IDictionary<Type, ITypeContributor> 
typeImplementerMapping = new Dictionary<Type, ITypeContributor>();
-                       var mixins = new 
MixinContributor(namingScope,AllowChangeTarget);
+                       var mixins = new MixinContributor(namingScope, 
AllowChangeTarget) { Logger = Logger };
                        // Order of interface precedence:
                        // 1. first target
                        var targetInterfaces = 
TypeUtil.GetAllInterfaces(proxyTargetType);
@@ -296,7 +296,7 @@
 
                protected virtual InterfaceProxyWithoutTargetContributor 
GetContributorForAdditionalInterfaces(INamingScope namingScope)
                {
-                       return new 
InterfaceProxyWithoutTargetContributor(namingScope, (c, m) => 
NullExpression.Instance);
+                       return new 
InterfaceProxyWithoutTargetContributor(namingScope, (c, m) => 
NullExpression.Instance) { Logger = Logger }; ;
                }
 
                protected override void SafeAddMapping(Type @interface, 
ITypeContributor implementer, IDictionary<Type, ITypeContributor> mapping)
@@ -311,7 +311,8 @@
 
                protected virtual ITypeContributor 
AddMappingForTargetType(IDictionary<Type, ITypeContributor> 
typeImplementerMapping, Type proxyTargetType, ICollection<Type> 
targetInterfaces, ICollection<Type> additionalInterfaces,INamingScope 
namingScope)
                {
-                       var contributor = new 
InterfaceProxyTargetContributor(proxyTargetType, AllowChangeTarget, 
namingScope);
+                       var contributor = new 
InterfaceProxyTargetContributor(proxyTargetType, AllowChangeTarget, namingScope)
+                       { Logger = Logger };
                        var proxiedInterfaces = 
TypeUtil.GetAllInterfaces(targetType);
                        foreach (var @interface in proxiedInterfaces)

File [modified]: InterfaceProxyWithTargetGenerator.cs
Delta lines: +6 -3
===================================================================

--- 
DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/InterfaceProxyWithTargetInterfaceGenerator.cs
 2009-12-29 13:06:00 UTC (rev 6537)
+++ 
DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/InterfaceProxyWithTargetInterfaceGenerator.cs
 2009-12-29 15:29:22 UTC (rev 6538)
@@ -27,12 +27,14 @@
        {
                protected override ITypeContributor 
AddMappingForTargetType(IDictionary<Type, ITypeContributor> 
typeImplementerMapping, Type proxyTargetType, ICollection<Type> 
targetInterfaces, ICollection<Type> additionalInterfaces, INamingScope 
namingScope)
                {
-                       var contributor = new 
InterfaceProxyWithTargetInterfaceTargetContributor(proxyTargetType, 
AllowChangeTarget,
-                                                                               
                                                                                
         namingScope);
+                       var contributor = new 
InterfaceProxyWithTargetInterfaceTargetContributor(proxyTargetType,
+                                                                               
                 AllowChangeTarget,
+                                                                               
                 namingScope) { Logger = Logger };
                        foreach (var @interface in 
TypeUtil.GetAllInterfaces(targetType))
                        {
                                SafeAddMapping(@interface, contributor, 
typeImplementerMapping);
                        }
+
                        return contributor;
                }
 
@@ -40,7 +42,8 @@
                {
                        return new InterfaceProxyWithoutTargetContributor(
                                namingScope,
-                               (@class, method) => new 
AsTypeReference(@class.GetField("__target"), 
method.DeclaringType).ToExpression());
+                               (@class, method) => new 
AsTypeReference(@class.GetField("__target"), 
method.DeclaringType).ToExpression())
+                       { Logger = Logger };
                }
 

File [modified]: InterfaceProxyWithTargetInterfaceGenerator.cs
Delta lines: +2 -1
===================================================================

--- 
DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/InterfaceProxyWithoutTargetGenerator.cs
       2009-12-29 13:06:00 UTC (rev 6537)
+++ 
DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/InterfaceProxyWithoutTargetGenerator.cs
       2009-12-29 15:29:22 UTC (rev 6538)
@@ -30,7 +30,8 @@
 
                protected override ITypeContributor 
AddMappingForTargetType(IDictionary<Type, ITypeContributor> 
interfaceTypeImplementerMapping, Type proxyTargetType, ICollection<Type> 
targetInterfaces, ICollection<Type> additionalInterfaces, INamingScope 
namingScope)
                {
-                       var contributor = new 
InterfaceProxyWithoutTargetContributor(namingScope, (c, m) => 
NullExpression.Instance);
+                       var contributor = new 
InterfaceProxyWithoutTargetContributor(namingScope, (c, m) => 
NullExpression.Instance)
+                       { Logger = Logger };
                        foreach (var @interface in 
TypeUtil.GetAllInterfaces(targetType))
                        {

File [modified]: InterfaceProxyWithoutTargetGenerator.cs
Delta lines: +3 -7
===================================================================

--- 
DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/InvocationTypeGenerator.cs
    2009-12-29 13:06:00 UTC (rev 6537)
+++ 
DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/InvocationTypeGenerator.cs
    2009-12-29 15:29:22 UTC (rev 6538)
@@ -25,11 +25,11 @@
        public abstract class InvocationTypeGenerator : 
IGenerator<AbstractTypeEmitter>
        {
                private readonly Type targetType;
-               private readonly IProxyMethod method;
+               private readonly MethodToGenerate method;
                private readonly MethodInfo callback;
                private readonly bool canChangeTarget;
 
-               protected InvocationTypeGenerator(Type targetType, IProxyMethod 
method, MethodInfo callback, bool canChangeTarget)
+               protected InvocationTypeGenerator(Type targetType, 
MethodToGenerate method, MethodInfo callback, bool canChangeTarget)
                {
                        this.targetType = targetType;
                        this.method = method;
@@ -75,10 +75,6 @@
                        {
                                ImplemementInvokeMethodOnTarget(type, 
methodInfo.GetParameters(), targetField, callback);
                        }
-                       else if (method.HasTarget)
-                       {
-                               ImplemementInvokeMethodOnTarget(type, 
methodInfo.GetParameters(), targetField, methodInfo);
-                       }
                        else
                        {
                                CreateEmptyIInvocationInvokeOnTarget(type);
@@ -226,7 +222,7 @@
 
                        if (callbackMethod.ReturnType != typeof(void))
                        {
-                               MethodInvocationExpression setRetVal =
+                               var setRetVal =
                                        new 
MethodInvocationExpression(SelfReference.Self,
                                                                                
                   InvocationMethods.SetReturnValue,

File [modified]: InvocationTypeGenerator.cs
Delta lines: +14 -38
===================================================================

--- DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/MethodToGenerate.cs   
2009-12-29 13:06:00 UTC (rev 6537)
+++ DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/MethodToGenerate.cs   
2009-12-29 15:29:22 UTC (rev 6538)
@@ -14,53 +14,29 @@
 
 namespace Castle.DynamicProxy.Generators
 {
+       using System.Diagnostics;
        using System.Reflection;
-       using Contributors;
 
-       public class MethodToGenerate : IProxyMethod
+       public class MethodToGenerate
        {
-               private readonly bool standalone;
-               private readonly MethodInfo methodOnTarget;
-               private readonly bool proxyable;
-               private readonly MethodInfo method;
-               private readonly ITypeContributor target;
-
-               public MethodToGenerate(MethodInfo method, bool standalone, 
ITypeContributor target, MethodInfo methodOnTarget, bool proxyable)
+               public MethodToGenerate(MethodInfo method, MethodInfo 
methodOnTarget, bool standalone, bool proxyable, bool hasTarget)
                {
-                       this.method = method;
-                       this.target = target;
-                       this.standalone = standalone;
-                       this.methodOnTarget = methodOnTarget;
-                       this.proxyable = proxyable;
+                       Debug.Assert(method != null, "method != null");
+                       Method = method;
+                       MethodOnTarget = methodOnTarget;
+                       Standalone = standalone;
+                       Proxyable = proxyable;
+                       HasTarget = hasTarget;
                }
 
-               public bool Proxyable
-               {
-                       get { return proxyable; }
-               }
+               public bool Proxyable { get; private set; }
 
-               public MethodInfo MethodOnTarget
-               {
-                       get { return methodOnTarget; }
-               }
+               public MethodInfo MethodOnTarget { get; private set; }
 
-               public bool Standalone
-               {
-                       get { return standalone; }
-               }
+               public bool Standalone { get; private set; }
 
-               public MethodInfo Method
-               {
-                       get { return method; }
-               }
+               public MethodInfo Method { get; private set; }
 
-               public bool HasTarget
-               {
-                       get
-                       {
-                               return target != null;
-                       }
-               }
-
+               public bool HasTarget { get; private set; }
        }
 }

File [modified]: MethodToGenerate.cs
Delta lines: +3 -3
===================================================================

--- DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/PropertyToGenerate.cs 
2009-12-29 13:06:00 UTC (rev 6537)
+++ DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/PropertyToGenerate.cs 
2009-12-29 15:29:22 UTC (rev 6538)
@@ -41,14 +41,14 @@
                        this.customAttributes = customAttributes;
                }
 
-               private string GetName(string name, IProxyMethod getter, 
IProxyMethod setter)
+               private string GetName(string name, MethodToGenerate getter, 
MethodToGenerate setter)
                {
                        Type declaringType = null;
-                       if(getter!=null)
+                       if (getter != null)
                        {
                                declaringType = getter.Method.DeclaringType;
                        }
-                       else if(setter!=null)
+                       else if (setter != null)
                        {
                                declaringType = setter.Method.DeclaringType;

File [modified]: PropertyToGenerate.cs
Delta lines: +4 -8
===================================================================

--- 
DynamicProxy/trunk/src/Castle.DynamicProxy.Tests/ExplicitInterfaceTestCase.cs   
    2009-12-29 13:06:00 UTC (rev 6537)
+++ 
DynamicProxy/trunk/src/Castle.DynamicProxy.Tests/ExplicitInterfaceTestCase.cs   
    2009-12-29 15:29:22 UTC (rev 6538)
@@ -12,15 +12,11 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-using Castle.DynamicProxy.Tests.Classes;
-
 namespace Castle.DynamicProxy.Tests
 {
-       using System;
-       using Core.Interceptor;
-       using Interceptors;
-       using InterClasses;
-       using Mixins;
+       using Castle.DynamicProxy.Tests.Classes;
+       using Castle.DynamicProxy.Tests.Interceptors;
+
        using NUnit.Framework;
 
        [TestFixture]
@@ -66,7 +62,7 @@
                }
 
                [Test]
-               public void 
ExplicitInterface_AsAdditionalInterfaceToProxy_OnClassProxy_WithoutBaseCalls ()
+               public void 
ExplicitInterface_AsAdditionalInterfaceToProxy_OnClassProxy_WithoutBaseCalls()
                {
                        LogInvocationInterceptor interceptor = new 
LogInvocationInterceptor ();

--

You received this message because you are subscribed to the Google Groups 
"Castle Project Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/castle-project-commits?hl=en.


Reply via email to