- linfu_src.zip
- LinFu.Common
- LinFu.Delegates
- LinFu.DynamicProxy
- LinFu.License.txt
- LinFu.Reflection
- NMock2.dll
- nunit.core.dll
- nunit.framework.dll
- Simple.IoC
- Simple.IoC.Loaders
- Simple.IoC.Tests
- Simple.IoC
- linfupart3_samples.zip
- LinFu.Delegates.Examples
- AdaptingClosuresToAnyDelegateSignature
- bin
- LinFu.Common.dll
- LinFu.Delegates.dll
- LinFu.DynamicProxy.dll
- LinFu.Reflection.dll
- BindingAndUnbindingClosureParameters
- CallingDelegatesBoundToClosuresWithClosedArguments
- ClosuresAndDynamicallyGeneratedMethods
- DelegatesAndArgumentBinding
- InstanceMethodBinding
- LinFu.Delegates.Examples.sln
- NestedClosures
- StaticMethodBinding
- UniversalEventHandling
- UsingClosuresWithDynamicObjects
- LinFu.License.txt
- linfu_bin.zip
- LinFu.Common.dll
- LinFu.Delegates.dll
- LinFu.DynamicProxy.dll
- LinFu.License.txt
- LinFu.Reflection.dll
- NMock2.dll
- nunit.core.dll
- nunit.framework.dll
- Simple.IoC.dll
- Simple.IoC.Loaders.dll
|
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
namespace LinFu.DynamicProxy
{
internal class DefaultyProxyMethodBuilder : IProxyMethodBuilder
{
private IMethodBodyEmitter _emitter;
public DefaultyProxyMethodBuilder() : this(new DefaultMethodEmitter())
{
}
public DefaultyProxyMethodBuilder(IMethodBodyEmitter emitter)
{
_emitter = emitter;
}
public IMethodBodyEmitter MethodBodyEmitter
{
get { return _emitter; }
set { _emitter = value; }
}
#region IProxyMethodBuilder Members
public void CreateProxiedMethod(FieldInfo field, MethodInfo method, TypeBuilder typeBuilder)
{
ParameterInfo[] parameters = method.GetParameters();
List<Type> parameterTypes = new List<Type>();
foreach (ParameterInfo param in parameters)
{
parameterTypes.Add(param.ParameterType);
}
MethodAttributes methodAttributes = MethodAttributes.Public | MethodAttributes.HideBySig |
MethodAttributes.Virtual;
MethodBuilder methodBuilder = typeBuilder.DefineMethod(method.Name, methodAttributes,
CallingConventions.HasThis, method.ReturnType,
parameterTypes.ToArray());
Type[] typeArgs = method.GetGenericArguments();
if (typeArgs != null && typeArgs.Length > 0)
{
List<string> typeNames = new List<string>();
for (int index = 0; index < typeArgs.Length; index++)
{
typeNames.Add(string.Format("T{0}", index));
}
methodBuilder.DefineGenericParameters(typeNames.ToArray());
}
ILGenerator IL = methodBuilder.GetILGenerator();
Debug.Assert(_emitter != null);
_emitter.EmitMethodBody(IL, method, field);
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.