Author: hammett Date: Fri Jun 25 22:01:51 2004 New Revision: 22116 Added: avalon/trunk/central/laboratory/avalon-net/DynamicProxy/DynamicProxyTest/IMyInterface.cs (contents, props changed) avalon/trunk/central/laboratory/avalon-net/DynamicProxy/DynamicProxyTest/IMySecondInterface.cs (contents, props changed) avalon/trunk/central/laboratory/avalon-net/DynamicProxy/DynamicProxyTest/IServiceStatus.cs (contents, props changed) avalon/trunk/central/laboratory/avalon-net/DynamicProxy/DynamicProxyTest/MyInterfaceImpl.cs (contents, props changed) avalon/trunk/central/laboratory/avalon-net/DynamicProxy/DynamicProxyTest/MySecondInterfaceImpl.cs (contents, props changed) avalon/trunk/central/laboratory/avalon-net/DynamicProxy/DynamicProxyTest/ServiceStatusImpl.cs (contents, props changed) avalon/trunk/central/laboratory/avalon-net/DynamicProxy/StandardInvocationHandler.cs (contents, props changed) Modified: avalon/trunk/central/laboratory/avalon-net/DynamicProxy/Apache.Avalon.DynamicProxy.csproj avalon/trunk/central/laboratory/avalon-net/DynamicProxy/AssemblyInfo.cs avalon/trunk/central/laboratory/avalon-net/DynamicProxy/DynamicProxy.sln avalon/trunk/central/laboratory/avalon-net/DynamicProxy/DynamicProxyTest/Apache.Avalon.DynamicProxy.Test.csproj avalon/trunk/central/laboratory/avalon-net/DynamicProxy/DynamicProxyTest/AssemblyInfo.cs avalon/trunk/central/laboratory/avalon-net/DynamicProxy/DynamicProxyTest/ProxyGeneratorTestCase.cs avalon/trunk/central/laboratory/avalon-net/DynamicProxy/IInvocationHandler.cs avalon/trunk/central/laboratory/avalon-net/DynamicProxy/ProxyGenerator.cs Log: Refactoring in test cases. Applied suggestion from Stefan Zobel (stefan.zobel at lycos.de) from Spring.Net devel list.
Modified: avalon/trunk/central/laboratory/avalon-net/DynamicProxy/Apache.Avalon.DynamicProxy.csproj ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/DynamicProxy/Apache.Avalon.DynamicProxy.csproj (original) +++ avalon/trunk/central/laboratory/avalon-net/DynamicProxy/Apache.Avalon.DynamicProxy.csproj Fri Jun 25 22:01:51 2004 @@ -1,105 +1,110 @@ -<VisualStudioProject> - <CSHARP - ProjectType = "Local" - ProductVersion = "7.10.3077" - SchemaVersion = "2.0" - ProjectGuid = "{70EE6AF2-1F6D-4CC5-A1B2-C3182F035F67}" - > - <Build> - <Settings - ApplicationIcon = "" - AssemblyKeyContainerName = "" - AssemblyName = "Apache.Avalon.DynamicProxy" - AssemblyOriginatorKeyFile = "" - DefaultClientScript = "JScript" - DefaultHTMLPageLayout = "Grid" - DefaultTargetSchema = "IE50" - DelaySign = "false" - OutputType = "Library" - PreBuildEvent = "" - PostBuildEvent = "" - RootNamespace = "Apache.Avalon.DynamicProxy" - RunPostBuildEvent = "OnBuildSuccess" - StartupObject = "" - > - <Config - Name = "Debug" - AllowUnsafeBlocks = "false" - BaseAddress = "285212672" - CheckForOverflowUnderflow = "false" - ConfigurationOverrideFile = "" - DefineConstants = "DEBUG;TRACE" - DocumentationFile = "" - DebugSymbols = "true" - FileAlignment = "4096" - IncrementalBuild = "false" - NoStdLib = "false" - NoWarn = "" - Optimize = "false" - OutputPath = "..\bin\" - RegisterForComInterop = "false" - RemoveIntegerChecks = "false" - TreatWarningsAsErrors = "false" - WarningLevel = "4" - /> - <Config - Name = "Release" - AllowUnsafeBlocks = "false" - BaseAddress = "285212672" - CheckForOverflowUnderflow = "false" - ConfigurationOverrideFile = "" - DefineConstants = "TRACE" - DocumentationFile = "" - DebugSymbols = "false" - FileAlignment = "4096" - IncrementalBuild = "false" - NoStdLib = "false" - NoWarn = "" - Optimize = "true" - OutputPath = "bin\Release\" - RegisterForComInterop = "false" - RemoveIntegerChecks = "false" - TreatWarningsAsErrors = "false" - WarningLevel = "4" - /> - </Settings> - <References> - <Reference - Name = "System" - AssemblyName = "System" - HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll" - /> - <Reference - Name = "System.Data" - AssemblyName = "System.Data" - HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll" - /> - <Reference - Name = "System.XML" - AssemblyName = "System.Xml" - HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll" - /> - </References> - </Build> - <Files> - <Include> - <File - RelPath = "AssemblyInfo.cs" - SubType = "Code" - BuildAction = "Compile" - /> - <File - RelPath = "IInvocationHandler.cs" - SubType = "Code" - BuildAction = "Compile" - /> - <File - RelPath = "ProxyGenerator.cs" - SubType = "Code" - BuildAction = "Compile" - /> - </Include> - </Files> - </CSHARP> -</VisualStudioProject> - +<VisualStudioProject> + <CSHARP + ProjectType = "Local" + ProductVersion = "7.10.3077" + SchemaVersion = "2.0" + ProjectGuid = "{70EE6AF2-1F6D-4CC5-A1B2-C3182F035F67}" + > + <Build> + <Settings + ApplicationIcon = "" + AssemblyKeyContainerName = "" + AssemblyName = "Apache.Avalon.DynamicProxy" + AssemblyOriginatorKeyFile = "" + DefaultClientScript = "JScript" + DefaultHTMLPageLayout = "Grid" + DefaultTargetSchema = "IE50" + DelaySign = "false" + OutputType = "Library" + PreBuildEvent = "" + PostBuildEvent = "" + RootNamespace = "Apache.Avalon.DynamicProxy" + RunPostBuildEvent = "OnBuildSuccess" + StartupObject = "" + > + <Config + Name = "Debug" + AllowUnsafeBlocks = "false" + BaseAddress = "285212672" + CheckForOverflowUnderflow = "false" + ConfigurationOverrideFile = "" + DefineConstants = "DEBUG;TRACE" + DocumentationFile = "" + DebugSymbols = "true" + FileAlignment = "4096" + IncrementalBuild = "false" + NoStdLib = "false" + NoWarn = "" + Optimize = "false" + OutputPath = "..\bin\" + RegisterForComInterop = "false" + RemoveIntegerChecks = "false" + TreatWarningsAsErrors = "false" + WarningLevel = "4" + /> + <Config + Name = "Release" + AllowUnsafeBlocks = "false" + BaseAddress = "285212672" + CheckForOverflowUnderflow = "false" + ConfigurationOverrideFile = "" + DefineConstants = "TRACE" + DocumentationFile = "" + DebugSymbols = "false" + FileAlignment = "4096" + IncrementalBuild = "false" + NoStdLib = "false" + NoWarn = "" + Optimize = "true" + OutputPath = "bin\Release\" + RegisterForComInterop = "false" + RemoveIntegerChecks = "false" + TreatWarningsAsErrors = "false" + WarningLevel = "4" + /> + </Settings> + <References> + <Reference + Name = "System" + AssemblyName = "System" + HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll" + /> + <Reference + Name = "System.Data" + AssemblyName = "System.Data" + HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll" + /> + <Reference + Name = "System.XML" + AssemblyName = "System.Xml" + HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll" + /> + </References> + </Build> + <Files> + <Include> + <File + RelPath = "AssemblyInfo.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "IInvocationHandler.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "ProxyGenerator.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "StandardInvocationHandler.cs" + SubType = "Code" + BuildAction = "Compile" + /> + </Include> + </Files> + </CSHARP> +</VisualStudioProject> + Modified: avalon/trunk/central/laboratory/avalon-net/DynamicProxy/AssemblyInfo.cs ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/DynamicProxy/AssemblyInfo.cs (original) +++ avalon/trunk/central/laboratory/avalon-net/DynamicProxy/AssemblyInfo.cs Fri Jun 25 22:01:51 2004 @@ -23,7 +23,7 @@ [assembly: AssemblyCopyright("Copyright (c) 2004 The Apache Software Foundation")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.0.0.1")] #if STRONG [assembly: AssemblyDelaySign(false)] Modified: avalon/trunk/central/laboratory/avalon-net/DynamicProxy/DynamicProxy.sln ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/DynamicProxy/DynamicProxy.sln (original) +++ avalon/trunk/central/laboratory/avalon-net/DynamicProxy/DynamicProxy.sln Fri Jun 25 22:01:51 2004 @@ -1,29 +1,29 @@ -Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Avalon.DynamicProxy", "Apache.Avalon.DynamicProxy.csproj", "{70EE6AF2-1F6D-4CC5-A1B2-C3182F035F67}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Avalon.DynamicProxy.Test", "DynamicProxyTest\Apache.Avalon.DynamicProxy.Test.csproj", "{EF89321E-FB2A-41B6-85B3-794D50A55CF1}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfiguration) = preSolution - Debug = Debug - Release = Release - EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {70EE6AF2-1F6D-4CC5-A1B2-C3182F035F67}.Debug.ActiveCfg = Debug|.NET - {70EE6AF2-1F6D-4CC5-A1B2-C3182F035F67}.Debug.Build.0 = Debug|.NET - {70EE6AF2-1F6D-4CC5-A1B2-C3182F035F67}.Release.ActiveCfg = Release|.NET - {70EE6AF2-1F6D-4CC5-A1B2-C3182F035F67}.Release.Build.0 = Release|.NET - {EF89321E-FB2A-41B6-85B3-794D50A55CF1}.Debug.ActiveCfg = Debug|.NET - {EF89321E-FB2A-41B6-85B3-794D50A55CF1}.Debug.Build.0 = Debug|.NET - {EF89321E-FB2A-41B6-85B3-794D50A55CF1}.Release.ActiveCfg = Release|.NET - {EF89321E-FB2A-41B6-85B3-794D50A55CF1}.Release.Build.0 = Release|.NET - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution - EndGlobalSection -EndGlobal +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Avalon.DynamicProxy", "Apache.Avalon.DynamicProxy.csproj", "{70EE6AF2-1F6D-4CC5-A1B2-C3182F035F67}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Avalon.DynamicProxy.Test", "DynamicProxyTest\Apache.Avalon.DynamicProxy.Test.csproj", "{EF89321E-FB2A-41B6-85B3-794D50A55CF1}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {70EE6AF2-1F6D-4CC5-A1B2-C3182F035F67}.Debug.ActiveCfg = Debug|.NET + {70EE6AF2-1F6D-4CC5-A1B2-C3182F035F67}.Debug.Build.0 = Debug|.NET + {70EE6AF2-1F6D-4CC5-A1B2-C3182F035F67}.Release.ActiveCfg = Release|.NET + {70EE6AF2-1F6D-4CC5-A1B2-C3182F035F67}.Release.Build.0 = Release|.NET + {EF89321E-FB2A-41B6-85B3-794D50A55CF1}.Debug.ActiveCfg = Debug|.NET + {EF89321E-FB2A-41B6-85B3-794D50A55CF1}.Debug.Build.0 = Debug|.NET + {EF89321E-FB2A-41B6-85B3-794D50A55CF1}.Release.ActiveCfg = Release|.NET + {EF89321E-FB2A-41B6-85B3-794D50A55CF1}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal Modified: avalon/trunk/central/laboratory/avalon-net/DynamicProxy/DynamicProxyTest/Apache.Avalon.DynamicProxy.Test.csproj ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/DynamicProxy/DynamicProxyTest/Apache.Avalon.DynamicProxy.Test.csproj (original) +++ avalon/trunk/central/laboratory/avalon-net/DynamicProxy/DynamicProxyTest/Apache.Avalon.DynamicProxy.Test.csproj Fri Jun 25 22:01:51 2004 @@ -1,110 +1,140 @@ -<VisualStudioProject> - <CSHARP - ProjectType = "Local" - ProductVersion = "7.10.3077" - SchemaVersion = "2.0" - ProjectGuid = "{EF89321E-FB2A-41B6-85B3-794D50A55CF1}" - > - <Build> - <Settings - ApplicationIcon = "" - AssemblyKeyContainerName = "" - AssemblyName = "Apache.Avalon.DynamicProxy.Test" - AssemblyOriginatorKeyFile = "" - DefaultClientScript = "JScript" - DefaultHTMLPageLayout = "Grid" - DefaultTargetSchema = "IE50" - DelaySign = "false" - OutputType = "Library" - PreBuildEvent = "" - PostBuildEvent = "" - RootNamespace = "Apache.Avalon.DynamicProxy.Test" - RunPostBuildEvent = "OnBuildSuccess" - StartupObject = "" - > - <Config - Name = "Debug" - AllowUnsafeBlocks = "false" - BaseAddress = "285212672" - CheckForOverflowUnderflow = "false" - ConfigurationOverrideFile = "" - DefineConstants = "DEBUG;TRACE" - DocumentationFile = "" - DebugSymbols = "true" - FileAlignment = "4096" - IncrementalBuild = "false" - NoStdLib = "false" - NoWarn = "" - Optimize = "false" - OutputPath = "..\..\bin\" - RegisterForComInterop = "false" - RemoveIntegerChecks = "false" - TreatWarningsAsErrors = "false" - WarningLevel = "4" - /> - <Config - Name = "Release" - AllowUnsafeBlocks = "false" - BaseAddress = "285212672" - CheckForOverflowUnderflow = "false" - ConfigurationOverrideFile = "" - DefineConstants = "TRACE" - DocumentationFile = "" - DebugSymbols = "false" - FileAlignment = "4096" - IncrementalBuild = "false" - NoStdLib = "false" - NoWarn = "" - Optimize = "true" - OutputPath = "bin\Release\" - RegisterForComInterop = "false" - RemoveIntegerChecks = "false" - TreatWarningsAsErrors = "false" - WarningLevel = "4" - /> - </Settings> - <References> - <Reference - Name = "System" - AssemblyName = "System" - HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll" - /> - <Reference - Name = "System.Data" - AssemblyName = "System.Data" - HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll" - /> - <Reference - Name = "System.XML" - AssemblyName = "System.Xml" - HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll" - /> - <Reference - Name = "DProxy" - Project = "{70EE6AF2-1F6D-4CC5-A1B2-C3182F035F67}" - Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}" - /> - <Reference - Name = "nunit.framework" - AssemblyName = "nunit.framework" - HintPath = "..\..\..\..\..\..\dotnet\NUnit2\bin\nunit.framework.dll" - /> - </References> - </Build> - <Files> - <Include> - <File - RelPath = "AssemblyInfo.cs" - SubType = "Code" - BuildAction = "Compile" - /> - <File - RelPath = "ProxyGeneratorTestCase.cs" - SubType = "Code" - BuildAction = "Compile" - /> - </Include> - </Files> - </CSHARP> -</VisualStudioProject> - +<VisualStudioProject> + <CSHARP + ProjectType = "Local" + ProductVersion = "7.10.3077" + SchemaVersion = "2.0" + ProjectGuid = "{EF89321E-FB2A-41B6-85B3-794D50A55CF1}" + > + <Build> + <Settings + ApplicationIcon = "" + AssemblyKeyContainerName = "" + AssemblyName = "Apache.Avalon.DynamicProxy.Test" + AssemblyOriginatorKeyFile = "" + DefaultClientScript = "JScript" + DefaultHTMLPageLayout = "Grid" + DefaultTargetSchema = "IE50" + DelaySign = "false" + OutputType = "Library" + PreBuildEvent = "" + PostBuildEvent = "" + RootNamespace = "Apache.Avalon.DynamicProxy.Test" + RunPostBuildEvent = "OnBuildSuccess" + StartupObject = "" + > + <Config + Name = "Debug" + AllowUnsafeBlocks = "false" + BaseAddress = "285212672" + CheckForOverflowUnderflow = "false" + ConfigurationOverrideFile = "" + DefineConstants = "DEBUG;TRACE" + DocumentationFile = "" + DebugSymbols = "true" + FileAlignment = "4096" + IncrementalBuild = "false" + NoStdLib = "false" + NoWarn = "" + Optimize = "false" + OutputPath = "..\..\bin\" + RegisterForComInterop = "false" + RemoveIntegerChecks = "false" + TreatWarningsAsErrors = "false" + WarningLevel = "4" + /> + <Config + Name = "Release" + AllowUnsafeBlocks = "false" + BaseAddress = "285212672" + CheckForOverflowUnderflow = "false" + ConfigurationOverrideFile = "" + DefineConstants = "TRACE" + DocumentationFile = "" + DebugSymbols = "false" + FileAlignment = "4096" + IncrementalBuild = "false" + NoStdLib = "false" + NoWarn = "" + Optimize = "true" + OutputPath = "bin\Release\" + RegisterForComInterop = "false" + RemoveIntegerChecks = "false" + TreatWarningsAsErrors = "false" + WarningLevel = "4" + /> + </Settings> + <References> + <Reference + Name = "System" + AssemblyName = "System" + HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll" + /> + <Reference + Name = "System.Data" + AssemblyName = "System.Data" + HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll" + /> + <Reference + Name = "System.XML" + AssemblyName = "System.Xml" + HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll" + /> + <Reference + Name = "DProxy" + Project = "{70EE6AF2-1F6D-4CC5-A1B2-C3182F035F67}" + Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}" + /> + <Reference + Name = "nunit.framework" + AssemblyName = "nunit.framework" + HintPath = "..\..\..\..\..\..\..\..\..\dotnet\NUnit2\bin\nunit.framework.dll" + /> + </References> + </Build> + <Files> + <Include> + <File + RelPath = "AssemblyInfo.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "IMyInterface.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "IMySecondInterface.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "IServiceStatus.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "MyInterfaceImpl.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "MySecondInterfaceImpl.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "ProxyGeneratorTestCase.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "ServiceStatusImpl.cs" + SubType = "Code" + BuildAction = "Compile" + /> + </Include> + </Files> + </CSHARP> +</VisualStudioProject> + Modified: avalon/trunk/central/laboratory/avalon-net/DynamicProxy/DynamicProxyTest/AssemblyInfo.cs ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/DynamicProxy/DynamicProxyTest/AssemblyInfo.cs (original) +++ avalon/trunk/central/laboratory/avalon-net/DynamicProxy/DynamicProxyTest/AssemblyInfo.cs Fri Jun 25 22:01:51 2004 @@ -23,5 +23,5 @@ [assembly: AssemblyCopyright("Copyright (c) 2004 The Apache Software Foundation")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.0.0.1")] Added: avalon/trunk/central/laboratory/avalon-net/DynamicProxy/DynamicProxyTest/IMyInterface.cs ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/avalon-net/DynamicProxy/DynamicProxyTest/IMyInterface.cs Fri Jun 25 22:01:51 2004 @@ -0,0 +1,42 @@ +// Copyright 2004 The Apache Software Foundation +// +// 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 Apache.Avalon.DynamicProxy.Test +{ + using System; + + /// <summary> + /// Summary description for IMyInterface. + /// </summary> + public interface IMyInterface + { + String Name + { + get; + set; + } + + bool Started + { + get; + set; + } + + // void Calc(int x, int y, out int result); + + int Calc(int x, int y); + + int Calc(int x, int y, int z, Single k); + } +} Added: avalon/trunk/central/laboratory/avalon-net/DynamicProxy/DynamicProxyTest/IMySecondInterface.cs ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/avalon-net/DynamicProxy/DynamicProxyTest/IMySecondInterface.cs Fri Jun 25 22:01:51 2004 @@ -0,0 +1,30 @@ +// Copyright 2004 The Apache Software Foundation +// +// 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 Apache.Avalon.DynamicProxy.Test +{ + using System; + + /// <summary> + /// Summary description for IMySecondInterface. + /// </summary> + public interface IMySecondInterface : IMyInterface + { + String Address + { + get; + set; + } + } +} Added: avalon/trunk/central/laboratory/avalon-net/DynamicProxy/DynamicProxyTest/IServiceStatus.cs ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/avalon-net/DynamicProxy/DynamicProxyTest/IServiceStatus.cs Fri Jun 25 22:01:51 2004 @@ -0,0 +1,45 @@ +// Copyright 2004 The Apache Software Foundation +// +// 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 Apache.Avalon.DynamicProxy.Test +{ + using System; + + /// <summary> + /// Simple enum declaration + /// </summary> + public enum State + { + Valid, + Invalid + } + + /// <summary> + /// Summary description for IServiceStatus. + /// </summary> + public interface IServiceStatus + { + int Requests + { + get; + } + + State ActualState + { + get; + } + + void ChangeState(State state); + } +} Added: avalon/trunk/central/laboratory/avalon-net/DynamicProxy/DynamicProxyTest/MyInterfaceImpl.cs ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/avalon-net/DynamicProxy/DynamicProxyTest/MyInterfaceImpl.cs Fri Jun 25 22:01:51 2004 @@ -0,0 +1,69 @@ +// Copyright 2004 The Apache Software Foundation +// +// 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 Apache.Avalon.DynamicProxy.Test +{ + using System; + + /// <summary> + /// Summary description for MyInterfaceImpl. + /// </summary> + public class MyInterfaceImpl : IMyInterface + { + private String m_name; + private bool m_started; + + public MyInterfaceImpl() + { + } + + #region IMyInterface Members + + public String Name + { + get + { + return m_name; + } + set + { + m_name = value; + } + } + + public bool Started + { + get + { + return m_started; + } + set + { + m_started = value; + } + } + + public int Calc(int x, int y) + { + return x + y; + } + + public int Calc(int x, int y, int z, Single k) + { + return x + y + z + (int)k; + } + + #endregion + } +} Added: avalon/trunk/central/laboratory/avalon-net/DynamicProxy/DynamicProxyTest/MySecondInterfaceImpl.cs ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/avalon-net/DynamicProxy/DynamicProxyTest/MySecondInterfaceImpl.cs Fri Jun 25 22:01:51 2004 @@ -0,0 +1,46 @@ +// Copyright 2004 The Apache Software Foundation +// +// 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 Apache.Avalon.DynamicProxy.Test +{ + using System; + + /// <summary> + /// Summary description for MySecondInterfaceImpl. + /// </summary> + public class MySecondInterfaceImpl : MyInterfaceImpl, IMySecondInterface + { + private String m_address; + + public MySecondInterfaceImpl() + { + } + + #region IMySecondInterface Members + + public String Address + { + get + { + return m_address; + } + set + { + m_address = value; + } + } + + #endregion + } +} Modified: avalon/trunk/central/laboratory/avalon-net/DynamicProxy/DynamicProxyTest/ProxyGeneratorTestCase.cs ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/DynamicProxy/DynamicProxyTest/ProxyGeneratorTestCase.cs (original) +++ avalon/trunk/central/laboratory/avalon-net/DynamicProxy/DynamicProxyTest/ProxyGeneratorTestCase.cs Fri Jun 25 22:01:51 2004 @@ -25,263 +25,79 @@ /// Summary description for ProxyGeneratorTestCase. /// </summary> [TestFixture] - public class ProxyGeneratorTestCase : Assertion, IInvocationHandler, IMyInterface, IMySecondInterface, IServiceStatus + public class ProxyGeneratorTestCase : Assertion { - protected String m_nameProperty; - protected String m_addressProperty; - protected State m_state = State.Invalid; - protected bool m_started; - [Test] - public void TestSimpleCase() + public void TestGenerationSimpleInterface() { - object proxy = ProxyGenerator.CreateProxy( new Type[] { typeof(IMyInterface) }, this ); + object proxy = ProxyGenerator.CreateProxy( + typeof(IMyInterface), new StandardInvocationHandler( new MyInterfaceImpl() ) ); + AssertNotNull( proxy ); Assert( typeof(IMyInterface).IsAssignableFrom( proxy.GetType() ) ); IMyInterface inter = (IMyInterface) proxy; - inter.Calc(1, "ola"); + + AssertEquals( 45, inter.Calc( 20, 25 ) ); + inter.Name = "opa"; AssertEquals( "opa", inter.Name ); + inter.Started = true; AssertEquals( true, inter.Started ); - AssertEquals( 45, inter.Calc( 20, 25 ) ); } [Test] - public void TestMoreComplexCase() + public void TestGenerationWithInterfaceHeritage() { - object proxy = ProxyGenerator.CreateProxy( new Type[] { typeof(IMySecondInterface) }, this ); + object proxy = ProxyGenerator.CreateProxy( + typeof(IMySecondInterface), new StandardInvocationHandler( new MySecondInterfaceImpl() ) ); + AssertNotNull( proxy ); Assert( typeof(IMyInterface).IsAssignableFrom( proxy.GetType() ) ); Assert( typeof(IMySecondInterface).IsAssignableFrom( proxy.GetType() ) ); IMySecondInterface inter = (IMySecondInterface) proxy; - inter.Calc(1, "ola"); - inter.Name = "opa"; - AssertEquals( "opa", inter.Name ); + inter.Calc(1, 1); + + inter.Name = "hammett"; + AssertEquals( "hammett", inter.Name ); + inter.Address = "pereira leite, 44"; AssertEquals( "pereira leite, 44", inter.Address ); + AssertEquals( 45, inter.Calc( 20, 25 ) ); } [Test] - public void TestEnumCase() + public void TestEnumProperties() { - m_state = State.Invalid; + ServiceStatusImpl service = new ServiceStatusImpl(); - object proxy = ProxyGenerator.CreateProxy( new Type[] { typeof(IServiceStatus) }, this ); + object proxy = ProxyGenerator.CreateProxy( + typeof(IServiceStatus), new StandardInvocationHandler( service ) ); + AssertNotNull( proxy ); Assert( typeof(IServiceStatus).IsAssignableFrom( proxy.GetType() ) ); IServiceStatus inter = (IServiceStatus) proxy; AssertEquals( State.Invalid, inter.ActualState ); + inter.ChangeState( State.Valid ); AssertEquals( State.Valid, inter.ActualState ); } - #region IInvocationHandler Members - - public object Invoke(object obj, MethodBase method, params object[] arguments) - { - Type[] parameters = new Type[arguments.Length]; - - for(int i=0; i < arguments.Length; i++ ) - { - parameters[i] = arguments[i].GetType(); - } - - MethodInfo ourMethod = this.GetType().GetMethod( method.Name, parameters ); - - AssertNotNull( ourMethod ); - - return ourMethod.Invoke( this, arguments ); - } - - #endregion - - #region IMyInterface Members - - public String Name - { - get - { - return m_nameProperty; - } - set - { - m_nameProperty = value; - } - } - - public bool Started - { - get - { - return m_started; - } - set - { - m_started = value; - } - } - - public void Calc(int x, String y) - { - } - - public void Calc(int x, String y, Single ip) - { - } - - public int Calc(int x, int y) - { - return x + y; - } - - public int Calc(int x, int y, int z, Single h) - { - return x + y + z + (int)h; - } - - #endregion - - #region IMySecondInterface Members - - public String Address - { - get - { - return m_addressProperty; - } - set - { - m_addressProperty = value; - } - } - - #endregion - - #region IServiceStatus Members - - public int Requests - { - get - { - return 32; - } - } - - public Apache.Avalon.DynamicProxy.Test.State ActualState - { - get - { - return m_state ; - } - } - - public void ChangeState(Apache.Avalon.DynamicProxy.Test.State state) - { - m_state = state; - } - - #endregion - } - - /// <summary> - /// - /// </summary> - public enum State - { - Valid, - Invalid - } - - /// <summary> - /// - /// </summary> - public interface IMyInterface - { - String Name - { - get; - set; - } - - bool Started + public class MyInterfaceProxy : IInvocationHandler { - get; - set; + #region IInvocationHandler Members + + public object Invoke(object proxy, MethodInfo method, params object[] arguments) + { + return null; + } + + #endregion } - - void Calc(int x, String y); - - void Calc(int x, String y, Single ip); - - int Calc(int x, int y); - - int Calc(int x, int y, int z, Single h); - } - - /// <summary> - /// - /// </summary> - public interface IMySecondInterface : IMyInterface - { - String Address - { - get; - set; - } - } - - public interface IServiceStatus - { - int Requests - { - get; - } - - State ActualState - { - get; - } - - void ChangeState(State state); - } - - public class MyTest : IServiceStatus - { - IInvocationHandler handler = null; - - #region IServiceStatus Members - - public int Requests - { - get - { - MethodBase method = MethodBase.GetCurrentMethod(); - return (int) handler.Invoke( this, method ); - } - } - - public Apache.Avalon.DynamicProxy.Test.State ActualState - { - get - { - MethodBase method = MethodBase.GetCurrentMethod(); - return (State) handler.Invoke( this, method ); - } - } - - public void ChangeState(Apache.Avalon.DynamicProxy.Test.State state) - { - MethodBase method = MethodBase.GetCurrentMethod(); - handler.Invoke( this, method, state ); - } - - #endregion - } } Added: avalon/trunk/central/laboratory/avalon-net/DynamicProxy/DynamicProxyTest/ServiceStatusImpl.cs ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/avalon-net/DynamicProxy/DynamicProxyTest/ServiceStatusImpl.cs Fri Jun 25 22:01:51 2004 @@ -0,0 +1,55 @@ +// Copyright 2004 The Apache Software Foundation +// +// 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 Apache.Avalon.DynamicProxy.Test +{ + using System; + + /// <summary> + /// Summary description for ServiceStatusImpl. + /// </summary> + public class ServiceStatusImpl : IServiceStatus + { + private Apache.Avalon.DynamicProxy.Test.State m_state = Apache.Avalon.DynamicProxy.Test.State.Invalid; + + public ServiceStatusImpl() + { + } + + #region IServiceStatus Members + + public int Requests + { + get + { + return 10; + } + } + + public Apache.Avalon.DynamicProxy.Test.State ActualState + { + get + { + return m_state; + } + } + + public void ChangeState(Apache.Avalon.DynamicProxy.Test.State state) + { + m_state = state; + } + + #endregion + } +} Modified: avalon/trunk/central/laboratory/avalon-net/DynamicProxy/IInvocationHandler.cs ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/DynamicProxy/IInvocationHandler.cs (original) +++ avalon/trunk/central/laboratory/avalon-net/DynamicProxy/IInvocationHandler.cs Fri Jun 25 22:01:51 2004 @@ -27,9 +27,9 @@ /// Implementation should invoke the method on the real object. /// </summary> /// <param name="proxy">proxy instance</param> - /// <param name="method"><see cref="System.Reflection.MethodBase"/> being invoked.</param> + /// <param name="method"><see cref="System.Reflection.MethodInfo"/> being invoked.</param> /// <param name="arguments">Arguments of method - if any</param> /// <returns>Should return the result of method invocation</returns> - object Invoke(object proxy, MethodBase method, params object[] arguments); + object Invoke(object proxy, MethodInfo method, params object[] arguments); } } Modified: avalon/trunk/central/laboratory/avalon-net/DynamicProxy/ProxyGenerator.cs ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/DynamicProxy/ProxyGenerator.cs (original) +++ avalon/trunk/central/laboratory/avalon-net/DynamicProxy/ProxyGenerator.cs Fri Jun 25 22:01:51 2004 @@ -28,6 +28,10 @@ /// implementing the specified interfaces. The class implementation will /// only call the internal <see cref="IInvocationHandler"/> instance. /// </remarks> + /// <remarks> + /// This proxy implementation currently doesn't not supports ref and out arguments + /// in methods. + /// </remarks> /// <example> /// <code> /// MyInvocationHandler handler = ... @@ -48,6 +52,18 @@ /// Generates a proxy implementing all the specified interfaces and /// redirecting method invocations to the specifed handler. /// </summary> + /// <param name="theInterface">Interface to be implemented</param> + /// <param name="handler">instance of <see cref="IInvocationHandler"/></param> + /// <returns>Proxy instance</returns> + public static object CreateProxy(Type theInterface, IInvocationHandler handler) + { + return CreateProxy(new Type[] { theInterface }, handler ); + } + + /// <summary> + /// Generates a proxy implementing all the specified interfaces and + /// redirecting method invocations to the specifed handler. + /// </summary> /// <param name="interfaces">Array of interfaces to be implemented</param> /// <param name="handler">instance of <see cref="IInvocationHandler"/></param> /// <returns>Proxy instance</returns> @@ -246,7 +262,7 @@ } } - WriteILForMethod( methodBuilder, parameters, handlerField ); + WriteILForMethod( method, methodBuilder, parameters, handlerField ); } /// <summary> @@ -267,7 +283,7 @@ /// <param name="typeBuilder"><see cref="TypeBuilder"/> being constructed.</param> /// <param name="parameters"></param> /// <param name="handlerField"></param> - private static void WriteILForMethod( MethodBuilder builder, + private static void WriteILForMethod( MethodInfo method, MethodBuilder builder, System.Type[] parameters, FieldBuilder handlerField ) { int arrayPositionInStack = 1; @@ -284,11 +300,12 @@ ilGenerator.DeclareLocal( typeof(object[]) ); - ilGenerator.Emit(OpCodes.Call, typeof(MethodBase).GetMethod("GetCurrentMethod") ); + ilGenerator.Emit(OpCodes.Ldtoken, method); + ilGenerator.Emit(OpCodes.Call, typeof(MethodBase).GetMethod("GetMethodFromHandle")); ilGenerator.Emit(OpCodes.Stloc_0); ilGenerator.Emit(OpCodes.Ldarg_0); - ilGenerator.Emit(OpCodes.Ldfld, handlerField ); + ilGenerator.Emit(OpCodes.Ldfld, handlerField); ilGenerator.Emit(OpCodes.Ldarg_0); ilGenerator.Emit(OpCodes.Ldloc_0); ilGenerator.Emit(OpCodes.Ldc_I4, parameters.Length); @@ -339,7 +356,6 @@ { ilGenerator.Emit(OpCodes.Pop); } - ilGenerator.Emit(OpCodes.Ret); } Added: avalon/trunk/central/laboratory/avalon-net/DynamicProxy/StandardInvocationHandler.cs ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/avalon-net/DynamicProxy/StandardInvocationHandler.cs Fri Jun 25 22:01:51 2004 @@ -0,0 +1,67 @@ +// Copyright 2004 The Apache Software Foundation +// +// 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 Apache.Avalon.DynamicProxy +{ + using System; + + /// <summary> + /// Summary description for StandardInvocationHandler. + /// </summary> + public class StandardInvocationHandler : IInvocationHandler + { + private object m_target; + + public StandardInvocationHandler(object target) + { + if (target == null) + { + throw new ArgumentNullException("target"); + } + + m_target = target; + } + + protected virtual void PreInvoke(object proxy, System.Reflection.MethodInfo method, params object[] arguments) + { + } + + protected virtual void PostInvoke(object proxy, System.Reflection.MethodInfo method, ref object returnValue, params object[] arguments) + { + } + + #region IInvocationHandler Members + + public virtual object Invoke(object proxy, System.Reflection.MethodInfo method, params object[] arguments) + { + PreInvoke(proxy, method, arguments); + + object returnValue = method.Invoke( Target, arguments ); + + PostInvoke(proxy, method, ref returnValue, arguments); + + return returnValue; + } + + #endregion + + public object Target + { + get + { + return m_target; + } + } + } +} --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]