Merge pull request #48 from ohadho/master
Allow CompositionProxyTypeBuilder to proxy objects with protected constructors
This commit is contained in:
@@ -197,8 +197,8 @@ namespace Spring.Proxy
|
||||
{
|
||||
il.Emit(OpCodes.Ldarg_S, i);
|
||||
}
|
||||
il.Emit(OpCodes.Newobj, TargetType.GetConstructor(
|
||||
ReflectionUtils.GetParameterTypes(constructor.GetParameters())));
|
||||
|
||||
il.Emit(OpCodes.Newobj, constructor);
|
||||
il.Emit(OpCodes.Stfld, targetInstance);
|
||||
}
|
||||
|
||||
|
||||
@@ -169,6 +169,14 @@ namespace Spring.Context.Support
|
||||
IApplicationContext context = ContextRegistry.GetContext("bingo");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanBuildProxyForClassWithProtectedConstructor()
|
||||
{
|
||||
CompositionProxyTypeBuilder typeBuilder = new CompositionProxyTypeBuilder();
|
||||
typeBuilder.TargetType = typeof(ClassWithProtectedCtor);
|
||||
typeBuilder.BuildProxyType();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ClearWithDynamicProxies()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace Spring.Objects
|
||||
{
|
||||
public class ClassWithProtectedCtor : IOther
|
||||
{
|
||||
protected ClassWithProtectedCtor()
|
||||
{
|
||||
}
|
||||
|
||||
public void Absquatulate()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -339,6 +339,7 @@
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="HookableContextHandler.cs" />
|
||||
<Compile Include="Objects\ClassWithProtectedCtor.cs" />
|
||||
<Compile Include="Objects\ExpressionTestObject.cs" />
|
||||
<Compile Include="Objects\Factory\Attributes\PostConstructAttributeTests.cs" />
|
||||
<Compile Include="Objects\Factory\Attributes\AutowireByTypeNormalTests.cs" />
|
||||
|
||||
Reference in New Issue
Block a user