resolved SPRNET-1109, SPRNET-1095
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
#region License
|
||||
|
||||
/*
|
||||
* Copyright <20> 2002-2008 the original author or authors.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
#region Imports
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.EnterpriseServices;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Xml;
|
||||
using Spring.Context.Support;
|
||||
using Spring.Objects;
|
||||
using Spring.Util;
|
||||
|
||||
#endregion
|
||||
|
||||
/*
|
||||
The code below is only for reverse engineering generated code in reflector
|
||||
*/
|
||||
namespace Spring.EnterpriseServices
|
||||
{
|
||||
internal interface ITestInterface
|
||||
{
|
||||
void Method();
|
||||
}
|
||||
|
||||
internal delegate object GetObjectHandler(ServicedComponent component, string targetName);
|
||||
|
||||
|
||||
internal class ExportedServicedComponentSample : ServicedComponent, ITestInterface
|
||||
{
|
||||
protected static GetObjectHandler getObject;
|
||||
|
||||
static ExportedServicedComponentSample()
|
||||
{
|
||||
try
|
||||
{
|
||||
// in case we're dealing w/ unsigned assemblies, that is the way to go...
|
||||
string path = Path.Combine( new FileInfo(Assembly.GetExecutingAssembly().Location).DirectoryName, "Spring.Services.dll");
|
||||
Assembly a = Assembly.LoadFrom(path);
|
||||
if (a == null)
|
||||
{
|
||||
a = Assembly.Load("Spring.Services, Version=1.2.0.20001, Culture=neutral, PublicKeyToken=null");
|
||||
}
|
||||
Type t = a.GetType("Spring.EnterpriseServices.ServicedComponentHelper", true);
|
||||
getObject = (GetObjectHandler) Delegate.CreateDelegate(typeof(GetObjectHandler), t.GetMethod("GetObject"));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Trace.WriteLine(ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void Method()
|
||||
{
|
||||
ITestInterface targetInstance = (ITestInterface) getObject(null, "name");
|
||||
targetInstance.Method();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,11 +71,10 @@ namespace Spring.EnterpriseServices
|
||||
|
||||
#region Private helpers classes
|
||||
|
||||
// private delegate Type CreateWrapperTypeHandler(ModuleBuilder module, Type baseType, IObjectFactory objectFactory, bool useSpring);
|
||||
|
||||
private Type CreateWrapperType(ServicedComponentExporter exporter, Type type)
|
||||
{
|
||||
MethodInfo createWrapperTypeMethodInfo = typeof(ServicedComponentExporter).GetMethod("CreateWrapperType", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
Assert.IsNotNull(createWrapperTypeMethodInfo);
|
||||
|
||||
AssemblyName an = new AssemblyName();
|
||||
an.Name = "Spring.EnterpriseServices.Tests";
|
||||
AssemblyBuilder proxyAssembly = AppDomain.CurrentDomain.DefineDynamicAssembly(an, AssemblyBuilderAccess.RunAndSave);
|
||||
@@ -84,7 +83,7 @@ namespace Spring.EnterpriseServices
|
||||
IDynamicMock mockObjectFactory = new DynamicMock(typeof(IObjectFactory));
|
||||
mockObjectFactory.ExpectAndReturn("GetType", type, new object[]{ exporter.TargetName });
|
||||
|
||||
object result = createWrapperTypeMethodInfo.Invoke(exporter, new object[] { module, mockObjectFactory.Object });
|
||||
object result = exporter.CreateWrapperType(module, typeof(ServicedComponent), (IObjectFactory) mockObjectFactory.Object, false); //createWrapperTypeMethodInfo.Invoke(exporter, new object[] { module, mockObjectFactory.Object });
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsTrue(result is Type);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<VisualStudioProject>
|
||||
<CSHARP
|
||||
ProjectType = "Local"
|
||||
ProductVersion = "7.10.3077"
|
||||
ProductVersion = "7.10.6030"
|
||||
SchemaVersion = "2.0"
|
||||
ProjectGuid = "{EB2687B7-8B26-4FBC-852A-4128D5CACAFC}"
|
||||
>
|
||||
@@ -178,6 +178,10 @@
|
||||
RelPath = "Data\Spring\Remoting\saoSingleton-aop.xml"
|
||||
BuildAction = "EmbeddedResource"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Data\Spring\Remoting\saoSingleton-autowired.xml"
|
||||
BuildAction = "Content"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Data\Spring\Web\Services\configurableFactory.xml"
|
||||
BuildAction = "EmbeddedResource"
|
||||
@@ -202,6 +206,11 @@
|
||||
RelPath = "Data\Spring\Web\Services\Service.cs.fyi"
|
||||
BuildAction = "None"
|
||||
/>
|
||||
<File
|
||||
RelPath = "EnterpriseServices\ExportedServicedComponentSample.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "EnterpriseServices\ServicedComponentExporterTests.cs"
|
||||
SubType = "Code"
|
||||
|
||||
@@ -96,6 +96,7 @@
|
||||
<Compile Include="AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="EnterpriseServices\ExportedServicedComponentSample.cs" />
|
||||
<Compile Include="EnterpriseServices\ServicedComponentExporterTests.cs" />
|
||||
<Compile Include="Remoting\BaseRemotingTestFixture.cs" />
|
||||
<Compile Include="Remoting\CaoExporterTests.cs">
|
||||
|
||||
Reference in New Issue
Block a user