├── .gitattributes ├── .gitignore ├── BuildScripts ├── .config │ └── dotnet-tools.json └── build.cake ├── LICENSE ├── MassiveDynamicProxyGenerator.ruleset ├── README.md ├── doc ├── MassiveDynamicProxyGenerator.Microsoft.DependencyInjection.md ├── MassiveDynamicProxyGenerator.SimpleInjector.md └── MassiveDynamicProxyGenerator.md └── src ├── .gitignore ├── MassiveDynamicProxyGenerator.sln ├── Samples ├── PerformaceExamples │ ├── DecoratorBenchmark.cs │ ├── DecoratorDispatchProxy.cs │ ├── DynamicProxyBenchmark.cs │ ├── ExamapleInterface.cs │ ├── IExamapleInterface.cs │ ├── IRemoteCall.cs │ ├── LoggerCallableInterceptor.cs │ ├── PerformaceExamples.csproj │ ├── Program.cs │ ├── RemoteCall.cs │ ├── RemoteCallDispatchProxy.cs │ └── RemoteCallInterceptor.cs ├── ProxyGeneratrorSamples.Net40 │ ├── .vs │ │ └── ProxyGeneratrorSamples.Net40.csproj.dtbcache.json │ ├── Calculator.cs │ ├── ErrorInterceptor.cs │ ├── ICalculator.cs │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── ProxyGeneratrorSamples.Net40.csproj │ └── app.config ├── SampleWebApplication │ ├── Controllers │ │ ├── ArticleController.cs │ │ └── HomeController.cs │ ├── Models │ │ ├── Article │ │ │ ├── ContentViewModel.cs │ │ │ ├── IndexViewModel.cs │ │ │ └── MenuItemViewModel.cs │ │ └── ErrorViewModel.cs │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── SampleWebApplication.csproj │ ├── Services │ │ ├── Contract │ │ │ ├── Article.cs │ │ │ ├── ArticleInfo.cs │ │ │ ├── IArticleService.cs │ │ │ ├── ICommonServices.cs │ │ │ └── INotificationService.cs │ │ ├── Implementation │ │ │ ├── ArticleDecoratorService.cs │ │ │ └── MockArticleService.cs │ │ └── Interceptors │ │ │ ├── ChangeAutorInterceptor.cs │ │ │ ├── PerformaceInterceptor.cs │ │ │ └── ServiceProviderInterceptor.cs │ ├── Startup.cs │ ├── Views │ │ ├── Article │ │ │ ├── Content.cshtml │ │ │ └── Index.cshtml │ │ ├── Home │ │ │ ├── About.cshtml │ │ │ ├── Contact.cshtml │ │ │ └── Index.cshtml │ │ ├── Shared │ │ │ ├── Error.cshtml │ │ │ ├── _Layout.cshtml │ │ │ └── _ValidationScriptsPartial.cshtml │ │ ├── _ViewImports.cshtml │ │ └── _ViewStart.cshtml │ ├── appsettings.Development.json │ ├── appsettings.json │ ├── bundleconfig.json │ └── wwwroot │ │ ├── css │ │ ├── site.css │ │ └── site.min.css │ │ ├── favicon.ico │ │ ├── images │ │ ├── banner1.svg │ │ ├── banner2.svg │ │ ├── banner3.svg │ │ └── banner4.svg │ │ ├── js │ │ ├── site.js │ │ └── site.min.js │ │ └── lib │ │ ├── bootstrap │ │ ├── .bower.json │ │ ├── LICENSE │ │ └── dist │ │ │ ├── css │ │ │ ├── bootstrap-theme.css │ │ │ ├── bootstrap-theme.css.map │ │ │ ├── bootstrap-theme.min.css │ │ │ ├── bootstrap-theme.min.css.map │ │ │ ├── bootstrap.css │ │ │ ├── bootstrap.css.map │ │ │ ├── bootstrap.min.css │ │ │ └── bootstrap.min.css.map │ │ │ ├── fonts │ │ │ ├── glyphicons-halflings-regular.eot │ │ │ ├── glyphicons-halflings-regular.svg │ │ │ ├── glyphicons-halflings-regular.ttf │ │ │ ├── glyphicons-halflings-regular.woff │ │ │ └── glyphicons-halflings-regular.woff2 │ │ │ └── js │ │ │ ├── bootstrap.js │ │ │ ├── bootstrap.min.js │ │ │ └── npm.js │ │ ├── jquery-validation-unobtrusive │ │ ├── .bower.json │ │ ├── jquery.validate.unobtrusive.js │ │ └── jquery.validate.unobtrusive.min.js │ │ ├── jquery-validation │ │ ├── .bower.json │ │ ├── LICENSE.md │ │ └── dist │ │ │ ├── additional-methods.js │ │ │ ├── additional-methods.min.js │ │ │ ├── jquery.validate.js │ │ │ └── jquery.validate.min.js │ │ └── jquery │ │ ├── .bower.json │ │ ├── LICENSE.txt │ │ └── dist │ │ ├── core.js │ │ ├── jquery.js │ │ ├── jquery.min.js │ │ ├── jquery.min.map │ │ ├── jquery.slim.js │ │ ├── jquery.slim.min.js │ │ └── jquery.slim.min.map ├── WcfForHipsters.Client │ ├── ExampleServiceClient.cs │ ├── Program.cs │ ├── WcfForHipsters.Client.csproj │ └── WcfForHipsters │ │ ├── HipsterClientBase.cs │ │ ├── JsonRpcInterceptor.cs │ │ ├── RpcFaultException.cs │ │ └── ServiceResponse.cs └── WcfForHipsters.WebServer │ ├── Contract │ ├── CreatBookResponse.cs │ ├── CreateBookRequest.cs │ ├── IExampleService.cs │ ├── RequestMetadata.cs │ └── ReuquestFormat.cs │ ├── Controllers │ ├── ExampleServiceController.cs │ └── ValuesController.cs │ ├── Program.cs │ ├── Properties │ └── launchSettings.json │ ├── Services │ └── ExampleService.cs │ ├── Startup.cs │ ├── WcfForHipsters.WebServer.csproj │ ├── WcfForHipsters │ ├── EndpointAdapter.cs │ ├── FaultBody.cs │ ├── FaultException.cs │ ├── RequestBody.cs │ ├── ResponseBody.cs │ └── UnwrapHelper.cs │ ├── appsettings.json │ ├── web.config │ └── wwwroot │ └── humans.txt ├── Src ├── MassiveDynamicProxyGenerator.Microsoft.DependencyInjection │ ├── DefaultProxyGeneratorProvider.cs │ ├── FuncInstanceProvider.cs │ ├── FuncProxyGeneratorProvider.cs │ ├── IOriginalService.cs │ ├── IProxyGeneratorProvider.cs │ ├── MassiveDynamicProxyGenerator.Microsoft.DependencyInjection.csproj │ ├── MassiveDynamicProxyGeneratorDiSettings.cs │ ├── OriginalService.cs │ ├── ServiceCollectionExtensions.Decorate.cs │ ├── ServiceCollectionExtensions.InstanceProxy.cs │ ├── ServiceCollectionExtensions.Interception.cs │ ├── ServiceCollectionExtensions.OriginalService.cs │ ├── ServiceCollectionExtensions.Proxy.cs │ ├── ServiceCollectionExtensions.ServiceProvider.cs │ ├── ServiceCollectionExtensions.cs │ ├── ServiceProvider │ │ ├── IServiceWrapperer.cs │ │ ├── MassiveScopedServiceFactory.cs │ │ ├── MassiveServiceProvider.cs │ │ ├── MassiveServiceScope.cs │ │ ├── OriginalServiceContainer.cs │ │ └── Registrations.cs │ └── TypeHelper.cs ├── MassiveDynamicProxyGenerator.SimpleInjector │ ├── ContainerExtensions.Interception.cs │ ├── ContainerExtensions.IstanceProxy.cs │ ├── ContainerExtensions.Mock.cs │ ├── ContainerExtensions.Proxy.cs │ ├── ContainerExtensions.cs │ ├── Dangerous │ │ ├── DangerousContainerExtensions.InstanceProvider.cs │ │ ├── DangerousContainerExtensions.Mock.cs │ │ └── DangerousContainerExtensions.cs │ ├── DefaultProxyGeneratorFactory.cs │ ├── FullFrameworkExtensions.cs │ ├── FuncInstanceProvider.cs │ ├── GlobalSuppressions.cs │ ├── IProxyGeneratorFactory.cs │ ├── InstanceProxy │ │ └── OpenInstanceProxyBuildProxy.cs │ ├── Interception │ │ ├── FuncInterceptedProxyBuilder.cs │ │ ├── FuncInterceptionBuilder.cs │ │ ├── InstanceInterceptedProxyBuilder.cs │ │ ├── InstanceInterceptionBuilder.cs │ │ ├── InterceptedProxyBuilder.cs │ │ ├── InterceptionBuilder.cs │ │ ├── OpenFuncInterceptedProxyBuilder.cs │ │ ├── OpenInstanceInterceptedProxyBuilder.cs │ │ ├── OpenTypeInterceptedProxyBuilder.cs │ │ ├── TypeInterceptedProxyBuilder.cs │ │ └── TypeInterceptionBuilder.cs │ ├── MassiveDynamicProxyGenerator.SimpleInjector.csproj │ ├── NetStandard14Extensions.cs │ ├── ProxyGeneratorFactory.cs │ ├── Registrations │ │ ├── InstanceProxyWithTypeRegistration.cs │ │ ├── ProxyWithFactoryInterceptorRegistration.cs │ │ ├── ProxyWithInstanceInterceptorRegistration.cs │ │ └── ProxyWithTypeInterceptorRegistration.cs │ └── TypeHelper.cs └── MassiveDynamicProxyGenerator │ ├── AbstractTypeBuilder.cs │ ├── CallableInterceptorAdapter.cs │ ├── CallableInterceptorAsyncAdapter.cs │ ├── CallableInterceptorAsyncInvocation.cs │ ├── DefaultInstances.cs │ ├── DynamicProxy │ ├── DynamicInvocation.cs │ └── DynamicProxyObject.cs │ ├── Extensions │ ├── AssemblyBuilderExtensios.cs │ └── TypeBuilderExtensions.cs │ ├── FullFrameworkExtensions.cs │ ├── GlobalSuppressions.cs │ ├── GuidTypeNameCreator.cs │ ├── ICallableInterceptor.cs │ ├── ICallableInvocation.cs │ ├── ICommonInvocation.cs │ ├── IInstanceProvicer.cs │ ├── IInterceptor.cs │ ├── IInvocation.cs │ ├── IProxyGenerator.cs │ ├── ITypeNameCreator.cs │ ├── InterceptorAdapter.cs │ ├── KoreanTypeNameCreator.cs │ ├── MassiveDynamicProxyGenerator.csproj │ ├── MockInterceptor.cs │ ├── NetStandard14Extensions.cs │ ├── NullAsyncInterceptor.cs │ ├── NullInterceptor.cs │ ├── ProxyGenerator.cs │ ├── ProxyGeneratorSettings.cs │ ├── TypedDecorator │ ├── CallableInterceptorDescriptor.cs │ ├── CallableInvocation.cs │ ├── CallableInvocationDescriptor.cs │ ├── GenerateUnion.cs │ └── TypedDecoratorGenerator.cs │ ├── TypedInstanceProxy │ ├── InstanceProvicerDescriptor.cs │ ├── LazyInstanceProvider.cs │ ├── SimpleInstanceProvider.cs │ └── TypedInstanceProxyGenerator.cs │ ├── TypedProxy │ ├── InvocationDescriptor.cs │ ├── TypedProxyContext.cs │ ├── TypedProxyGenerator.cs │ └── TypedProxyInvocation.cs │ └── Utils │ ├── EmitExtensions.cs │ ├── GeneratedTypeList.cs │ ├── ITypeRquest.cs │ ├── KoreanAlphabet.cs │ ├── MultyTypeRquest.cs │ ├── RusianAplhabet.cs │ ├── SettingsUtils.cs │ ├── TypeRquest.cs │ └── TypedDecoratorType.cs ├── Test ├── MassiveDynamicProxyGenerator.DependencyInjection.Test │ ├── AddProxyTests.cs │ ├── BasicDecoratorTests.cs │ ├── InstanceProxyTests.cs │ ├── InterceptionTests.cs │ ├── MassiveDynamicProxyGenerator.DependencyInjection.Test.csproj │ └── Services │ │ ├── GenericService.cs │ │ ├── IGenericService.cs │ │ ├── IMessageService.cs │ │ ├── ITestMessager.cs │ │ ├── ITypeA.cs │ │ ├── ITypeB.cs │ │ ├── ITypeC.cs │ │ ├── IntGenericService.cs │ │ ├── MessageService.cs │ │ ├── StringGenericService.cs │ │ ├── TestMessager.cs │ │ ├── TypeA.cs │ │ ├── TypeADependInterceptor.cs │ │ ├── TypeB.cs │ │ └── TypeC.cs ├── MassiveDynamicProxyGenerator.SimpleInjector.Tests.NetCore │ └── MassiveDynamicProxyGenerator.SimpleInjector.Tests.NetCore.csproj ├── MassiveDynamicProxyGenerator.SimpleInjector.Tests │ ├── .vs │ │ └── MassiveDynamicProxyGenerator.SimpleInjector.Tests.csproj.dtbcache.json │ ├── DangerousInstanceProviderTests.cs │ ├── DangerousMockTests.cs │ ├── InstanceProxyTests.cs │ ├── InterceptedpDecoratorTests.cs │ ├── MassiveDynamicProxyGenerator.SimpleInjector.Tests.csproj │ ├── MockTests.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── ProxyGeneratorFactoryTests.cs │ ├── ProxyTests.cs │ ├── Services │ │ ├── GenericInstanceProducer.cs │ │ ├── GenericService.cs │ │ ├── IGenericService.cs │ │ ├── IMessageService.cs │ │ ├── ITestMessager.cs │ │ ├── ITypeA.cs │ │ ├── ITypeB.cs │ │ ├── ITypeC.cs │ │ ├── IntGenericService.cs │ │ ├── MessageDependentIInstanceProvicer.cs │ │ ├── MessageService.cs │ │ ├── MessageServiceInstanceProvider.cs │ │ ├── StringGenericService.cs │ │ ├── TestMessager.cs │ │ ├── TypeA.cs │ │ ├── TypeB.cs │ │ └── TypeC.cs │ └── packages.config ├── MassiveDynamicProxyGenerator.Tests.NetStandard │ └── MassiveDynamicProxyGenerator.Tests.NetStandard.csproj └── MassiveDynamicProxyGenerator.Tests │ ├── .vs │ └── MassiveDynamicProxyGenerator.Tests.csproj.dtbcache.json │ ├── CacheTests.cs │ ├── CallableInterceptorAsyncAdapterTests.cs │ ├── DecoratorTests.cs │ ├── DynamicObjectProxyTests.cs │ ├── Examples │ ├── Caller.cs │ ├── InvocationExample.cs │ ├── NonReturnExample.cs │ └── ReturnTypes.cs │ ├── MassiveDynamicProxyGenerator.Tests.csproj │ ├── MockInterceptorTests.cs │ ├── NullAsyncInterceptorTests.cs │ ├── NullInterceptorTests.cs │ ├── Properties │ └── AssemblyInfo.cs │ ├── TestExtensions │ ├── ExceptionAssertion.cs │ └── TypeAssertExtensions.cs │ ├── TestInterfaces │ ├── CallableInterceptorAsyncImpl.cs │ ├── IAsyncInterface.cs │ ├── ICompositeInterface.cs │ ├── IGenericInterface.cs │ ├── IGrapth.cs │ ├── IInterfaceWithDefaultMethod.cs │ ├── IMethodWraper.cs │ ├── INonReturn.cs │ ├── IPrototype.cs │ └── IReturnTypes.cs │ ├── TestMultiProxy.cs │ ├── TypedDecoratorTests.cs │ ├── TypedInstanceProxyTests.cs │ ├── TypedProxyTests.cs │ ├── app.config │ └── packages.config ├── Version.proj └── img └── NugetIcon.png /BuildScripts/.config/dotnet-tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "isRoot": true, 4 | "tools": { 5 | "cake.tool": { 6 | "version": "1.1.0", 7 | "commands": [ 8 | "dotnet-cake" 9 | ] 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Jozef Gajdoš 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/Samples/PerformaceExamples/DecoratorBenchmark.cs: -------------------------------------------------------------------------------- 1 | using BenchmarkDotNet.Attributes; 2 | using MassiveDynamicProxyGenerator; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace PerformaceExamples 10 | { 11 | public class DecoratorBenchmark 12 | { 13 | private IExamapleInterface massiveDynamicDecorator; 14 | private IExamapleInterface dispatchProxyDynamicDecorator; 15 | 16 | [GlobalSetup] 17 | public void Setup() 18 | { 19 | IRemoteCall remoteCall = new RemoteCall(); 20 | ProxyGenerator proxyGenerator = new ProxyGenerator(); 21 | 22 | this.massiveDynamicDecorator = proxyGenerator.GenerateDecorator(new LoggerCallableInterceptor(remoteCall), new ExamapleInterface()); 23 | this.dispatchProxyDynamicDecorator = DecoratorDispatchProxy.Create(new ExamapleInterface(), remoteCall); 24 | } 25 | 26 | [Benchmark] 27 | public string MassiveDynamic() 28 | { 29 | return this.massiveDynamicDecorator.Foo(12, "hello", "world"); 30 | } 31 | 32 | [Benchmark] 33 | public string DispatchProxy() 34 | { 35 | return this.dispatchProxyDynamicDecorator.Foo(12, "hello", "world"); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Samples/PerformaceExamples/DecoratorDispatchProxy.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace PerformaceExamples 9 | { 10 | public class DecoratorDispatchProxy : DispatchProxy where T : class 11 | { 12 | private T parent; 13 | private IRemoteCall remoteCall; 14 | 15 | public DecoratorDispatchProxy() 16 | { 17 | 18 | } 19 | 20 | protected override object Invoke(MethodInfo targetMethod, object[] args) 21 | { 22 | this.remoteCall.Call(targetMethod.Name, targetMethod.ReturnType, args); 23 | return targetMethod.Invoke(this.parent, args); 24 | } 25 | 26 | public static T Create(T parent, IRemoteCall remoteCall) 27 | { 28 | T decorator = DecoratorDispatchProxy.Create>(); 29 | (decorator as DecoratorDispatchProxy).parent = parent; 30 | (decorator as DecoratorDispatchProxy).remoteCall = remoteCall; 31 | 32 | return decorator; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Samples/PerformaceExamples/DynamicProxyBenchmark.cs: -------------------------------------------------------------------------------- 1 | using BenchmarkDotNet.Attributes; 2 | using MassiveDynamicProxyGenerator; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace PerformaceExamples 10 | { 11 | public class DynamicProxyBenchmark 12 | { 13 | private IExamapleInterface massiveDynamicProxy; 14 | private IExamapleInterface disptachProxy; 15 | 16 | [GlobalSetup] 17 | public void Setup() 18 | { 19 | IRemoteCall remoteCall = new RemoteCall(); 20 | ProxyGenerator proxyGenerator = new ProxyGenerator(); 21 | 22 | this.massiveDynamicProxy = proxyGenerator.GenerateProxy(new RemoteCallInterceptor(remoteCall)); 23 | this.disptachProxy = RemoteCallDispatchProxy.Create(remoteCall); 24 | } 25 | 26 | [Benchmark] 27 | public string MassiveDynamic() 28 | { 29 | return this.massiveDynamicProxy.Foo(12, "hello", "world"); 30 | } 31 | 32 | [Benchmark] 33 | public string DispatchProxy() 34 | { 35 | return this.disptachProxy.Foo(12, "hello", "world"); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Samples/PerformaceExamples/ExamapleInterface.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace PerformaceExamples 8 | { 9 | public class ExamapleInterface : IExamapleInterface 10 | { 11 | public ExamapleInterface() 12 | { 13 | 14 | } 15 | 16 | public string Foo(int id, string name, string content) 17 | { 18 | return name; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Samples/PerformaceExamples/IExamapleInterface.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace PerformaceExamples 8 | { 9 | public interface IExamapleInterface 10 | { 11 | string Foo(int id, string name, string content); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/Samples/PerformaceExamples/IRemoteCall.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace PerformaceExamples 8 | { 9 | public interface IRemoteCall 10 | { 11 | object Call(string methodName, Type returnType, object[] parameters); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/Samples/PerformaceExamples/LoggerCallableInterceptor.cs: -------------------------------------------------------------------------------- 1 | using MassiveDynamicProxyGenerator; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace PerformaceExamples 9 | { 10 | public class LoggerCallableInterceptor : ICallableInterceptor 11 | { 12 | private readonly IRemoteCall remoteCall; 13 | 14 | public LoggerCallableInterceptor(IRemoteCall remoteCall) 15 | { 16 | this.remoteCall = remoteCall; 17 | } 18 | 19 | public void Intercept(ICallableInvocation invocation) 20 | { 21 | this.remoteCall.Call(invocation.MethodName, invocation.ReturnType, invocation.Arguments); 22 | invocation.Process(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Samples/PerformaceExamples/PerformaceExamples.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/Samples/PerformaceExamples/Program.cs: -------------------------------------------------------------------------------- 1 | using BenchmarkDotNet.Running; 2 | using System; 3 | 4 | namespace PerformaceExamples 5 | { 6 | public class Program 7 | { 8 | public static void Main(string[] args) 9 | { 10 | _ = BenchmarkRunner.Run(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/Samples/PerformaceExamples/RemoteCall.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace PerformaceExamples 8 | { 9 | public class RemoteCall : IRemoteCall 10 | { 11 | public RemoteCall() 12 | { 13 | 14 | } 15 | 16 | public object Call(string methodName, Type returnType, object[] parameters) 17 | { 18 | return methodName; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Samples/PerformaceExamples/RemoteCallDispatchProxy.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace PerformaceExamples 9 | { 10 | public class RemoteCallDispatchProxy : DispatchProxy 11 | { 12 | private IRemoteCall remoteCall; 13 | 14 | public RemoteCallDispatchProxy() 15 | { 16 | this.remoteCall = null; 17 | } 18 | 19 | public static T Create(IRemoteCall remoteCall) where T : class 20 | { 21 | T proxy = RemoteCallDispatchProxy.Create(); 22 | (proxy as RemoteCallDispatchProxy).remoteCall = remoteCall; 23 | 24 | return proxy; 25 | } 26 | 27 | protected override object Invoke(MethodInfo targetMethod, object[] args) 28 | { 29 | return this.remoteCall.Call(targetMethod.Name, targetMethod.ReturnType, args); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Samples/PerformaceExamples/RemoteCallInterceptor.cs: -------------------------------------------------------------------------------- 1 | using MassiveDynamicProxyGenerator; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace PerformaceExamples 9 | { 10 | public class RemoteCallInterceptor : IInterceptor 11 | { 12 | private readonly IRemoteCall remoteCall; 13 | 14 | public RemoteCallInterceptor(IRemoteCall remoteCall) 15 | { 16 | this.remoteCall = remoteCall ?? throw new ArgumentNullException(nameof(remoteCall)); 17 | } 18 | 19 | public void Intercept(IInvocation invocation) 20 | { 21 | invocation.ReturnValue = this.remoteCall.Call(invocation.MethodName, invocation.ReturnType, invocation.Arguments); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Samples/ProxyGeneratrorSamples.Net40/Calculator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ProxyGeneratrorSamples.Net40 8 | { 9 | public class Calculator : ICalculator 10 | { 11 | public Calculator() 12 | { 13 | 14 | } 15 | 16 | public int Add(int a, int b) 17 | { 18 | return a + b; 19 | } 20 | 21 | public int Modulo(int a, int b) 22 | { 23 | if (b < 1) 24 | { 25 | throw new ArgumentOutOfRangeException("Parameter b can not by less of one."); 26 | } 27 | 28 | return a % b; 29 | } 30 | 31 | public int Product(int a, int b) 32 | { 33 | return a * b; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Samples/ProxyGeneratrorSamples.Net40/ErrorInterceptor.cs: -------------------------------------------------------------------------------- 1 | using MassiveDynamicProxyGenerator; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace ProxyGeneratrorSamples.Net40 9 | { 10 | /// 11 | /// Interceptor for handling exceptions from normal and async methods. 12 | /// 13 | /// 14 | public abstract class ErrorInterceptor : ICallableInterceptor 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | public ErrorInterceptor() 20 | { 21 | 22 | } 23 | 24 | /// 25 | /// Intercepts the specified invocation. 26 | /// 27 | /// The invocation informations. 28 | public void Intercept(ICallableInvocation invocation) 29 | { 30 | try 31 | { 32 | invocation.Process(); 33 | if (invocation.ReturnValue is Task) 34 | { 35 | invocation.ReturnValue = ((Task)invocation.ReturnValue).ContinueWith(task => 36 | { 37 | if (task.IsFaulted) 38 | { 39 | Exception agregateException = task.Exception; 40 | if (agregateException.InnerException != null) 41 | { 42 | agregateException = agregateException.InnerException; 43 | } 44 | 45 | this.HandleException(agregateException); 46 | } 47 | }); 48 | } 49 | } 50 | catch (Exception ex) 51 | { 52 | this.HandleException(ex); 53 | } 54 | } 55 | 56 | /// 57 | /// Handles the exception throws during call method or execute async . 58 | /// 59 | /// The handled . 60 | protected abstract void HandleException(Exception ex); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/Samples/ProxyGeneratrorSamples.Net40/ICalculator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ProxyGeneratrorSamples.Net40 8 | { 9 | public interface ICalculator 10 | { 11 | int Add(int a, int b); 12 | 13 | int Product(int a, int b); 14 | 15 | int Modulo(int a, int b); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Samples/ProxyGeneratrorSamples.Net40/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ProxyGeneratrorSamples.Net40")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ProxyGeneratrorSamples.Net40")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("e7f2b2b2-318c-4f2b-bf76-086a230e59fa")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /src/Samples/ProxyGeneratrorSamples.Net40/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/Controllers/ArticleController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using SampleWebApplication.Services.Contract; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using SampleWebApplication.Models.Article; 8 | 9 | namespace SampleWebApplication.Controllers 10 | { 11 | public class ArticleController : Controller 12 | { 13 | private readonly IArticleService articleServices; 14 | private readonly INotificationService notificationsService; 15 | 16 | public ArticleController(IArticleService articleServices, INotificationService notificationService) 17 | { 18 | this.articleServices = articleServices; 19 | this.notificationsService = notificationService; 20 | } 21 | 22 | public IActionResult Index() 23 | { 24 | List infos = this.articleServices.GetArticlesInfo(); 25 | IndexViewModel model = new IndexViewModel(infos); 26 | this.notificationsService.NotifyRead("ArticleMenu", null); 27 | 28 | return View(model); 29 | } 30 | 31 | public IActionResult Content(int id) 32 | { 33 | try 34 | { 35 | Article artcle = this.articleServices.ReadArticle(id); 36 | ContentViewModel model = new ContentViewModel(artcle); 37 | this.notificationsService.NotifyRead("Article", id); 38 | 39 | return this.View(model); 40 | } 41 | catch (KeyNotFoundException) 42 | { 43 | return this.NotFound(); 44 | } 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore.Mvc; 7 | using SampleWebApplication.Models; 8 | 9 | namespace SampleWebApplication.Controllers 10 | { 11 | public class HomeController : Controller 12 | { 13 | public IActionResult Index() 14 | { 15 | return View(); 16 | } 17 | 18 | public IActionResult About() 19 | { 20 | ViewData["Message"] = "Your application description page."; 21 | 22 | return View(); 23 | } 24 | 25 | public IActionResult Contact() 26 | { 27 | ViewData["Message"] = "Your contact page."; 28 | 29 | return View(); 30 | } 31 | 32 | public IActionResult Error() 33 | { 34 | return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/Models/Article/ContentViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace SampleWebApplication.Models.Article 7 | { 8 | public class ContentViewModel 9 | { 10 | public int Id 11 | { 12 | get; 13 | private set; 14 | } 15 | 16 | public string Title 17 | { 18 | get; 19 | private set; 20 | } 21 | 22 | public string Content 23 | { 24 | get; 25 | private set; 26 | } 27 | 28 | public string Autor 29 | { 30 | get; 31 | private set; 32 | } 33 | public ContentViewModel(SampleWebApplication.Services.Contract.Article article) 34 | { 35 | if (article == null) 36 | { 37 | throw new ArgumentNullException(nameof(article)); 38 | } 39 | 40 | this.Autor = article.Autor; 41 | this.Content = article.Content; 42 | this.Id = article.Id; 43 | this.Title = article.Title; 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/Models/Article/IndexViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace SampleWebApplication.Models.Article 7 | { 8 | public class IndexViewModel 9 | { 10 | public IReadOnlyCollection MenuItems 11 | { 12 | get; 13 | private set; 14 | } 15 | 16 | public IndexViewModel(IEnumerable infos) 17 | { 18 | if (infos == null) 19 | { 20 | throw new ArgumentNullException(nameof(infos)); 21 | } 22 | 23 | this.MenuItems = infos.Select(t => new MenuItemViewModel(t)).ToList(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/Models/Article/MenuItemViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace SampleWebApplication.Models.Article 7 | { 8 | public class MenuItemViewModel 9 | { 10 | public int Id 11 | { 12 | get; 13 | private set; 14 | } 15 | 16 | public string Title 17 | { 18 | get; 19 | private set; 20 | } 21 | 22 | public MenuItemViewModel(Services.Contract.ArticleInfo info) 23 | { 24 | if (info == null) 25 | { 26 | throw new ArgumentNullException(nameof(info)); 27 | } 28 | 29 | this.Id = info.Id; 30 | this.Title = info.Title; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SampleWebApplication.Models 4 | { 5 | public class ErrorViewModel 6 | { 7 | public string RequestId { get; set; } 8 | 9 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 10 | } 11 | } -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.Extensions.Configuration; 9 | using Microsoft.Extensions.Logging; 10 | 11 | namespace SampleWebApplication 12 | { 13 | public class Program 14 | { 15 | public static void Main(string[] args) 16 | { 17 | BuildWebHost(args).Run(); 18 | } 19 | 20 | public static IWebHost BuildWebHost(string[] args) => 21 | WebHost.CreateDefaultBuilder(args) 22 | .ConfigureLogging(loggerBuilder => 23 | { 24 | loggerBuilder.AddFilter((cathegory, _) => cathegory.StartsWith("SampleWebApplication")); 25 | loggerBuilder.AddConsole(); 26 | loggerBuilder.AddDebug(); 27 | }) 28 | .UseStartup() 29 | .Build(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:63084/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "SampleWebApplication": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "environmentVariables": { 22 | "ASPNETCORE_ENVIRONMENT": "Development" 23 | }, 24 | "applicationUrl": "http://localhost:63085/" 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/SampleWebApplication.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/Services/Contract/Article.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace SampleWebApplication.Services.Contract 7 | { 8 | public class Article 9 | { 10 | public int Id 11 | { 12 | get; 13 | set; 14 | } 15 | 16 | public string Title 17 | { 18 | get; 19 | set; 20 | } 21 | 22 | public string Content 23 | { 24 | get; 25 | set; 26 | } 27 | 28 | public string Autor 29 | { 30 | get; 31 | set; 32 | } 33 | 34 | public Article() 35 | { 36 | 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/Services/Contract/ArticleInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace SampleWebApplication.Services.Contract 7 | { 8 | public class ArticleInfo 9 | { 10 | public int Id 11 | { 12 | get; 13 | set; 14 | } 15 | 16 | public string Title 17 | { 18 | get; 19 | set; 20 | } 21 | 22 | public ArticleInfo() 23 | { 24 | 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/Services/Contract/IArticleService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace SampleWebApplication.Services.Contract 7 | { 8 | public interface IArticleService 9 | { 10 | List GetArticlesInfo(); 11 | 12 | Article ReadArticle(int id); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/Services/Contract/ICommonServices.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Hosting; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace SampleWebApplication.Services.Contract 8 | { 9 | public interface ICommonServices 10 | { 11 | IWebHostEnvironment HostingEnvironment 12 | { 13 | get; 14 | } 15 | 16 | INotificationService NotificationService 17 | { 18 | get; 19 | } 20 | 21 | // other srvices 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/Services/Contract/INotificationService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace SampleWebApplication.Services.Contract 7 | { 8 | public interface INotificationService 9 | { 10 | void NotifyRead(string itemName, object id); 11 | 12 | void NotifyUpdate(string itemName, object id); 13 | 14 | void NotifyInsert(string itemName, object id); 15 | 16 | void NotifyDelete(string itemName, object id); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/Services/Implementation/ArticleDecoratorService.cs: -------------------------------------------------------------------------------- 1 | using SampleWebApplication.Services.Contract; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace SampleWebApplication.Services.Implementation 8 | { 9 | public class ArticleDecoratorService : IArticleService 10 | { 11 | private readonly IArticleService parent; 12 | 13 | public ArticleDecoratorService(IArticleService parent) 14 | { 15 | this.parent = parent ?? throw new ArgumentNullException(nameof(parent)); 16 | } 17 | 18 | public List GetArticlesInfo() 19 | { 20 | return this.parent.GetArticlesInfo(); 21 | } 22 | 23 | public Article ReadArticle(int id) 24 | { 25 | Article article = this.parent.ReadArticle(id); 26 | 27 | article.Autor = "harrison314"; 28 | article.Content = string.Concat(article.Content, Environment.NewLine, "Decorated"); 29 | 30 | return article; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/Services/Implementation/MockArticleService.cs: -------------------------------------------------------------------------------- 1 | using SampleWebApplication.Services.Contract; 2 | using System; 3 | using System.Collections.Concurrent; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace SampleWebApplication.Services.Implementation 10 | { 11 | public class MockArticleService : IArticleService 12 | { 13 | private readonly ConcurrentDictionary articles; 14 | 15 | public MockArticleService() 16 | { 17 | this.articles = new ConcurrentDictionary(); 18 | this.AddArticle(1); 19 | this.AddArticle(2); 20 | this.AddArticle(3); 21 | this.AddArticle(7); 22 | this.AddArticle(13); 23 | this.AddArticle(28); 24 | } 25 | 26 | public List GetArticlesInfo() 27 | { 28 | List infos = new List(); 29 | foreach (Article article in this.articles.Values) 30 | { 31 | ArticleInfo info = new ArticleInfo(); 32 | info.Id = article.Id; 33 | info.Title = article.Title; 34 | 35 | infos.Add(info); 36 | } 37 | 38 | return infos; 39 | } 40 | 41 | public Article ReadArticle(int id) 42 | { 43 | Article article; 44 | 45 | if (this.articles.TryGetValue(id, out article)) 46 | { 47 | return article; 48 | } 49 | else 50 | { 51 | throw new KeyNotFoundException(); 52 | } 53 | } 54 | 55 | private void AddArticle(int id) 56 | { 57 | string title = $"Article {id}"; 58 | 59 | StringBuilder article = new StringBuilder(); 60 | for (int i = 0; i < 50; i++) 61 | { 62 | article.Append(title); 63 | article.Append(" "); 64 | if (i % 13 == 1) 65 | { 66 | article.AppendLine(); 67 | } 68 | } 69 | 70 | this.articles[id] = new Article() 71 | { 72 | Autor = $"Autor {id}", 73 | Content = article.ToString(), 74 | Id = id, 75 | Title = title 76 | }; 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/Services/Interceptors/ChangeAutorInterceptor.cs: -------------------------------------------------------------------------------- 1 | using MassiveDynamicProxyGenerator; 2 | using SampleWebApplication.Services.Contract; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | 8 | namespace SampleWebApplication.Services.Interceptors 9 | { 10 | public class ChangeAutorInterceptor : ICallableInterceptor 11 | { 12 | private readonly string name; 13 | 14 | public ChangeAutorInterceptor(string name) 15 | { 16 | this.name = name; 17 | } 18 | public void Intercept(ICallableInvocation invocation) 19 | { 20 | invocation.Process(); 21 | 22 | Article article = invocation.ReturnValue as Article; 23 | if (article != null) 24 | { 25 | article.Autor = this.name; 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/Services/Interceptors/ServiceProviderInterceptor.cs: -------------------------------------------------------------------------------- 1 | using MassiveDynamicProxyGenerator; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Reflection; 6 | using System.Threading.Tasks; 7 | 8 | namespace SampleWebApplication.Services.Interceptors 9 | { 10 | public class ServiceProviderInterceptor : IInterceptor 11 | { 12 | private readonly IServiceProvider serviceProvider; 13 | 14 | public ServiceProviderInterceptor(IServiceProvider serviceProvider) 15 | { 16 | this.serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); 17 | } 18 | 19 | public void Intercept(IInvocation invocation) 20 | { 21 | TypeInfo info = invocation.ReturnType.GetTypeInfo(); 22 | if (info.IsInterface || info.IsClass) 23 | { 24 | invocation.ReturnValue = this.serviceProvider.GetService(invocation.ReturnType); 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Builder; 6 | using Microsoft.AspNetCore.Hosting; 7 | using Microsoft.Extensions.Configuration; 8 | using Microsoft.Extensions.DependencyInjection; 9 | 10 | using MassiveDynamicProxyGenerator.Microsoft.DependencyInjection; 11 | using SampleWebApplication.Services.Contract; 12 | using SampleWebApplication.Services.Implementation; 13 | using SampleWebApplication.Services.Interceptors; 14 | using Microsoft.Extensions.Hosting; 15 | 16 | namespace SampleWebApplication 17 | { 18 | public class Startup 19 | { 20 | public IConfiguration Configuration { get; } 21 | 22 | public Startup(IConfiguration configuration) 23 | { 24 | this.Configuration = configuration; 25 | } 26 | 27 | public IServiceProvider ConfigureServices(IServiceCollection services) 28 | { 29 | services.AddSingleton(); 30 | 31 | 32 | services.AddInterceptedDecorator(); 33 | 34 | // services.AddDecorator(); 35 | // services.AddInterceptedDecorator("Ing interceptor"); 36 | 37 | services.AddProxy(); 38 | services.AddProxy(); 39 | 40 | services.AddControllers(); 41 | 42 | return services.BuildIntercepedServiceProvider(); 43 | } 44 | 45 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 46 | { 47 | if (env.IsDevelopment()) 48 | { 49 | app.UseDeveloperExceptionPage(); 50 | } 51 | else 52 | { 53 | app.UseExceptionHandler("/Home/Error"); 54 | } 55 | 56 | app.UseStaticFiles(); 57 | 58 | app.UseHttpsRedirection(); 59 | 60 | app.UseRouting(); 61 | 62 | app.UseAuthorization(); 63 | 64 | app.UseEndpoints(endpoints => 65 | { 66 | endpoints.MapControllers(); 67 | }); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/Views/Article/Content.cshtml: -------------------------------------------------------------------------------- 1 | @model SampleWebApplication.Models.Article.ContentViewModel 2 | @using System.Text 3 | @{ 4 | ViewBag.Title = Model.Title; 5 | } 6 | 7 |
8 |
9 |

@ViewBag.Title

10 | Articles 11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | @Model.Autor 19 | 20 |
21 |
22 |
23 |
24 |
25 | @Model.Title 26 |
27 |
28 |

@Model.Title

29 | @RenderWithParagraphs(Model.Content) 30 |
31 |
32 | 33 | 34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | 42 | @functions { 43 | public Microsoft.AspNetCore.Html.IHtmlContent RenderWithParagraphs(string content) 44 | { 45 | string[] lines = content.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); 46 | string html = lines.Aggregate(new StringBuilder(), (sb, line) => 47 | { 48 | sb.Append("

"); 49 | sb.Append(HtmlEncoder.Encode(line)); 50 | sb.AppendLine("

"); 51 | 52 | return sb; 53 | }).ToString(); 54 | 55 | return this.Html.Raw(html); 56 | } 57 | } -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/Views/Article/Index.cshtml: -------------------------------------------------------------------------------- 1 | @model SampleWebApplication.Models.Article.IndexViewModel 2 | @using SampleWebApplication.Models.Article 3 | @{ 4 | ViewBag.Title = "Article list"; 5 | } 6 | 7 |
8 |
9 |

@ViewBag.Title

10 |
11 |
12 |
13 |
14 | 24 |
25 |
-------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/Views/Home/About.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "About"; 3 | } 4 |

@ViewData["Title"]

5 |

@ViewData["Message"]

6 | 7 |

Use this area to provide additional information.

8 | -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/Views/Home/Contact.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Contact"; 3 | } 4 |

@ViewData["Title"]

5 |

@ViewData["Message"]

6 | 7 |
8 | One Microsoft Way
9 | Redmond, WA 98052-6399
10 | P: 11 | 425.555.0100 12 |
13 | 14 |
15 | Support: Support@example.com
16 | Marketing: Marketing@example.com 17 |
18 | -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @model ErrorViewModel 2 | @{ 3 | ViewData["Title"] = "Error"; 4 | } 5 | 6 |

Error.

7 |

An error occurred while processing your request.

8 | 9 | @if (Model.ShowRequestId) 10 | { 11 |

12 | Request ID: @Model.RequestId 13 |

14 | } 15 | 16 |

Development Mode

17 |

18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |

20 |

21 | Development environment should not be enabled in deployed applications, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application. 22 |

23 | -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 12 | 18 | 19 | -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using SampleWebApplication 2 | @using SampleWebApplication.Models 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "IncludeScopes": false, 4 | "LogLevel": { 5 | "Default": "Debug", 6 | "System": "Information", 7 | "Microsoft": "Information" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "IncludeScopes": false, 4 | "LogLevel": { 5 | "Default": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/bundleconfig.json: -------------------------------------------------------------------------------- 1 | // Configure bundling and minification for the project. 2 | // More info at https://go.microsoft.com/fwlink/?LinkId=808241 3 | [ 4 | { 5 | "outputFileName": "wwwroot/css/site.min.css", 6 | // An array of relative input file paths. Globbing patterns supported 7 | "inputFiles": [ 8 | "wwwroot/css/site.css" 9 | ] 10 | }, 11 | { 12 | "outputFileName": "wwwroot/js/site.min.js", 13 | "inputFiles": [ 14 | "wwwroot/js/site.js" 15 | ], 16 | // Optionally specify minification options 17 | "minify": { 18 | "enabled": true, 19 | "renameLocals": true 20 | }, 21 | // Optionally generate .map file 22 | "sourceMap": false 23 | } 24 | ] 25 | -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding-top: 50px; 3 | padding-bottom: 20px; 4 | } 5 | 6 | /* Wrapping element */ 7 | /* Set some basic padding to keep content from hitting the edges */ 8 | .body-content { 9 | padding-left: 15px; 10 | padding-right: 15px; 11 | } 12 | 13 | /* Carousel */ 14 | .carousel-caption p { 15 | font-size: 20px; 16 | line-height: 1.4; 17 | } 18 | 19 | /* Make .svg files in the carousel display properly in older browsers */ 20 | .carousel-inner .item img[src$=".svg"] { 21 | width: 100%; 22 | } 23 | 24 | /* QR code generator */ 25 | #qrCode { 26 | margin: 15px; 27 | } 28 | 29 | /* Hide/rearrange for smaller screens */ 30 | @media screen and (max-width: 767px) { 31 | /* Hide captions */ 32 | .carousel-caption { 33 | display: none; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/wwwroot/css/site.min.css: -------------------------------------------------------------------------------- 1 | body{padding-top:50px;padding-bottom:20px}.body-content{padding-left:15px;padding-right:15px}.carousel-caption p{font-size:20px;line-height:1.4}.carousel-inner .item img[src$=".svg"]{width:100%}#qrCode{margin:15px}@media screen and (max-width:767px){.carousel-caption{display:none}} -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harrison314/MassiveDynamicProxyGenerator/eed714dd848f6885293333188463f8a737d90685/src/Samples/SampleWebApplication/wwwroot/favicon.ico -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Write your JavaScript code. 2 | -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/wwwroot/js/site.min.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harrison314/MassiveDynamicProxyGenerator/eed714dd848f6885293333188463f8a737d90685/src/Samples/SampleWebApplication/wwwroot/js/site.min.js -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/wwwroot/lib/bootstrap/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bootstrap", 3 | "description": "The most popular front-end framework for developing responsive, mobile first projects on the web.", 4 | "keywords": [ 5 | "css", 6 | "js", 7 | "less", 8 | "mobile-first", 9 | "responsive", 10 | "front-end", 11 | "framework", 12 | "web" 13 | ], 14 | "homepage": "http://getbootstrap.com", 15 | "license": "MIT", 16 | "moduleType": "globals", 17 | "main": [ 18 | "less/bootstrap.less", 19 | "dist/js/bootstrap.js" 20 | ], 21 | "ignore": [ 22 | "/.*", 23 | "_config.yml", 24 | "CNAME", 25 | "composer.json", 26 | "CONTRIBUTING.md", 27 | "docs", 28 | "js/tests", 29 | "test-infra" 30 | ], 31 | "dependencies": { 32 | "jquery": "1.9.1 - 3" 33 | }, 34 | "version": "3.3.7", 35 | "_release": "3.3.7", 36 | "_resolution": { 37 | "type": "version", 38 | "tag": "v3.3.7", 39 | "commit": "0b9c4a4007c44201dce9a6cc1a38407005c26c86" 40 | }, 41 | "_source": "https://github.com/twbs/bootstrap.git", 42 | "_target": "v3.3.7", 43 | "_originalSource": "bootstrap", 44 | "_direct": true 45 | } -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2016 Twitter, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harrison314/MassiveDynamicProxyGenerator/eed714dd848f6885293333188463f8a737d90685/src/Samples/SampleWebApplication/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harrison314/MassiveDynamicProxyGenerator/eed714dd848f6885293333188463f8a737d90685/src/Samples/SampleWebApplication/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harrison314/MassiveDynamicProxyGenerator/eed714dd848f6885293333188463f8a737d90685/src/Samples/SampleWebApplication/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harrison314/MassiveDynamicProxyGenerator/eed714dd848f6885293333188463f8a737d90685/src/Samples/SampleWebApplication/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/wwwroot/lib/bootstrap/dist/js/npm.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment. 2 | require('../../js/transition.js') 3 | require('../../js/alert.js') 4 | require('../../js/button.js') 5 | require('../../js/carousel.js') 6 | require('../../js/collapse.js') 7 | require('../../js/dropdown.js') 8 | require('../../js/modal.js') 9 | require('../../js/tooltip.js') 10 | require('../../js/popover.js') 11 | require('../../js/scrollspy.js') 12 | require('../../js/tab.js') 13 | require('../../js/affix.js') -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/wwwroot/lib/jquery-validation-unobtrusive/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery-validation-unobtrusive", 3 | "version": "3.2.6", 4 | "homepage": "https://github.com/aspnet/jquery-validation-unobtrusive", 5 | "description": "Add-on to jQuery Validation to enable unobtrusive validation options in data-* attributes.", 6 | "main": [ 7 | "jquery.validate.unobtrusive.js" 8 | ], 9 | "ignore": [ 10 | "**/.*", 11 | "*.json", 12 | "*.md", 13 | "*.txt", 14 | "gulpfile.js" 15 | ], 16 | "keywords": [ 17 | "jquery", 18 | "asp.net", 19 | "mvc", 20 | "validation", 21 | "unobtrusive" 22 | ], 23 | "authors": [ 24 | "Microsoft" 25 | ], 26 | "license": "http://www.microsoft.com/web/webpi/eula/net_library_eula_enu.htm", 27 | "repository": { 28 | "type": "git", 29 | "url": "git://github.com/aspnet/jquery-validation-unobtrusive.git" 30 | }, 31 | "dependencies": { 32 | "jquery-validation": ">=1.8", 33 | "jquery": ">=1.8" 34 | }, 35 | "_release": "3.2.6", 36 | "_resolution": { 37 | "type": "version", 38 | "tag": "v3.2.6", 39 | "commit": "13386cd1b5947d8a5d23a12b531ce3960be1eba7" 40 | }, 41 | "_source": "git://github.com/aspnet/jquery-validation-unobtrusive.git", 42 | "_target": "3.2.6", 43 | "_originalSource": "jquery-validation-unobtrusive" 44 | } -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/wwwroot/lib/jquery-validation/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery-validation", 3 | "homepage": "http://jqueryvalidation.org/", 4 | "repository": { 5 | "type": "git", 6 | "url": "git://github.com/jzaefferer/jquery-validation.git" 7 | }, 8 | "authors": [ 9 | "Jörn Zaefferer " 10 | ], 11 | "description": "Form validation made easy", 12 | "main": "dist/jquery.validate.js", 13 | "keywords": [ 14 | "forms", 15 | "validation", 16 | "validate" 17 | ], 18 | "license": "MIT", 19 | "ignore": [ 20 | "**/.*", 21 | "node_modules", 22 | "bower_components", 23 | "test", 24 | "demo", 25 | "lib" 26 | ], 27 | "dependencies": { 28 | "jquery": ">= 1.7.2" 29 | }, 30 | "version": "1.14.0", 31 | "_release": "1.14.0", 32 | "_resolution": { 33 | "type": "version", 34 | "tag": "1.14.0", 35 | "commit": "c1343fb9823392aa9acbe1c3ffd337b8c92fed48" 36 | }, 37 | "_source": "git://github.com/jzaefferer/jquery-validation.git", 38 | "_target": ">=1.8", 39 | "_originalSource": "jquery-validation" 40 | } -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/wwwroot/lib/jquery/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery", 3 | "main": "dist/jquery.js", 4 | "license": "MIT", 5 | "ignore": [ 6 | "package.json" 7 | ], 8 | "keywords": [ 9 | "jquery", 10 | "javascript", 11 | "browser", 12 | "library" 13 | ] 14 | } -------------------------------------------------------------------------------- /src/Samples/SampleWebApplication/wwwroot/lib/jquery/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright JS Foundation and other contributors, https://js.foundation/ 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /src/Samples/WcfForHipsters.Client/ExampleServiceClient.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using WcfForHipsters.Client.WcfForHipsters; 6 | using WcfForHipsters.WebServer.Contract; 7 | 8 | namespace WcfForHipsters.Client 9 | { 10 | public class ExampleServiceClient : HipsterClientBase, IExampleService 11 | { 12 | public ExampleServiceClient(string endpointUrl) 13 | : base(endpointUrl) 14 | { 15 | } 16 | 17 | public ExampleServiceClient(Uri endpoint) 18 | : base(endpoint) 19 | { 20 | } 21 | 22 | public int CalCulateAdd(int a, int b, int c) 23 | { 24 | return this.Channal.CalCulateAdd(a, b, c); 25 | } 26 | 27 | public CreatBookResponse CreateBook(CreateBookRequest request) 28 | { 29 | if (request == null) throw new ArgumentNullException(nameof(request)); 30 | 31 | return this.Channal.CreateBook(request); 32 | } 33 | 34 | public void SendEvent(Guid id, string content, RequestMetadata metadata) 35 | { 36 | if (content == null) throw new ArgumentNullException(nameof(content)); 37 | if (metadata == null) throw new ArgumentNullException(nameof(metadata)); 38 | 39 | this.Channal.SendEvent(id, content, metadata); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/Samples/WcfForHipsters.Client/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using WcfForHipsters.WebServer.Contract; 6 | 7 | namespace WcfForHipsters.Client 8 | { 9 | public class Program 10 | { 11 | public static void Main(string[] args) 12 | { 13 | // Change url 14 | Uri endpoint = new Uri("http://localhost:57106/api/ExampleService"); 15 | 16 | ExampleServiceClient client = new ExampleServiceClient(endpoint); 17 | 18 | int sum = client.CalCulateAdd(14, 6, -1); 19 | Console.WriteLine("Sum is {0}", sum); 20 | Console.WriteLine(); 21 | 22 | CreateBookRequest createBook = new CreateBookRequest(); 23 | createBook.MarkdawnText = "# Title\nAny text"; 24 | createBook.Title = "Title"; 25 | createBook.Metadata = new RequestMetadata() 26 | { 27 | CorelationId = 475, 28 | Format = ReuquestFormat.Sync, 29 | Nonce = null 30 | }; 31 | 32 | CreatBookResponse response = client.CreateBook(createBook); 33 | 34 | Console.WriteLine("Book creted with Id {0}", response.Id); 35 | Console.WriteLine(); 36 | 37 | try 38 | { 39 | int nonExistSum = client.CalCulateAdd(1, 2, -500); 40 | Console.WriteLine("Sum is {0}", nonExistSum); 41 | } 42 | catch (WcfForHipsters.RpcFaultException ex) 43 | { 44 | Console.WriteLine("Server exception: {0}", ex.Message); 45 | } 46 | 47 | Console.WriteLine(); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/Samples/WcfForHipsters.Client/WcfForHipsters.Client.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/Samples/WcfForHipsters.Client/WcfForHipsters/HipsterClientBase.cs: -------------------------------------------------------------------------------- 1 | using MassiveDynamicProxyGenerator; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace WcfForHipsters.Client.WcfForHipsters 8 | { 9 | public abstract class HipsterClientBase where T : class 10 | { 11 | protected T Channal 12 | { 13 | get; 14 | private set; 15 | } 16 | 17 | public Uri Endpoint 18 | { 19 | get; 20 | private set; 21 | } 22 | 23 | public HipsterClientBase(Uri endpoint) 24 | { 25 | if (endpoint == null) 26 | { 27 | throw new ArgumentNullException(nameof(endpoint)); 28 | } 29 | 30 | //TODO: check type of T - must by interface with unique method names. 31 | 32 | this.Endpoint = endpoint; 33 | 34 | ProxyGenerator proxygenerator = new ProxyGenerator(); 35 | this.Channal = proxygenerator.GenerateProxy(new JsonRpcInterceptor(endpoint)); 36 | } 37 | 38 | public HipsterClientBase(string endpointUrl) 39 | : this(new Uri(endpointUrl)) 40 | { 41 | if (endpointUrl == null) 42 | { 43 | throw new ArgumentNullException(nameof(endpointUrl)); 44 | } 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Samples/WcfForHipsters.Client/WcfForHipsters/RpcFaultException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace WcfForHipsters.Client.WcfForHipsters 7 | { 8 | public class RpcFaultException : Exception 9 | { 10 | public RpcFaultException() 11 | { 12 | } 13 | 14 | public RpcFaultException(string message) 15 | : base(message) 16 | { 17 | } 18 | 19 | public RpcFaultException(string message, Exception innerException) 20 | : base(message, innerException) 21 | { 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Samples/WcfForHipsters.Client/WcfForHipsters/ServiceResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace WcfForHipsters.Client.WcfForHipsters 7 | { 8 | internal struct ServiceResponse 9 | { 10 | public readonly int StatusCode; 11 | 12 | public readonly string Content; 13 | 14 | public ServiceResponse(int statusCode, string responseContent) : this() 15 | { 16 | this.StatusCode = statusCode; 17 | this.Content = responseContent; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Samples/WcfForHipsters.WebServer/Contract/CreatBookResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace WcfForHipsters.WebServer.Contract 7 | { 8 | public class CreatBookResponse 9 | { 10 | public Guid Id 11 | { 12 | get; 13 | set; 14 | } 15 | 16 | public int UserId 17 | { 18 | get; 19 | set; 20 | } 21 | 22 | public DateTime CreateionTime 23 | { 24 | get; 25 | set; 26 | } 27 | 28 | public string PublicUrl 29 | { 30 | get; 31 | set; 32 | } 33 | 34 | public CreatBookResponse() 35 | { 36 | 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Samples/WcfForHipsters.WebServer/Contract/CreateBookRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace WcfForHipsters.WebServer.Contract 7 | { 8 | public class CreateBookRequest 9 | { 10 | public string Title 11 | { 12 | get; 13 | set; 14 | } 15 | 16 | public string MarkdawnText 17 | { 18 | get; 19 | set; 20 | } 21 | 22 | public RequestMetadata Metadata 23 | { 24 | get; 25 | set; 26 | } 27 | 28 | public CreateBookRequest() 29 | { 30 | 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Samples/WcfForHipsters.WebServer/Contract/IExampleService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace WcfForHipsters.WebServer.Contract 7 | { 8 | public interface IExampleService 9 | { 10 | int CalCulateAdd(int a, int b, int c); 11 | 12 | CreatBookResponse CreateBook(CreateBookRequest request); 13 | 14 | void SendEvent(Guid id, string content, RequestMetadata metadata); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Samples/WcfForHipsters.WebServer/Contract/RequestMetadata.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace WcfForHipsters.WebServer.Contract 7 | { 8 | public class RequestMetadata 9 | { 10 | public string Nonce 11 | { 12 | get; 13 | set; 14 | } 15 | 16 | public int CorelationId 17 | { 18 | get; 19 | set; 20 | } 21 | 22 | public ReuquestFormat Format 23 | { 24 | get; 25 | set; 26 | } 27 | 28 | public RequestMetadata() 29 | { 30 | 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Samples/WcfForHipsters.WebServer/Contract/ReuquestFormat.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace WcfForHipsters.WebServer.Contract 7 | { 8 | public enum ReuquestFormat 9 | { 10 | Async, 11 | Sync, 12 | Paralel, 13 | Lock 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/Samples/WcfForHipsters.WebServer/Controllers/ExampleServiceController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.Extensions.Logging; 3 | using Newtonsoft.Json.Linq; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Threading.Tasks; 8 | using WcfForHipsters.WebServer.Contract; 9 | using WcfForHipsters.WebServer.WcfForHipsters; 10 | 11 | namespace WcfForHipsters.WebServer.Controllers 12 | { 13 | [Route("api/[controller]")] 14 | public class ExampleServiceController : Controller 15 | { 16 | private readonly ILogger logger; 17 | private readonly EndpointAdapter serviceAdapter; 18 | 19 | public ExampleServiceController(EndpointAdapter serviceAdapter, ILogger logger) 20 | { 21 | if (serviceAdapter == null) 22 | { 23 | throw new ArgumentNullException(nameof(serviceAdapter)); 24 | } 25 | if (logger == null) 26 | { 27 | throw new ArgumentNullException(nameof(logger)); 28 | } 29 | 30 | this.serviceAdapter = serviceAdapter; 31 | this.logger = logger; 32 | } 33 | 34 | // api/ExampleService POST 35 | [HttpPost] 36 | public IActionResult Post([FromBody] JObject value) 37 | { 38 | this.logger.LogTrace("Endpoint invoked"); 39 | try 40 | { 41 | ResponseBody response = this.serviceAdapter.ProcessCall(value); 42 | return this.Json(response); 43 | } 44 | catch (FaultException ex) 45 | { 46 | this.logger.LogError("Exception during call Rpc method {0}", ex.InnerException); 47 | return this.Json(ex.FaultBody); 48 | } 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/Samples/WcfForHipsters.WebServer/Controllers/ValuesController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | 7 | namespace WcfForHipsters.WebServer.Controllers 8 | { 9 | [Route("api/[controller]")] 10 | public class ValuesController : Controller 11 | { 12 | [HttpGet] 13 | public IEnumerable Get() 14 | { 15 | return new string[] { "value1", "value2" }; 16 | } 17 | 18 | [HttpGet("{id}")] 19 | public string Get(int id) 20 | { 21 | return "value"; 22 | } 23 | 24 | [HttpPost] 25 | public void Post([FromBody] string value) 26 | { 27 | } 28 | 29 | [HttpPut("{id}")] 30 | public void Put(int id, [FromBody] string value) 31 | { 32 | } 33 | 34 | [HttpDelete("{id}")] 35 | public void Delete(int id) 36 | { 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Samples/WcfForHipsters.WebServer/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore.Hosting; 7 | using Microsoft.AspNetCore.Builder; 8 | using Microsoft.AspNetCore; 9 | 10 | namespace WcfForHipsters.WebServer 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateWebHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IWebHostBuilder CreateWebHostBuilder(string[] args) 20 | { 21 | return WebHost.CreateDefaultBuilder(args) 22 | .UseStartup(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Samples/WcfForHipsters.WebServer/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:57106/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "launchUrl": "api/values", 15 | "environmentVariables": { 16 | "ASPNETCORE_ENVIRONMENT": "Development" 17 | } 18 | }, 19 | "WcfForHipsters.WebServer": { 20 | "commandName": "Project", 21 | "launchBrowser": true, 22 | "launchUrl": "http://localhost:5000/api/values", 23 | "environmentVariables": { 24 | "ASPNETCORE_ENVIRONMENT": "Development" 25 | } 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /src/Samples/WcfForHipsters.WebServer/Services/ExampleService.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Logging; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using WcfForHipsters.WebServer.Contract; 7 | 8 | namespace WcfForHipsters.WebServer.Services 9 | { 10 | public class ExampleService : IExampleService 11 | { 12 | private ILogger logger; 13 | 14 | public ExampleService(ILogger logger) 15 | { 16 | this.logger = logger; 17 | } 18 | 19 | public int CalCulateAdd(int a, int b, int c) 20 | { 21 | this.logger.LogTrace("CalCulateAdd: a={0}, b={1}, c={2}", a, b, c); 22 | 23 | if (c < -150) 24 | { 25 | this.logger.LogError("Parameter c is out of range."); 26 | throw new ArgumentOutOfRangeException($"Parameter {nameof(c)} is out of range. Must by more as -150."); 27 | } 28 | 29 | return a + b + c; 30 | } 31 | 32 | public CreatBookResponse CreateBook(CreateBookRequest request) 33 | { 34 | this.logger.LogTrace("CreateBook with title: {0}", request.Title); 35 | 36 | CreatBookResponse response = new CreatBookResponse(); 37 | response.CreateionTime = DateTime.Now; 38 | response.Id = Guid.NewGuid(); 39 | response.PublicUrl = "https://temuri.org/" + response.Id.ToString(); 40 | response.UserId = request.MarkdawnText.Length; 41 | 42 | return response; 43 | } 44 | 45 | public void SendEvent(Guid id, string content, RequestMetadata metadata) 46 | { 47 | this.logger.LogTrace("SendEvent: id={0}, content={1}, c={2}", id, content); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/Samples/WcfForHipsters.WebServer/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Builder; 6 | using Microsoft.AspNetCore.Hosting; 7 | using Microsoft.Extensions.Configuration; 8 | using Microsoft.Extensions.DependencyInjection; 9 | using Microsoft.Extensions.Logging; 10 | using WcfForHipsters.WebServer.WcfForHipsters; 11 | using WcfForHipsters.WebServer.Contract; 12 | using WcfForHipsters.WebServer.Services; 13 | using Microsoft.Extensions.Hosting; 14 | 15 | namespace WcfForHipsters.WebServer 16 | { 17 | public class Startup 18 | { 19 | public Startup(IConfigurationRoot configuration) 20 | { 21 | this.Configuration = configuration; 22 | } 23 | 24 | public IConfigurationRoot Configuration { get; } 25 | 26 | // This method gets called by the runtime. Use this method to add services to the container 27 | public void ConfigureServices(IServiceCollection services) 28 | { 29 | services.AddTransient(); 30 | services.AddSingleton(typeof(EndpointAdapter<>)); 31 | 32 | services.AddControllers(); 33 | } 34 | 35 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline 36 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 37 | { 38 | if (env.IsDevelopment()) 39 | { 40 | app.UseDeveloperExceptionPage(); 41 | } 42 | else 43 | { 44 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 45 | 46 | app.UseHsts(); 47 | } 48 | 49 | app.UseStaticFiles(); 50 | app.UseHttpsRedirection(); 51 | 52 | app.UseRouting(); 53 | 54 | app.UseAuthorization(); 55 | 56 | app.UseEndpoints(endpoints => 57 | { 58 | endpoints.MapControllers(); 59 | }); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/Samples/WcfForHipsters.WebServer/WcfForHipsters.WebServer.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | PreserveNewest 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/Samples/WcfForHipsters.WebServer/WcfForHipsters/FaultBody.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace WcfForHipsters.WebServer.WcfForHipsters 7 | { 8 | public class FaultBody 9 | { 10 | public string jsonrpc 11 | { 12 | get; 13 | set; 14 | } 15 | 16 | public string id 17 | { 18 | get; 19 | set; 20 | } 21 | 22 | public string error 23 | { 24 | get; 25 | set; 26 | } 27 | 28 | public FaultBody() 29 | { 30 | 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Samples/WcfForHipsters.WebServer/WcfForHipsters/FaultException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace WcfForHipsters.WebServer.WcfForHipsters 7 | { 8 | public class FaultException : Exception 9 | { 10 | public FaultBody FaultBody 11 | { 12 | get; 13 | private set; 14 | } 15 | 16 | public FaultException(string message, string id, Exception innerException) 17 | : base(message, innerException) 18 | { 19 | this.FaultBody = new FaultBody() 20 | { 21 | error = innerException.ToString(), 22 | id = id, 23 | jsonrpc = "2.0" 24 | }; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Samples/WcfForHipsters.WebServer/WcfForHipsters/RequestBody.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace WcfForHipsters.WebServer.WcfForHipsters 7 | { 8 | public class RequestBody 9 | { 10 | public string jsonrpc 11 | { 12 | get; 13 | set; 14 | } 15 | 16 | public string method 17 | { 18 | get; 19 | set; 20 | } 21 | 22 | public object[] @params 23 | { 24 | get; 25 | set; 26 | } 27 | 28 | public string id 29 | { 30 | get; 31 | set; 32 | } 33 | 34 | public RequestBody() 35 | { 36 | 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Samples/WcfForHipsters.WebServer/WcfForHipsters/ResponseBody.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace WcfForHipsters.WebServer.WcfForHipsters 7 | { 8 | public class ResponseBody 9 | { 10 | public string jsonrpc 11 | { 12 | get; 13 | set; 14 | } 15 | 16 | public string method 17 | { 18 | get; 19 | set; 20 | } 21 | 22 | public object result 23 | { 24 | get; 25 | set; 26 | } 27 | 28 | public string id 29 | { 30 | get; 31 | set; 32 | } 33 | 34 | public ResponseBody() 35 | { 36 | 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Samples/WcfForHipsters.WebServer/WcfForHipsters/UnwrapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace WcfForHipsters.WebServer.WcfForHipsters 7 | { 8 | internal static class UnwrapHelper 9 | { 10 | public static object UnwrapTask(Task t) 11 | { 12 | t.GetAwaiter().GetResult(); 13 | 14 | return null; 15 | } 16 | 17 | public static object UnwrapGenericTask(Task task) 18 | { 19 | return task.GetAwaiter().GetResult(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Samples/WcfForHipsters.WebServer/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "IncludeScopes": false, 4 | "LogLevel": { 5 | "Default": "Debug", 6 | "System": "Information", 7 | "Microsoft": "Information" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/Samples/WcfForHipsters.WebServer/web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/Samples/WcfForHipsters.WebServer/wwwroot/humans.txt: -------------------------------------------------------------------------------- 1 | Humans 2 | 3 | 4 | Use JsonRpc call to api/ExampleService with post. To service WcfForHipsters.WebServer.Contract.IExampleService. -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.Microsoft.DependencyInjection/DefaultProxyGeneratorProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace MassiveDynamicProxyGenerator.Microsoft.DependencyInjection 6 | { 7 | internal class DefaultProxyGeneratorProvider : IProxyGeneratorProvider 8 | { 9 | private readonly IProxyGenerator proxygGenerator; 10 | 11 | public DefaultProxyGeneratorProvider() 12 | { 13 | this.proxygGenerator = new ProxyGenerator(); 14 | } 15 | 16 | public IProxyGenerator GetProxyGenerator(IServiceProvider serviceProvider) 17 | { 18 | return this.proxygGenerator; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.Microsoft.DependencyInjection/FuncInstanceProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace MassiveDynamicProxyGenerator.Microsoft.DependencyInjection 6 | { 7 | internal class FuncInstanceProvider : IInstanceProvicer 8 | { 9 | private readonly Func instaceFyctory; 10 | 11 | public FuncInstanceProvider(Func instaceFyctory) 12 | { 13 | this.instaceFyctory = instaceFyctory; 14 | } 15 | 16 | public void Dispose() 17 | { 18 | 19 | } 20 | 21 | public object GetInstance() 22 | { 23 | return this.instaceFyctory.Invoke(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.Microsoft.DependencyInjection/FuncProxyGeneratorProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace MassiveDynamicProxyGenerator.Microsoft.DependencyInjection 6 | { 7 | internal class FuncProxyGeneratorProvider : IProxyGeneratorProvider 8 | { 9 | private readonly Func provider; 10 | 11 | public FuncProxyGeneratorProvider(Func provider) 12 | { 13 | this.provider = provider; 14 | } 15 | 16 | public IProxyGenerator GetProxyGenerator(IServiceProvider serviceProvider) 17 | { 18 | if (serviceProvider == null) 19 | { 20 | throw new ArgumentNullException(nameof(serviceProvider)); 21 | } 22 | 23 | return this.provider.Invoke(serviceProvider); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.Microsoft.DependencyInjection/IOriginalService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace MassiveDynamicProxyGenerator.Microsoft.DependencyInjection 6 | { 7 | /// 8 | /// Interface provide original non-wrapped or intercepted service. 9 | /// 10 | /// Type of service. 11 | public interface IOriginalService where T : class 12 | { 13 | /// 14 | /// Gets the service instance. 15 | /// 16 | /// 17 | /// The service instance. 18 | /// 19 | T ServiceInstance 20 | { 21 | get; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.Microsoft.DependencyInjection/IProxyGeneratorProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace MassiveDynamicProxyGenerator.Microsoft.DependencyInjection 6 | { 7 | /// 8 | /// Interface represents provider for . 9 | /// 10 | /// 11 | public interface IProxyGeneratorProvider 12 | { 13 | /// 14 | /// Get or create instance. 15 | /// 16 | /// The service provider from IoC. 17 | /// Instance of proxy generator. 18 | IProxyGenerator GetProxyGenerator(IServiceProvider serviceProvider); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.Microsoft.DependencyInjection/MassiveDynamicProxyGenerator.Microsoft.DependencyInjection.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netstandard2.0 5 | MassiveDynamic ProxyGenerator Microsoft.DependencyInjection 6 | MassiveDynamicProxyGenerator Microsoft.Extensions.DependencyInjection is intergration MassiveDynamicProxyGenerator to standard IoC container in ASP.NET Core. 7 | massive, dynamic, proxy, dynamic proxy, runtime, .net, micoroft.extensions, IOC, ASP.NET, MVC 8 | Add support for .Net Core 3.1 and higher. 9 | NugetIcon.png 10 | 11 | 12 | 13 | 14 | bin\Debug\netstandard2.0\MassiveDynamicProxyGenerator.Microsoft.DependencyInjection.xml 15 | 0 16 | 17 | 18 | 19 | bin\Release\netstandard2.0\MassiveDynamicProxyGenerator.Microsoft.DependencyInjection.xml 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | True 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.Microsoft.DependencyInjection/MassiveDynamicProxyGeneratorDiSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace MassiveDynamicProxyGenerator.Microsoft.DependencyInjection 6 | { 7 | /// 8 | /// Settings for MassiveDynamicProxyGenerator with Microsoft.Extensions.DependencyInjection. 9 | /// 10 | public static class MassiveDynamicProxyGeneratorDiSettings 11 | { 12 | /// 13 | /// Gets Proxy generator provider. 14 | /// 15 | /// 16 | /// The proxy generator provider. 17 | /// 18 | internal static IProxyGeneratorProvider ProxyGeneratorProvider 19 | { 20 | get; 21 | private set; 22 | } 23 | 24 | static MassiveDynamicProxyGeneratorDiSettings() 25 | { 26 | ProxyGeneratorProvider = new DefaultProxyGeneratorProvider(); 27 | } 28 | 29 | /// 30 | /// Set default proxy generator provider. 31 | /// 32 | /// The proxy generator provider. 33 | /// provider 34 | /// 35 | public static void SetProxyGeneratorProvider(IProxyGeneratorProvider provider) 36 | { 37 | if (provider == null) 38 | { 39 | throw new ArgumentNullException(nameof(provider)); 40 | } 41 | 42 | ProxyGeneratorProvider = provider; 43 | } 44 | 45 | /// 46 | /// Set default proxy generator provider. 47 | /// 48 | /// The proxy generator provider as function. 49 | /// provider 50 | /// 51 | public static void SetProxyGeneratorProvider(Func provider) 52 | { 53 | if (provider == null) 54 | { 55 | throw new ArgumentNullException(nameof(provider)); 56 | } 57 | 58 | ProxyGeneratorProvider = new FuncProxyGeneratorProvider(provider); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.Microsoft.DependencyInjection/OriginalService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace MassiveDynamicProxyGenerator.Microsoft.DependencyInjection 6 | { 7 | /// 8 | /// Original service generic implementation. 9 | /// 10 | /// 11 | /// 12 | public class OriginalService : IOriginalService where T : class 13 | { 14 | /// 15 | /// Gets the service instance. 16 | /// 17 | /// 18 | /// The service instance. 19 | /// 20 | public T ServiceInstance 21 | { 22 | get; 23 | private set; 24 | } 25 | 26 | /// 27 | /// Initializes a new instance of the class. 28 | /// 29 | /// The service provider. 30 | /// serviceProvider 31 | public OriginalService(IServiceProvider serviceProvider) 32 | { 33 | if (serviceProvider == null) throw new ArgumentNullException(nameof(serviceProvider)); 34 | 35 | this.ServiceInstance = serviceProvider.GetService(typeof(T)) as T; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.Microsoft.DependencyInjection/ServiceCollectionExtensions.OriginalService.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace MassiveDynamicProxyGenerator.Microsoft.DependencyInjection 9 | { 10 | public static partial class ServiceCollectionExtensions 11 | { 12 | /// 13 | /// Adds the original service. 14 | /// 15 | /// The to add the service to. 16 | /// 17 | /// The to add the service to. 18 | /// 19 | public static IServiceCollection AddOriginalService(this IServiceCollection services) 20 | { 21 | services.AddTransient(typeof(IOriginalService<>), typeof(OriginalService<>)); 22 | return services; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.Microsoft.DependencyInjection/ServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace MassiveDynamicProxyGenerator.Microsoft.DependencyInjection 7 | { 8 | /// 9 | /// Extensions for . 10 | /// 11 | public static partial class ServiceCollectionExtensions 12 | { 13 | private static List GetDescriptors(this IServiceCollection services, Type serviceType) 14 | { 15 | List descriptors = new List(); 16 | 17 | foreach (ServiceDescriptor service in services) 18 | { 19 | if (service.ServiceType == serviceType) 20 | { 21 | descriptors.Add(service); 22 | } 23 | } 24 | 25 | if (descriptors.Count == 0) 26 | { 27 | throw new InvalidOperationException($"Could not find any registered services for type '{serviceType.FullName}'."); 28 | } 29 | 30 | return descriptors; 31 | } 32 | 33 | private static List GetDescriptors(this IServiceCollection services, Predicate predicate) 34 | { 35 | List descriptors = new List(); 36 | 37 | foreach (ServiceDescriptor service in services) 38 | { 39 | if (predicate.Invoke(service.ServiceType)) 40 | { 41 | descriptors.Add(service); 42 | } 43 | } 44 | 45 | return descriptors; 46 | } 47 | 48 | private static object GetInstanceFromDescriptor(IServiceProvider provider, ServiceDescriptor descriptor) 49 | { 50 | if (descriptor.ImplementationInstance != null) 51 | { 52 | return descriptor.ImplementationInstance; 53 | } 54 | 55 | if (descriptor.ImplementationType != null) 56 | { 57 | return ActivatorUtilities.GetServiceOrCreateInstance(provider, descriptor.ImplementationType); 58 | } 59 | 60 | return descriptor.ImplementationFactory(provider); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.Microsoft.DependencyInjection/ServiceProvider/IServiceWrapperer.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace MassiveDynamicProxyGenerator.Microsoft.DependencyInjection.ServiceProvider 7 | { 8 | /// 9 | /// Microsoft.Extensions.DependencyInjection service wrapperer. 10 | /// 11 | public interface IServiceWrapperer 12 | { 13 | /// 14 | /// Provides the instance or wrap this. 15 | /// 16 | /// Type of the requested service. 17 | /// The real instance or null. 18 | /// The ASP service provider. 19 | /// The proxy generator. 20 | /// Real service or wrapper. 21 | object ProvideInstance(Type serviceType, object realInstance, IServiceProvider aspServiceProvider, IProxyGenerator proxyGenerator); 22 | } 23 | } -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.Microsoft.DependencyInjection/ServiceProvider/MassiveScopedServiceFactory.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace MassiveDynamicProxyGenerator.Microsoft.DependencyInjection.ServiceProvider 7 | { 8 | internal class MassiveScopedServiceFactory : IServiceScopeFactory 9 | { 10 | private readonly IServiceScopeFactory serviceScopeFactory; 11 | private readonly IProxyGenerator proxygGenerator; 12 | private readonly IServiceWrapperer serviceWraperer; 13 | 14 | public MassiveScopedServiceFactory(IServiceScopeFactory serviceScopeFactory, IProxyGenerator proxygGenerator, IServiceWrapperer serviceWraperer ) 15 | { 16 | this.serviceScopeFactory = serviceScopeFactory; 17 | this.proxygGenerator = proxygGenerator; 18 | this.serviceWraperer = serviceWraperer; 19 | } 20 | 21 | public IServiceScope CreateScope() 22 | { 23 | IServiceScope serviceScope = this.serviceScopeFactory.CreateScope(); 24 | if (serviceScope is MassiveServiceScope) 25 | { 26 | return serviceScope; 27 | } 28 | else 29 | { 30 | return new MassiveServiceScope(serviceScope, this.proxygGenerator, this.serviceWraperer); 31 | } 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.Microsoft.DependencyInjection/ServiceProvider/MassiveServiceScope.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace MassiveDynamicProxyGenerator.Microsoft.DependencyInjection.ServiceProvider 7 | { 8 | internal class MassiveServiceScope : IServiceScope 9 | { 10 | private readonly IServiceScope serviceScope; 11 | private readonly IProxyGenerator proxygGenerator; 12 | private readonly IServiceWrapperer serviceWraperer; 13 | 14 | public IServiceProvider ServiceProvider 15 | { 16 | get 17 | { 18 | IServiceProvider serviceProvider = this.serviceScope.ServiceProvider; 19 | if(serviceProvider is MassiveServiceProvider) 20 | { 21 | return serviceProvider; 22 | } 23 | else 24 | { 25 | return new MassiveServiceProvider(serviceProvider, this.proxygGenerator, this.serviceWraperer); 26 | } 27 | } 28 | } 29 | 30 | public MassiveServiceScope(IServiceScope serviceScope, IProxyGenerator proxygGenerator, IServiceWrapperer serviceWraperer) 31 | { 32 | this.serviceScope = serviceScope; 33 | this.proxygGenerator = proxygGenerator; 34 | this.serviceWraperer = serviceWraperer; 35 | } 36 | 37 | public void Dispose() 38 | { 39 | this.serviceScope.Dispose(); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.Microsoft.DependencyInjection/ServiceProvider/OriginalServiceContainer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq.Expressions; 4 | using System.Reflection; 5 | using System.Text; 6 | 7 | namespace MassiveDynamicProxyGenerator.Microsoft.DependencyInjection.ServiceProvider 8 | { 9 | internal class OriginalServiceContainer : IOriginalService where T : class 10 | { 11 | public T ServiceInstance 12 | { 13 | get; 14 | protected set; 15 | } 16 | 17 | public OriginalServiceContainer(T instance) 18 | { 19 | this.ServiceInstance = instance; 20 | } 21 | 22 | public static object BuildOriginalService(Type genericType, object serviceInstance) 23 | { 24 | Type originalType = typeof(OriginalServiceContainer<>).MakeGenericType(genericType); 25 | ConstructorInfo constructor = originalType.GetConstructor(new Type[] { genericType }); 26 | 27 | Expression instance = Expression.Constant(serviceInstance, genericType); 28 | Expression newExpr = Expression.New(constructor, instance); 29 | 30 | return Expression.Lambda>(newExpr).Compile().Invoke(); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.Microsoft.DependencyInjection/TypeHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Reflection; 4 | using System.Runtime.CompilerServices; 5 | using System.Text; 6 | 7 | namespace MassiveDynamicProxyGenerator.Microsoft.DependencyInjection 8 | { 9 | internal class TypeHelper 10 | { 11 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 12 | public static bool IsOpenGeneric(Type type) 13 | { 14 | return type.GetTypeInfo().IsGenericTypeDefinition; 15 | } 16 | 17 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 18 | public static bool IsGenericConstructedOf(Type genericDefinitionType, Type constructedType) 19 | { 20 | if (!genericDefinitionType.GetTypeInfo().IsGenericType || !constructedType.GetTypeInfo().IsGenericType) 21 | { 22 | return false; 23 | } 24 | 25 | return constructedType.GetGenericTypeDefinition() == genericDefinitionType; 26 | } 27 | 28 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 29 | public static bool IsPublicInterface(Type type) 30 | { 31 | return type.GetTypeInfo().IsPublic && type.GetTypeInfo().IsInterface; 32 | } 33 | 34 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 35 | public static Type[] GetConstructorRequiredTypes(Type type) 36 | { 37 | ConstructorInfo[] constructors = type.GetConstructors(BindingFlags.Public | BindingFlags.Instance); 38 | if (constructors.Length != 1) 39 | { 40 | throw new ArgumentException($"Type '{type.AssemblyQualifiedName}' must have only one public constructor."); 41 | } 42 | 43 | ParameterInfo[] parameters = constructors[0].GetParameters(); 44 | Type[] requiredTypes = new Type[parameters.Length]; 45 | for (int i = 0; i < requiredTypes.Length; i++) 46 | { 47 | requiredTypes[i] = parameters[i].ParameterType; 48 | } 49 | 50 | return requiredTypes; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.SimpleInjector/ContainerExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using MassiveDynamicProxyGenerator; 3 | using MassiveDynamicProxyGenerator.SimpleInjector; 4 | using SimpleInjector; 5 | 6 | namespace MassiveDynamicProxyGenerator.SimpleInjector 7 | { 8 | /// 9 | /// Extensions for SimpleInjector using MassiveDynamicProxyGenerator. 10 | /// 11 | /// 12 | /// 13 | public static partial class ContainerExtensions 14 | { 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.SimpleInjector/Dangerous/DangerousContainerExtensions.Mock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Reflection; 5 | using MassiveDynamicProxyGenerator; 6 | using MassiveDynamicProxyGenerator.SimpleInjector; 7 | using SimpleInjector; 8 | 9 | namespace MassiveDynamicProxyGenerator.SimpleInjector.Dangerous 10 | { 11 | public static partial class DangerousContainerExtensions 12 | { 13 | /// 14 | /// Register mocks for all unregistered types in container. 15 | /// This operation use only design mode or tests. 16 | /// 17 | /// The container. 18 | public static void RegisterAllUnregisteredAsMock(this Container container) 19 | { 20 | IProxyGenerator generator = ProxyGeneratorFactory.Factory.GetInstance(); 21 | 22 | container.ResolveUnregisteredType += (sender, arguments) => 23 | { 24 | if (!arguments.Handled && arguments.UnregisteredServiceType.GetTypeInfo().IsInterface) 25 | { 26 | #if NET40 27 | arguments.Register(() => generator.GenerateProxy(arguments.UnregisteredServiceType, new NullInterceptor())); 28 | #else 29 | arguments.Register(() => generator.GenerateProxy(arguments.UnregisteredServiceType, new NullAsyncInterceptor())); 30 | #endif 31 | } 32 | }; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.SimpleInjector/Dangerous/DangerousContainerExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace MassiveDynamicProxyGenerator.SimpleInjector.Dangerous 6 | { 7 | /// 8 | /// Extensions for dangerous operations. 9 | /// This extensions using in tests or design time in WPF applications. 10 | /// 11 | public static partial class DangerousContainerExtensions 12 | { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.SimpleInjector/DefaultProxyGeneratorFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace MassiveDynamicProxyGenerator.SimpleInjector 6 | { 7 | internal class DefaultProxyGeneratorFactory : IProxyGeneratorFactory 8 | { 9 | public DefaultProxyGeneratorFactory() 10 | { 11 | } 12 | 13 | public IProxyGenerator GetInstance() 14 | { 15 | return new ProxyGenerator(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.SimpleInjector/FullFrameworkExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Reflection; 5 | using System.Runtime.CompilerServices; 6 | 7 | namespace MassiveDynamicProxyGenerator.SimpleInjector 8 | { 9 | #if !(NETSTANDARD1_6 || NETSTANDARD1_4 || NETSTANDARD2_0) 10 | 11 | /// 12 | /// Extensions for adapt .Net Core API to full framework. 13 | /// 14 | #if !NET40 && !NET45 15 | // [MethodImpl(MethodImplOptions.AggressiveInlining)] 16 | #endif 17 | internal static class FullFrameworkExtensions 18 | { 19 | /// 20 | /// Gets same type for NET Standard compatibility. 21 | /// 22 | /// The type. 23 | /// The same type. 24 | public static Type GetTypeInfo(this Type type) 25 | { 26 | return type; 27 | } 28 | } 29 | 30 | #endif 31 | } -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.SimpleInjector/FuncInstanceProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace MassiveDynamicProxyGenerator.SimpleInjector 6 | { 7 | internal class FuncInstanceProvider : IInstanceProvicer 8 | { 9 | private readonly Func factory; 10 | 11 | public FuncInstanceProvider(Func factory) 12 | { 13 | this.factory = factory; 14 | } 15 | 16 | public void Dispose() 17 | { 18 | } 19 | 20 | public object GetInstance() 21 | { 22 | return this.factory(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.SimpleInjector/GlobalSuppressions.cs: -------------------------------------------------------------------------------- 1 | // This file is used by Code Analysis to maintain SuppressMessage 2 | // attributes that are applied to this project. 3 | // Project-level suppressions either have no target or are given 4 | // a specific target and scoped to a namespace, type, member, etc. 5 | 6 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1601:Partial elements must be documented", Justification = "ContainerExtensions is partial class with documentation.", Scope = "type", Target = "~T:MassiveDynamicProxyGenerator.SimpleInjector.ContainerExtensions")] 7 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1601:Partial elements must be documented", Justification = "DangerousContainerExtensions is partial class with documentation.", Scope = "type", Target = "~T:MassiveDynamicProxyGenerator.SimpleInjector.Dangerous.DangerousContainerExtensions")] 8 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.SimpleInjector/IProxyGeneratorFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace MassiveDynamicProxyGenerator.SimpleInjector 6 | { 7 | /// 8 | /// Interface represents factory for crate 9 | /// for Simple Injector extensions. 10 | /// 11 | /// 12 | /// 13 | /// 14 | /// 15 | /// 16 | public interface IProxyGeneratorFactory 17 | { 18 | /// 19 | /// Gets the instance of . 20 | /// 21 | /// Instance . 22 | IProxyGenerator GetInstance(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.SimpleInjector/Interception/FuncInterceptedProxyBuilder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq.Expressions; 4 | using System.Text; 5 | using System.Reflection; 6 | using SimpleInjector; 7 | 8 | namespace MassiveDynamicProxyGenerator.SimpleInjector.Interception 9 | { 10 | internal class FuncInterceptedProxyBuilder : InterceptedProxyBuilder 11 | { 12 | private static readonly MethodInfo InvokeMethod = typeof(Func).GetTypeInfo().GetMethod(nameof(Func.Invoke)); 13 | 14 | private readonly Type serviceType; 15 | private readonly Func interceptorFactory; 16 | 17 | public FuncInterceptedProxyBuilder(IProxyGenerator generator, Type serviceType, Func interceptorFactory) 18 | : base(generator) 19 | { 20 | this.serviceType = serviceType; 21 | this.interceptorFactory = interceptorFactory; 22 | } 23 | 24 | protected override Expression BuildInterceptionExpression(Container container, Type typeToIntercept) 25 | { 26 | return Expression.Call(Expression.Constant(this.interceptorFactory, typeof(Func)), InvokeMethod); 27 | } 28 | 29 | protected override bool CheckTypeToIntercept(Type interfaceType) 30 | { 31 | return this.serviceType == interfaceType; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.SimpleInjector/Interception/FuncInterceptionBuilder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq.Expressions; 4 | using System.Text; 5 | using System.Reflection; 6 | using SimpleInjector; 7 | 8 | namespace MassiveDynamicProxyGenerator.SimpleInjector.Interception 9 | { 10 | internal class FuncInterceptionBuilder : InterceptionBuilder 11 | { 12 | private static readonly MethodInfo InvokeMethod = typeof(Func).GetTypeInfo().GetMethod(nameof(Func.Invoke)); 13 | 14 | private readonly Predicate predicate; 15 | private readonly Func interceptorFactory; 16 | 17 | public FuncInterceptionBuilder(IProxyGenerator generator, Predicate predicate, Func interceptorFactory) 18 | : base(generator) 19 | { 20 | this.predicate = predicate; 21 | this.interceptorFactory = interceptorFactory; 22 | } 23 | 24 | protected override Expression BuildInterceptionExpression(Container container, Type typeToIntercept) 25 | { 26 | return Expression.Call(Expression.Constant(this.interceptorFactory, typeof(Func)), InvokeMethod); 27 | } 28 | 29 | protected override bool CheckTypeToIntercept(Type typeToIntercept) 30 | { 31 | return this.predicate(typeToIntercept); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.SimpleInjector/Interception/InstanceInterceptedProxyBuilder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq.Expressions; 4 | using System.Text; 5 | using SimpleInjector; 6 | 7 | namespace MassiveDynamicProxyGenerator.SimpleInjector.Interception 8 | { 9 | internal class InstanceInterceptedProxyBuilder : InterceptedProxyBuilder 10 | { 11 | private readonly Type serviceType; 12 | private readonly IInterceptor interceptor; 13 | 14 | public InstanceInterceptedProxyBuilder(IProxyGenerator generator, Type serviceType, IInterceptor interceptor) 15 | : base(generator) 16 | { 17 | this.serviceType = serviceType; 18 | this.interceptor = interceptor; 19 | } 20 | 21 | protected override Expression BuildInterceptionExpression(Container container, Type typeToIntercept) 22 | { 23 | return Expression.Constant(this.interceptor, typeof(IInterceptor)); 24 | } 25 | 26 | protected override bool CheckTypeToIntercept(Type interfaceType) 27 | { 28 | return this.serviceType == interfaceType; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.SimpleInjector/Interception/InstanceInterceptionBuilder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq.Expressions; 4 | using System.Text; 5 | using SimpleInjector; 6 | 7 | namespace MassiveDynamicProxyGenerator.SimpleInjector.Interception 8 | { 9 | internal class InstanceInterceptionBuilder : InterceptionBuilder 10 | { 11 | private readonly Predicate predicate; 12 | private readonly ICallableInterceptor interceptor; 13 | 14 | public InstanceInterceptionBuilder(Predicate predicate, IProxyGenerator generator, ICallableInterceptor interceptor) 15 | : base(generator) 16 | { 17 | this.interceptor = interceptor; 18 | this.predicate = predicate; 19 | } 20 | 21 | protected override Expression BuildInterceptionExpression(Container container, Type typeToIntercept) 22 | { 23 | return Expression.Constant(this.interceptor, typeof(ICallableInterceptor)); 24 | } 25 | 26 | protected override bool CheckTypeToIntercept(Type typeToIntercept) 27 | { 28 | return this.predicate(typeToIntercept); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.SimpleInjector/Interception/OpenFuncInterceptedProxyBuilder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq.Expressions; 4 | using System.Reflection; 5 | using System.Text; 6 | using SimpleInjector; 7 | 8 | namespace MassiveDynamicProxyGenerator.SimpleInjector.Interception 9 | { 10 | internal class OpenFuncInterceptedProxyBuilder : InterceptedProxyBuilder 11 | { 12 | private static readonly MethodInfo InvokeMethod = typeof(Func).GetTypeInfo().GetMethod(nameof(Func.Invoke)); 13 | 14 | private readonly Type serviceType; 15 | private readonly Func interceptorFactory; 16 | 17 | public OpenFuncInterceptedProxyBuilder(IProxyGenerator generator, Type serviceType, Func interceptorFactory) 18 | : base(generator) 19 | { 20 | this.serviceType = serviceType; 21 | this.interceptorFactory = interceptorFactory; 22 | } 23 | 24 | protected override Expression BuildInterceptionExpression(Container container, Type typeToIntercept) 25 | { 26 | return Expression.Call(Expression.Constant(this.interceptorFactory, typeof(Func)), InvokeMethod); 27 | } 28 | 29 | protected override bool CheckTypeToIntercept(Type interfaceType) 30 | { 31 | return TypeHelper.IsGenericConstructedOf(this.serviceType, interfaceType); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.SimpleInjector/Interception/OpenInstanceInterceptedProxyBuilder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq.Expressions; 4 | using System.Text; 5 | using SimpleInjector; 6 | 7 | namespace MassiveDynamicProxyGenerator.SimpleInjector.Interception 8 | { 9 | internal class OpenInstanceInterceptedProxyBuilder : InterceptedProxyBuilder 10 | { 11 | private readonly Type serviceType; 12 | private readonly IInterceptor interceptor; 13 | 14 | public OpenInstanceInterceptedProxyBuilder(IProxyGenerator generator, Type serviceType, IInterceptor interceptor) 15 | : base(generator) 16 | { 17 | this.serviceType = serviceType; 18 | this.interceptor = interceptor; 19 | } 20 | 21 | protected override Expression BuildInterceptionExpression(Container container, Type typeToIntercept) 22 | { 23 | return Expression.Constant(this.interceptor, typeof(IInterceptor)); 24 | } 25 | 26 | protected override bool CheckTypeToIntercept(Type interfaceType) 27 | { 28 | return TypeHelper.IsGenericConstructedOf(this.serviceType, interfaceType); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.SimpleInjector/Interception/OpenTypeInterceptedProxyBuilder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq.Expressions; 4 | using System.Text; 5 | using SimpleInjector; 6 | 7 | namespace MassiveDynamicProxyGenerator.SimpleInjector.Interception 8 | { 9 | internal class OpenTypeInterceptedProxyBuilder : InterceptedProxyBuilder 10 | { 11 | private readonly Type serviceType; 12 | private readonly Type interceptorType; 13 | 14 | public OpenTypeInterceptedProxyBuilder(IProxyGenerator generator, Type serviceType, Type interceptorType) 15 | : base(generator) 16 | { 17 | this.serviceType = serviceType; 18 | this.interceptorType = interceptorType; 19 | } 20 | 21 | protected override Expression BuildInterceptionExpression(Container container, Type typeToIntercept) 22 | { 23 | InstanceProducer producer = container.GetRegistration(this.interceptorType, false); 24 | Expression interceptorSourse = (producer != null) ? producer.BuildExpression() : Expression.New(this.interceptorType); 25 | 26 | return interceptorSourse; 27 | } 28 | 29 | protected override bool CheckTypeToIntercept(Type interfaceType) 30 | { 31 | return TypeHelper.IsGenericConstructedOf(this.serviceType, interfaceType); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.SimpleInjector/Interception/TypeInterceptedProxyBuilder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq.Expressions; 4 | using System.Text; 5 | using SimpleInjector; 6 | 7 | namespace MassiveDynamicProxyGenerator.SimpleInjector.Interception 8 | { 9 | internal class TypeInterceptedProxyBuilder : InterceptedProxyBuilder 10 | { 11 | private readonly Type serviceType; 12 | private readonly Type interceptorType; 13 | 14 | public TypeInterceptedProxyBuilder(IProxyGenerator generator, Type serviceType, Type interceptorType) 15 | : base(generator) 16 | { 17 | this.serviceType = serviceType; 18 | this.interceptorType = interceptorType; 19 | } 20 | 21 | protected override Expression BuildInterceptionExpression(Container container, Type typeToIntercept) 22 | { 23 | InstanceProducer producer = container.GetRegistration(this.interceptorType, false); 24 | Expression interceptorSourse = (producer != null) ? producer.BuildExpression() : Expression.New(this.interceptorType); 25 | 26 | return interceptorSourse; 27 | } 28 | 29 | protected override bool CheckTypeToIntercept(Type interfaceType) 30 | { 31 | return this.serviceType == interfaceType; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.SimpleInjector/Interception/TypeInterceptionBuilder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq.Expressions; 4 | using System.Text; 5 | using SimpleInjector; 6 | 7 | namespace MassiveDynamicProxyGenerator.SimpleInjector.Interception 8 | { 9 | internal class TypeInterceptionBuilder : InterceptionBuilder 10 | { 11 | private readonly Predicate predicate; 12 | private readonly Type interceptorType; 13 | 14 | public TypeInterceptionBuilder(Predicate predicate, IProxyGenerator generator, Type interceptorType) 15 | : base(generator) 16 | { 17 | this.interceptorType = interceptorType; 18 | this.predicate = predicate; 19 | } 20 | 21 | protected override Expression BuildInterceptionExpression(Container container, Type typeToIntercept) 22 | { 23 | InstanceProducer producer = container.GetRegistration(this.interceptorType, false); 24 | Expression interceptorSourse = (producer != null) ? producer.BuildExpression() : Expression.New(this.interceptorType); 25 | 26 | return interceptorSourse; 27 | } 28 | 29 | protected override bool CheckTypeToIntercept(Type typeToIntercept) 30 | { 31 | return this.predicate(typeToIntercept) && this.interceptorType != typeToIntercept; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.SimpleInjector/ProxyGeneratorFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace MassiveDynamicProxyGenerator.SimpleInjector 6 | { 7 | /// 8 | /// Class represents singleton for generate . 9 | /// 10 | public static class ProxyGeneratorFactory 11 | { 12 | private static IProxyGeneratorFactory factory; 13 | 14 | /// 15 | /// Gets the instance of factory. 16 | /// 17 | /// 18 | /// The instance of factory. 19 | /// 20 | public static IProxyGeneratorFactory Factory 21 | { 22 | get => factory; 23 | } 24 | 25 | static ProxyGeneratorFactory() 26 | { 27 | factory = new DefaultProxyGeneratorFactory(); 28 | } 29 | 30 | /// 31 | /// Overrides the factory instance. 32 | /// 33 | /// The new factory instance. 34 | /// newFactory 35 | public static void OverrideFactory(IProxyGeneratorFactory newFactory) 36 | { 37 | if (newFactory == null) 38 | { 39 | throw new ArgumentNullException(nameof(newFactory)); 40 | } 41 | 42 | factory = newFactory; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.SimpleInjector/Registrations/InstanceProxyWithTypeRegistration.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq.Expressions; 4 | using System.Linq; 5 | using System.Reflection; 6 | using System.Text; 7 | using SimpleInjector; 8 | 9 | namespace MassiveDynamicProxyGenerator.SimpleInjector.Registrations 10 | { 11 | internal class InstanceProxyWithTypeRegistration : Registration 12 | { 13 | protected static readonly MethodInfo GenerateInstanceProxyMethod = typeof(IProxyGenerator).GetTypeInfo() 14 | .GetMethod(nameof(IProxyGenerator.GenerateInstanceProxy), new[] { typeof(Type), typeof(IInstanceProvicer) }); 15 | 16 | private readonly Type instanceProviderType; 17 | private readonly IProxyGenerator generator; 18 | 19 | public InstanceProxyWithTypeRegistration(Lifestyle lifestyle, Container container, Type implementationType, Type instanceProviderType, IProxyGenerator generator) 20 | : base(lifestyle, container, implementationType, null) 21 | { 22 | this.instanceProviderType = instanceProviderType; 23 | this.generator = generator; 24 | } 25 | 26 | public override Expression BuildExpression() 27 | { 28 | InstanceProducer producer = this.Container.GetCurrentRegistrations().LastOrDefault(t => t.ServiceType == this.instanceProviderType); 29 | Expression interceptorSourse = (producer != null) ? producer.BuildExpression() : Expression.New(this.instanceProviderType); 30 | 31 | Expression generator = Expression.Constant(this.generator, typeof(IProxyGenerator)); 32 | Expression typeOfInstance = Expression.Constant(this.ImplementationType, typeof(Type)); 33 | Expression crateInstance = Expression.Call(generator, GenerateInstanceProxyMethod, typeOfInstance, interceptorSourse); 34 | 35 | return Expression.Convert(crateInstance, this.ImplementationType); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.SimpleInjector/Registrations/ProxyWithFactoryInterceptorRegistration.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Linq.Expressions; 5 | using System.Reflection; 6 | using SimpleInjector; 7 | 8 | namespace MassiveDynamicProxyGenerator.SimpleInjector.Registrations 9 | { 10 | internal class ProxyWithFactoryInterceptorRegistration : Registration 11 | { 12 | protected static readonly MethodInfo GenerateProxyMethod = typeof(IProxyGenerator).GetTypeInfo() 13 | .GetMethod(nameof(IProxyGenerator.GenerateProxy), new[] { typeof(Type), typeof(IInterceptor) }); 14 | 15 | private readonly Func factory; 16 | private readonly IProxyGenerator generator; 17 | 18 | public ProxyWithFactoryInterceptorRegistration(Lifestyle lifestyle, Container container, Type implementationType, Func factory, IProxyGenerator generator) 19 | : base(lifestyle, container, implementationType) 20 | { 21 | this.factory = factory; 22 | 23 | this.generator = generator; 24 | } 25 | 26 | public override Expression BuildExpression() 27 | { 28 | Expression interceptorSourse = Expression.Invoke(Expression.Constant(this.factory, typeof(Func))); 29 | 30 | Expression generator = Expression.Constant(this.generator, typeof(IProxyGenerator)); 31 | Expression typeOfInstance = Expression.Constant(this.ImplementationType, typeof(Type)); 32 | Expression crateInstance = Expression.Call(generator, GenerateProxyMethod, typeOfInstance, interceptorSourse); 33 | 34 | return Expression.Convert(crateInstance, this.ImplementationType); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.SimpleInjector/Registrations/ProxyWithInstanceInterceptorRegistration.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Linq.Expressions; 5 | using System.Reflection; 6 | using SimpleInjector; 7 | 8 | namespace MassiveDynamicProxyGenerator.SimpleInjector.Registrations 9 | { 10 | internal class ProxyWithInstanceInterceptorRegistration : Registration 11 | { 12 | protected static readonly MethodInfo GenerateProxyMethod = typeof(IProxyGenerator).GetTypeInfo() 13 | .GetMethod(nameof(IProxyGenerator.GenerateProxy), new[] { typeof(Type), typeof(IInterceptor) }); 14 | 15 | private readonly IInterceptor instance; 16 | private readonly IProxyGenerator generator; 17 | 18 | public ProxyWithInstanceInterceptorRegistration(Lifestyle lifestyle, Container container, Type implementationType, IInterceptor instance, IProxyGenerator generator) 19 | : base(lifestyle, container, implementationType) 20 | { 21 | this.instance = instance; 22 | 23 | this.generator = generator; 24 | } 25 | 26 | public override Expression BuildExpression() 27 | { 28 | Expression interceptorSourse = Expression.Constant(this.instance, typeof(IInterceptor)); 29 | 30 | Expression generator = Expression.Constant(this.generator, typeof(IProxyGenerator)); 31 | Expression typeOfInstance = Expression.Constant(this.ImplementationType, typeof(Type)); 32 | Expression crateInstance = Expression.Call(generator, GenerateProxyMethod, typeOfInstance, interceptorSourse); 33 | 34 | return Expression.Convert(crateInstance, this.ImplementationType); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.SimpleInjector/Registrations/ProxyWithTypeInterceptorRegistration.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Linq.Expressions; 5 | using System.Reflection; 6 | using SimpleInjector; 7 | 8 | namespace MassiveDynamicProxyGenerator.SimpleInjector.Registrations 9 | { 10 | internal class ProxyWithTypeInterceptorRegistration : Registration 11 | { 12 | protected static readonly MethodInfo GenerateProxyMethod = typeof(IProxyGenerator).GetTypeInfo() 13 | .GetMethod(nameof(IProxyGenerator.GenerateProxy), new[] { typeof(Type), typeof(IInterceptor) }); 14 | 15 | private readonly Type interceptorType; 16 | private readonly IProxyGenerator generator; 17 | 18 | public ProxyWithTypeInterceptorRegistration(Lifestyle lifestyle, Container container, Type implementationType, Type interceptorType, IProxyGenerator generator) 19 | : base(lifestyle, container, implementationType) 20 | { 21 | this.interceptorType = interceptorType; 22 | 23 | this.generator = generator; 24 | } 25 | 26 | public override Expression BuildExpression() 27 | { 28 | InstanceProducer producer = this.Container.GetRegistration(this.interceptorType, false); 29 | Expression interceptorSourse = (producer != null) ? producer.BuildExpression() : Expression.New(this.interceptorType); 30 | 31 | Expression generator = Expression.Constant(this.generator, typeof(IProxyGenerator)); 32 | Expression typeOfInstance = Expression.Constant(this.ImplementationType, typeof(Type)); 33 | Expression crateInstance = Expression.Call(generator, GenerateProxyMethod, typeOfInstance, interceptorSourse); 34 | 35 | return Expression.Convert(crateInstance, this.ImplementationType); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator.SimpleInjector/TypeHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | 4 | namespace MassiveDynamicProxyGenerator.SimpleInjector 5 | { 6 | internal class TypeHelper 7 | { 8 | public static bool IsOpenGeneric(Type type) 9 | { 10 | return type.GetTypeInfo().IsGenericTypeDefinition; 11 | } 12 | 13 | public static bool IsGenericConstructedOf(Type genericDefinitionType, Type constructedType) 14 | { 15 | if (!genericDefinitionType.GetTypeInfo().IsGenericType || !constructedType.GetTypeInfo().IsGenericType) 16 | { 17 | return false; 18 | } 19 | 20 | return constructedType.GetGenericTypeDefinition() == genericDefinitionType; 21 | } 22 | 23 | public static bool IsPublicInterface(Type type) 24 | { 25 | return type.GetTypeInfo().IsPublic && type.GetTypeInfo().IsInterface; 26 | } 27 | 28 | public static Type[] GetConstructorRequiredTypes(Type type) 29 | { 30 | ConstructorInfo[] constructors = type.GetTypeInfo().GetConstructors(BindingFlags.Public | BindingFlags.Instance); 31 | if (constructors.Length != 1) 32 | { 33 | throw new ArgumentException($"Type '{type.AssemblyQualifiedName}' must have only one public constructor."); 34 | } 35 | 36 | ParameterInfo[] parameters = constructors[0].GetParameters(); 37 | Type[] requiredTypes = new Type[parameters.Length]; 38 | for (int i = 0; i < requiredTypes.Length; i++) 39 | { 40 | requiredTypes[i] = parameters[i].ParameterType; 41 | } 42 | 43 | return requiredTypes; 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator/CallableInterceptorAsyncInvocation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | 6 | namespace MassiveDynamicProxyGenerator 7 | { 8 | internal class CallableInterceptorAsyncInvocation : ICallableInvocation 9 | { 10 | private readonly ICallableInvocation parent; 11 | private bool superssProcess; 12 | 13 | public object ReturnValue 14 | { 15 | get 16 | { 17 | return this.parent.ReturnValue; 18 | } 19 | 20 | set 21 | { 22 | this.superssProcess = true; 23 | this.parent.ReturnValue = value; 24 | } 25 | } 26 | 27 | public object[] Arguments 28 | { 29 | get 30 | { 31 | return this.parent.Arguments; 32 | } 33 | } 34 | 35 | public Type OriginalType 36 | { 37 | get 38 | { 39 | return this.parent.OriginalType; 40 | } 41 | } 42 | 43 | public string MethodName 44 | { 45 | get 46 | { 47 | return this.parent.MethodName; 48 | } 49 | } 50 | 51 | public Type[] ArgumentTypes 52 | { 53 | get 54 | { 55 | return this.parent.ArgumentTypes; 56 | } 57 | } 58 | 59 | public Type ReturnType 60 | { 61 | get 62 | { 63 | return this.parent.ReturnType; 64 | } 65 | } 66 | 67 | public CallableInterceptorAsyncInvocation(ICallableInvocation parent) 68 | { 69 | this.parent = parent; 70 | this.superssProcess = false; 71 | } 72 | 73 | public MethodBase GetConcreteMethod() 74 | { 75 | return this.parent.GetConcreteMethod(); 76 | } 77 | 78 | public void Process() 79 | { 80 | if (!this.superssProcess) 81 | { 82 | this.parent.Process(); 83 | } 84 | } 85 | } 86 | } -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator/DefaultInstances.cs: -------------------------------------------------------------------------------- 1 | using MassiveDynamicProxyGenerator.Utils; 2 | 3 | namespace MassiveDynamicProxyGenerator 4 | { 5 | /// 6 | /// Container for default instances. 7 | /// 8 | internal static class DefaultInstances 9 | { 10 | private static readonly object syncRoot = new object(); 11 | 12 | private static ITypeNameCreator typeNameCreator = null; 13 | private static GeneratedTypeList typedList = null; 14 | 15 | /// 16 | /// Gets the type name creator. 17 | /// 18 | /// 19 | /// The type name creator. 20 | /// 21 | public static ITypeNameCreator TypeNameCreator 22 | { 23 | get 24 | { 25 | if (typeNameCreator == null) 26 | { 27 | lock (syncRoot) 28 | { 29 | if (typeNameCreator == null) 30 | { 31 | typeNameCreator = new KoreanTypeNameCreator(); 32 | } 33 | } 34 | } 35 | 36 | return typeNameCreator; 37 | } 38 | } 39 | 40 | /// 41 | /// Gets the typed list - cache. 42 | /// 43 | /// 44 | /// The typed list. 45 | /// 46 | public static GeneratedTypeList TypedList 47 | { 48 | get 49 | { 50 | if (typedList == null) 51 | { 52 | lock (syncRoot) 53 | { 54 | if (typedList == null) 55 | { 56 | typedList = new GeneratedTypeList(); 57 | } 58 | } 59 | } 60 | 61 | return typedList; 62 | } 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator/Extensions/AssemblyBuilderExtensios.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection.Emit; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator 8 | { 9 | internal static class AssemblyBuilderExtensios 10 | { 11 | #if NETSTANDARD1_6 || NETSTANDARD2_0 12 | public static void Save(this AssemblyBuilder typeBuilder, string fileName) 13 | { 14 | throw new NotImplementedException(".Net Standard does not support save assembly."); 15 | } 16 | #endif 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator/Extensions/TypeBuilderExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Reflection.Emit; 6 | using System.Runtime.CompilerServices; 7 | using System.Threading.Tasks; 8 | 9 | namespace MassiveDynamicProxyGenerator 10 | { 11 | internal static class TypeBuilderExtensions 12 | { 13 | #if NETSTANDARD1_6 || NETSTANDARD2_0 14 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 15 | public static Type CreateType(this TypeBuilder typeBuilder) 16 | { 17 | TypeInfo typeInfo = typeBuilder.CreateTypeInfo(); 18 | return typeBuilder.AsType(); 19 | } 20 | #endif 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator/FullFrameworkExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace MassiveDynamicProxyGenerator 9 | { 10 | #if !(NETSTANDARD1_6 || NETSTANDARD1_4 || NETSTANDARD2_0) 11 | 12 | /// 13 | /// Extensions for adapt .Net Core API to full framework. 14 | /// 15 | internal static class FullFrameworkExtensions 16 | { 17 | /// 18 | /// Gets same type. 19 | /// 20 | /// The type. 21 | /// The same type. 22 | #if !NET40 23 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 24 | #endif 25 | public static Type GetTypeInfo(this Type type) 26 | { 27 | return type; 28 | } 29 | } 30 | 31 | #endif 32 | } 33 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator/ICallableInterceptor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator 8 | { 9 | /// 10 | /// Interface represents callable interceptor. 11 | /// 12 | public interface ICallableInterceptor 13 | { 14 | /// 15 | /// Intercepts the specified invocation. 16 | /// 17 | /// The invocation informations. 18 | void Intercept(ICallableInvocation invocation); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator/ICallableInvocation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator 8 | { 9 | /// 10 | /// Interface represented callable invocation informations. 11 | /// 12 | /// 13 | public interface ICallableInvocation : ICommonInvocation 14 | { 15 | /// 16 | /// Processes intercept method. 17 | /// 18 | void Process(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator/IInstanceProvicer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator 8 | { 9 | /// 10 | /// Interface represented instance provider. 11 | /// 12 | /// 13 | public interface IInstanceProvicer : IDisposable 14 | { 15 | /// 16 | /// Gets the instance of real class implementation. 17 | /// 18 | /// Instance of real class implementation. 19 | object GetInstance(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator/IInterceptor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator 8 | { 9 | /// 10 | /// Interface for interceptor. 11 | /// 12 | /// 13 | /// See http://simpleinjector.readthedocs.org/en/latest/advanced.html#interception 14 | /// 15 | public interface IInterceptor 16 | { 17 | /// 18 | /// Intercept call of method. 19 | /// 20 | /// Invocation informations. 21 | void Intercept(IInvocation invocation); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator/IInvocation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace MassiveDynamicProxyGenerator 9 | { 10 | /// 11 | /// Interface represented invocation information`s. 12 | /// 13 | /// 14 | public interface IInvocation : ICommonInvocation 15 | { 16 | /// 17 | /// Processes intercept method on . 18 | /// 19 | /// Instance of object when by call method. 20 | void Process(object instance); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator/ITypeNameCreator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator 8 | { 9 | /// 10 | /// Interface representes creator for name of type. 11 | /// 12 | public interface ITypeNameCreator 13 | { 14 | /// 15 | /// Creates the name of the type. 16 | /// 17 | /// A new name of the type. 18 | string CreateTypeName(); 19 | 20 | /// 21 | /// Creates the name of the type. 22 | /// 23 | /// The name prefix. 24 | /// The length of name. 25 | /// A new name of the type. 26 | string CreateTypeName(string prefix, int length); 27 | 28 | /// 29 | /// Creates the name of the method. 30 | /// 31 | /// A new name of the method. 32 | string CreateMethodName(); 33 | 34 | /// 35 | /// Creates the name of the method. 36 | /// 37 | /// The name prefix. 38 | /// The length of name. 39 | /// A new name of the method. 40 | string CreateMethodName(string prefix, int length); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator/NullInterceptor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator 8 | { 9 | #if NET40 10 | /// 11 | /// Null interceptor, returns default values. 12 | /// 13 | /// 14 | #else 15 | /// 16 | /// Null interceptor, returns default values. 17 | /// This interceptor is preferred in the .Net 4.0, in more framework vesions use . 18 | /// 19 | /// 20 | #endif 21 | public class NullInterceptor : IInterceptor 22 | { 23 | private static NullInterceptor instance; 24 | 25 | /// 26 | /// Gets the singlton instance. 27 | /// 28 | /// 29 | /// The singlton instance. 30 | /// 31 | public static NullInterceptor Instance 32 | { 33 | get 34 | { 35 | return instance; 36 | } 37 | } 38 | 39 | /// 40 | /// Initializes static members of the class. 41 | /// 42 | static NullInterceptor() 43 | { 44 | instance = new NullInterceptor(); 45 | } 46 | 47 | /// 48 | /// Initializes a new instance of the class. 49 | /// 50 | public NullInterceptor() 51 | { 52 | } 53 | 54 | /// 55 | /// Intercept call of method. Returns default value. 56 | /// 57 | /// Invocation informations. 58 | public void Intercept(IInvocation invocation) 59 | { 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator/ProxyGeneratorSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator 8 | { 9 | /// 10 | /// Optimal settings for . 11 | /// 12 | /// 13 | public class ProxyGeneratorSettings 14 | { 15 | /// 16 | /// Gets or sets a value indicating whether use local or global cache. 17 | /// 18 | /// 19 | /// true if use local cache; otherwise, false use global cache. 20 | /// 21 | public bool UseLocalCache 22 | { 23 | get; 24 | set; 25 | } 26 | 27 | /// 28 | /// Gets or sets the type name creator. 29 | /// 30 | /// 31 | /// The type name creator. 32 | /// 33 | public ITypeNameCreator TypeNameCreator 34 | { 35 | get; 36 | set; 37 | } 38 | 39 | /// 40 | /// Gets or sets the name of the created assembly. 41 | /// 42 | /// 43 | /// The name of the cerated assembly. 44 | /// 45 | public string AssemblyName 46 | { 47 | get; 48 | set; 49 | } 50 | 51 | /// 52 | /// Initializes a new instance of the class. 53 | /// 54 | public ProxyGeneratorSettings() 55 | { 56 | this.UseLocalCache = false; 57 | this.TypeNameCreator = null; 58 | this.AssemblyName = null; 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator/TypedDecorator/CallableInterceptorDescriptor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace MassiveDynamicProxyGenerator.TypedDecorator 9 | { 10 | /// 11 | /// Internal interceptor descriptor. 12 | /// 13 | internal class CallableInterceptorDescriptor 14 | { 15 | /// 16 | /// Gets or sets the type. 17 | /// 18 | /// 19 | /// The type. 20 | /// 21 | public Type Type 22 | { 23 | get; 24 | protected set; 25 | } 26 | 27 | /// 28 | /// Gets or sets the intercept. 29 | /// 30 | /// 31 | /// The intercept. 32 | /// 33 | public MethodInfo Intercept 34 | { 35 | get; 36 | protected set; 37 | } 38 | 39 | /// 40 | /// Initializes a new instance of the class. 41 | /// 42 | public CallableInterceptorDescriptor() 43 | { 44 | this.Type = typeof(ICallableInterceptor); 45 | this.Intercept = this.Type.GetTypeInfo().GetMethod(nameof(ICallableInterceptor.Intercept), new Type[] { typeof(ICallableInvocation) }); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator/TypedDecorator/GenerateUnion.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace MassiveDynamicProxyGenerator.TypedDecorator 9 | { 10 | /// 11 | /// Internal generate union. 12 | /// 13 | internal class GenerateUnion 14 | { 15 | /// 16 | /// Gets the process method. 17 | /// 18 | /// 19 | /// The process method. 20 | /// 21 | public MethodInfo ProcessMethod 22 | { 23 | get; 24 | private set; 25 | } 26 | 27 | /// 28 | /// Initializes a new instance of the class. 29 | /// 30 | /// The method information. 31 | /// methodInfo 32 | public GenerateUnion(MethodInfo methodInfo) 33 | { 34 | #if DEBUG 35 | if (methodInfo == null) 36 | { 37 | throw new ArgumentNullException(nameof(methodInfo)); 38 | } 39 | #endif 40 | 41 | this.ProcessMethod = methodInfo; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator/TypedInstanceProxy/InstanceProvicerDescriptor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace MassiveDynamicProxyGenerator.TypedInstanceProxy 9 | { 10 | /// 11 | /// Instance provider descriptor. 12 | /// 13 | /// 14 | internal class InstanceProvicerDescriptor 15 | { 16 | /// 17 | /// Gets or sets the type. 18 | /// 19 | /// 20 | /// The type. 21 | /// 22 | public Type Type 23 | { 24 | get; 25 | protected set; 26 | } 27 | 28 | /// 29 | /// Gets or sets the dispose. 30 | /// 31 | /// 32 | /// The dispose. 33 | /// 34 | public MethodInfo Dispose 35 | { 36 | get; 37 | protected set; 38 | } 39 | 40 | /// 41 | /// Gets or sets the get instance. 42 | /// 43 | /// 44 | /// The get instance. 45 | /// 46 | public MethodInfo GetInstance 47 | { 48 | get; 49 | protected set; 50 | } 51 | 52 | /// 53 | /// Initializes a new instance of the class. 54 | /// 55 | public InstanceProvicerDescriptor() 56 | { 57 | this.Type = typeof(IInstanceProvicer); 58 | this.Dispose = this.Type.GetTypeInfo().GetMethod(nameof(IInstanceProvicer.Dispose), Type.EmptyTypes); 59 | this.GetInstance = this.Type.GetTypeInfo().GetMethod(nameof(IInstanceProvicer.GetInstance), Type.EmptyTypes); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator/TypedInstanceProxy/SimpleInstanceProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.TypedInstanceProxy 8 | { 9 | /// 10 | /// Class represented simple instance provided, avails returns one instance. 11 | /// 12 | /// Type of instance. 13 | /// 14 | public class SimpleInstanceProvider : IInstanceProvicer 15 | where T : class 16 | { 17 | private readonly T instance; 18 | 19 | /// 20 | /// Initializes a new instance of the class. 21 | /// 22 | /// The instance. 23 | /// instance 24 | public SimpleInstanceProvider(T instance) 25 | { 26 | if (instance == null) 27 | { 28 | throw new ArgumentNullException(nameof(instance)); 29 | } 30 | 31 | this.instance = instance; 32 | } 33 | 34 | /// 35 | /// Gets the instance of real class implementation. 36 | /// 37 | /// 38 | /// Instance of real class implementation. 39 | /// 40 | public object GetInstance() 41 | { 42 | return this.instance; 43 | } 44 | 45 | /// 46 | /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. 47 | /// 48 | public void Dispose() 49 | { 50 | this.Dispose(true); 51 | } 52 | 53 | /// 54 | /// Releases unmanaged and - optionally - managed resources. 55 | /// 56 | /// true to release both managed and unmanaged resources; false to release only unmanaged resources. 57 | protected virtual void Dispose(bool disposing) 58 | { 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator/TypedProxy/TypedProxyContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection.Emit; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace MassiveDynamicProxyGenerator.TypedProxy 9 | { 10 | internal class TypedProxyContext 11 | { 12 | public MethodBuilder ParentMethodCall 13 | { 14 | get; 15 | protected set; 16 | } 17 | 18 | public TypedProxyContext(MethodBuilder builder) 19 | { 20 | #if DEBUG 21 | if (builder == null) 22 | { 23 | throw new ArgumentNullException(nameof(builder)); 24 | } 25 | #endif 26 | 27 | this.ParentMethodCall = builder; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator/Utils/ITypeRquest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.Utils 8 | { 9 | /// 10 | /// Instance represented type request for cache. 11 | /// 12 | internal interface ITypeRquest 13 | { 14 | /// 15 | /// Gets the type of the decorator. 16 | /// 17 | /// 18 | /// The type of the decorator. 19 | /// 20 | TypedDecoratorType DecoratorType 21 | { 22 | get; 23 | } 24 | 25 | /// 26 | /// Gets the interface types. 27 | /// 28 | /// 29 | /// The interface types. 30 | /// 31 | Type[] InterfaceTypes 32 | { 33 | get; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator/Utils/RusianAplhabet.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.Utils 8 | { 9 | /// 10 | /// Class represented rusian alphabet. 11 | /// 12 | internal static class RusianAplhabet 13 | { 14 | private static char[] alphabet; 15 | 16 | static RusianAplhabet() 17 | { 18 | string sourse = "АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ"; 19 | alphabet = sourse.ToCharArray(); 20 | } 21 | 22 | /// 23 | /// Generates the string. 24 | /// 25 | /// The number representation. 26 | /// String representation of number. 27 | public static string GenerateString(int numberRepresentation) 28 | { 29 | int z = alphabet.Length; 30 | 31 | if (numberRepresentation == 0) 32 | { 33 | return new string(alphabet[0], 1); 34 | } 35 | 36 | List characters = new List(); 37 | 38 | int number = numberRepresentation; 39 | if (numberRepresentation < 0) 40 | { 41 | characters.Add('ㅡ'); 42 | } 43 | 44 | while (number > 0) 45 | { 46 | char newChar = alphabet[number % z]; 47 | number = number / z; 48 | characters.Add(newChar); 49 | } 50 | 51 | characters.Reverse(); 52 | 53 | return new string(characters.ToArray()); 54 | } 55 | 56 | /// 57 | /// Generates the random. 58 | /// 59 | /// The random source. 60 | /// The length. 61 | /// String representation of number. 62 | public static string GenerateRandom(Random randomSource, int length) 63 | { 64 | char[] array = new char[length]; 65 | for (int i = 0; i < length; i++) 66 | { 67 | int index = randomSource.Next(0, alphabet.Length); 68 | array[i] = alphabet[index]; 69 | } 70 | 71 | return new string(array); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator/Utils/SettingsUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Linq.Expressions; 7 | 8 | namespace MassiveDynamicProxyGenerator.Utils 9 | { 10 | /// 11 | /// Settings utils. 12 | /// 13 | internal static class SettingsUtils 14 | { 15 | /// 16 | /// Applies the specified action to settings instance. 17 | /// 18 | /// Type of settings. 19 | /// The action. 20 | /// The settings. 21 | public static T Apply(Action action) 22 | where T : new() 23 | { 24 | T instance = Expression.Lambda>(Expression.New(typeof(T))).Compile().Invoke(); 25 | action.Invoke(instance); 26 | 27 | return instance; 28 | } 29 | 30 | /// 31 | /// Applies the specified action to settings instance. 32 | /// 33 | /// Type of settings. 34 | /// The action. 35 | /// The default instance. 36 | /// 37 | /// The settings. 38 | /// 39 | public static T Apply(Action action, T instance) 40 | { 41 | action.Invoke(instance); 42 | 43 | return instance; 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Src/MassiveDynamicProxyGenerator/Utils/TypedDecoratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.Utils 8 | { 9 | /// 10 | /// Decorator type. 11 | /// 12 | internal enum TypedDecoratorType : int 13 | { 14 | /// 15 | /// The typed proxy. 16 | /// 17 | TypedProxy = 1, 18 | 19 | /// 20 | /// The typed proxy with parameters. 21 | /// 22 | TypedProxyWithParameters = 2, 23 | 24 | /// 25 | /// The typed instanced proxy. 26 | /// 27 | TypedInstancedProxy = 3, 28 | 29 | /// 30 | /// The typed decorator. 31 | /// 32 | TypedDecorator = 4 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.DependencyInjection.Test/MassiveDynamicProxyGenerator.DependencyInjection.Test.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp3.1 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | all 19 | runtime; build; native; contentfiles; analyzers; buildtransitive 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.DependencyInjection.Test/Services/GenericService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.DependencyInjection.Test.Services 8 | { 9 | public class GenericService : IGenericService 10 | { 11 | private T last; 12 | 13 | public GenericService() 14 | { 15 | this.last = default(T); 16 | } 17 | 18 | public T GetLast() 19 | { 20 | return this.last; 21 | } 22 | 23 | public T Transform(T item) 24 | { 25 | this.last = item; 26 | return item; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.DependencyInjection.Test/Services/IGenericService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace MassiveDynamicProxyGenerator.DependencyInjection.Test.Services 6 | { 7 | public interface IGenericService 8 | { 9 | T Transform(T item); 10 | 11 | T GetLast(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.DependencyInjection.Test/Services/IMessageService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.DependencyInjection.Test.Services 8 | { 9 | public interface IMessageService 10 | { 11 | void Send(string email, string body); 12 | 13 | void TestMethod(); 14 | 15 | int GetCountOfMessagesInFront(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.DependencyInjection.Test/Services/ITestMessager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.DependencyInjection.Test.Services 8 | { 9 | public interface ITestMessager 10 | { 11 | void Send(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.DependencyInjection.Test/Services/ITypeA.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.DependencyInjection.Test.Services 8 | { 9 | public interface ITypeA 10 | { 11 | void FooForA(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.DependencyInjection.Test/Services/ITypeB.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.DependencyInjection.Test.Services 8 | { 9 | public interface ITypeB 10 | { 11 | void FooForB(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.DependencyInjection.Test/Services/ITypeC.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.DependencyInjection.Test.Services 8 | { 9 | public interface ITypeC 10 | { 11 | void FooForC(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.DependencyInjection.Test/Services/IntGenericService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.DependencyInjection.Test.Services 8 | { 9 | public class IntGenericService : IGenericService 10 | { 11 | public IntGenericService() 12 | { 13 | 14 | } 15 | 16 | public int GetLast() 17 | { 18 | throw new NotImplementedException(); 19 | } 20 | 21 | public int Transform(int item) 22 | { 23 | throw new NotImplementedException(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.DependencyInjection.Test/Services/MessageService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace MassiveDynamicProxyGenerator.DependencyInjection.Test.Services 6 | { 7 | public class MessageService : IMessageService 8 | { 9 | public MessageService() 10 | { 11 | 12 | } 13 | 14 | public int GetCountOfMessagesInFront() 15 | { 16 | return 14; 17 | } 18 | 19 | public void Send(string email, string body) 20 | { 21 | 22 | } 23 | 24 | public void TestMethod() 25 | { 26 | 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.DependencyInjection.Test/Services/StringGenericService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.DependencyInjection.Test.Services 8 | { 9 | public class StringGenericService : IGenericService 10 | { 11 | public StringGenericService() 12 | { 13 | 14 | } 15 | 16 | public string GetLast() 17 | { 18 | throw new NotImplementedException(); 19 | } 20 | 21 | public string Transform(string item) 22 | { 23 | throw new NotImplementedException(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.DependencyInjection.Test/Services/TestMessager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.DependencyInjection.Test.Services 8 | { 9 | public class TestMessager : ITestMessager 10 | { 11 | public TestMessager(IGenericService strg, IGenericService igst, IMessageService messages) 12 | { 13 | 14 | } 15 | public void Send() 16 | { 17 | throw new NotImplementedException(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.DependencyInjection.Test/Services/TypeA.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.DependencyInjection.Test.Services 8 | { 9 | public class TypeA : ITypeA 10 | { 11 | public void FooForA() 12 | { 13 | throw new NotImplementedException(); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.DependencyInjection.Test/Services/TypeADependInterceptor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace MassiveDynamicProxyGenerator.DependencyInjection.Test.Services 6 | { 7 | public class TypeADependInterceptor : IInterceptor 8 | { 9 | private readonly ITypeA typeA; 10 | 11 | public TypeADependInterceptor(ITypeA typeA) 12 | { 13 | this.typeA = typeA; 14 | } 15 | 16 | public void Intercept(IInvocation invocation) 17 | { 18 | 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.DependencyInjection.Test/Services/TypeB.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.DependencyInjection.Test.Services 8 | { 9 | public class TypeB : ITypeB 10 | { 11 | public void FooForB() 12 | { 13 | throw new NotImplementedException(); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.DependencyInjection.Test/Services/TypeC.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.DependencyInjection.Test.Services 8 | { 9 | public class TypeC : ITypeC 10 | { 11 | public void FooForC() 12 | { 13 | throw new NotImplementedException(); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.SimpleInjector.Tests.NetCore/MassiveDynamicProxyGenerator.SimpleInjector.Tests.NetCore.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | all 27 | runtime; build; native; contentfiles; analyzers; buildtransitive 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.SimpleInjector.Tests/DangerousMockTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Shouldly; 3 | using SimpleInjector; 4 | using Microsoft.VisualStudio.TestTools.UnitTesting; 5 | using MassiveDynamicProxyGenerator.SimpleInjector.Tests.Services; 6 | using MassiveDynamicProxyGenerator.SimpleInjector.Dangerous; 7 | 8 | namespace MassiveDynamicProxyGenerator.SimpleInjector.Tests 9 | { 10 | [TestClass] 11 | public class DangerousMockTests 12 | { 13 | [TestMethod] 14 | public void MockAllUnregistred_GetTypes_Sucess() 15 | { 16 | Container container = new Container(); 17 | container.Register(); 18 | container.Register(); 19 | container.RegisterAllUnregisteredAsMock(); 20 | 21 | container.Verify(); 22 | 23 | container.GetInstance>() 24 | .ShouldNotBeNull(); 25 | 26 | container.GetInstance() 27 | .ShouldNotBeNull(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.SimpleInjector.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | [assembly: AssemblyTitle("MassiveDynamicProxyGenerator.SimpleInjector.Tests")] 6 | [assembly: AssemblyDescription("")] 7 | [assembly: AssemblyConfiguration("")] 8 | [assembly: AssemblyCompany("")] 9 | [assembly: AssemblyProduct("MassiveDynamicProxyGenerator.SimpleInjector.Tests")] 10 | [assembly: AssemblyCopyright("Copyright © 2017")] 11 | [assembly: AssemblyTrademark("")] 12 | [assembly: AssemblyCulture("")] 13 | 14 | [assembly: ComVisible(false)] 15 | 16 | [assembly: Guid("6c1991b8-f14b-4563-a088-602ce91527e2")] 17 | 18 | // [assembly: AssemblyVersion("1.0.*")] 19 | [assembly: AssemblyVersion("1.0.0.0")] 20 | [assembly: AssemblyFileVersion("1.0.0.0")] 21 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.SimpleInjector.Tests/ProxyGeneratorFactoryTests.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Shouldly; 8 | 9 | namespace MassiveDynamicProxyGenerator.SimpleInjector.Tests 10 | { 11 | [TestClass] 12 | public class ProxyGeneratorFactoryTests 13 | { 14 | [TestMethod] 15 | public void ProxyGeneratorFactory_Init() 16 | { 17 | ProxyGeneratorFactory.Factory.ShouldNotBeNull(); 18 | } 19 | 20 | [TestMethod] 21 | public void ProxyGeneratorFactory_GetInstance() 22 | { 23 | ProxyGeneratorFactory.Factory.GetInstance().ShouldNotBeNull(); 24 | } 25 | 26 | [TestMethod] 27 | public void ProxyGeneratorFactory_OverrideFactory() 28 | { 29 | ProxyGenerator generator = new ProxyGenerator(); 30 | 31 | ProxyGeneratorFactory.Factory.GetInstance().ShouldNotBeSameAs(generator); 32 | 33 | ProxyGeneratorFactory.OverrideFactory(new TestGeneratorFactory(generator)); 34 | 35 | ProxyGeneratorFactory.Factory.GetInstance().ShouldBeSameAs(generator); 36 | } 37 | 38 | private class TestGeneratorFactory : IProxyGeneratorFactory 39 | { 40 | private readonly IProxyGenerator generator; 41 | 42 | public TestGeneratorFactory(IProxyGenerator generator) 43 | { 44 | this.generator = generator; 45 | } 46 | 47 | public IProxyGenerator GetInstance() 48 | { 49 | return this.generator; 50 | } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.SimpleInjector.Tests/Services/GenericInstanceProducer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.SimpleInjector.Tests.Services 8 | { 9 | public class GenericInstanceProducer : IInstanceProvicer 10 | { 11 | public GenericInstanceProducer() 12 | { 13 | 14 | } 15 | 16 | public void Dispose() 17 | { 18 | } 19 | 20 | public object GetInstance() 21 | { 22 | return new GenericService(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.SimpleInjector.Tests/Services/GenericService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.SimpleInjector.Tests.Services 8 | { 9 | public class GenericService : IGenericService 10 | { 11 | private T last; 12 | 13 | public GenericService() 14 | { 15 | this.last = default(T); 16 | } 17 | 18 | public T GetLast() 19 | { 20 | return this.last; 21 | } 22 | 23 | public T Transform(T item) 24 | { 25 | this.last = item; 26 | return item; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.SimpleInjector.Tests/Services/IGenericService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.SimpleInjector.Tests.Services 8 | { 9 | public interface IGenericService 10 | { 11 | T Transform(T item); 12 | 13 | T GetLast(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.SimpleInjector.Tests/Services/IMessageService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.SimpleInjector.Tests.Services 8 | { 9 | public interface IMessageService 10 | { 11 | void Send(string email, string body); 12 | 13 | void TestMethod(); 14 | 15 | int GetCountOfMessagesInFront(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.SimpleInjector.Tests/Services/ITestMessager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.SimpleInjector.Tests.Services 8 | { 9 | public interface ITestMessager 10 | { 11 | void Send(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.SimpleInjector.Tests/Services/ITypeA.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.SimpleInjector.Tests.Services 8 | { 9 | public interface ITypeA 10 | { 11 | void FooForA(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.SimpleInjector.Tests/Services/ITypeB.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.SimpleInjector.Tests.Services 8 | { 9 | public interface ITypeB 10 | { 11 | void FooForB(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.SimpleInjector.Tests/Services/ITypeC.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.SimpleInjector.Tests.Services 8 | { 9 | public interface ITypeC 10 | { 11 | void FooForC(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.SimpleInjector.Tests/Services/IntGenericService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.SimpleInjector.Tests.Services 8 | { 9 | public class IntGenericService : IGenericService 10 | { 11 | public IntGenericService() 12 | { 13 | 14 | } 15 | 16 | public int GetLast() 17 | { 18 | throw new NotImplementedException(); 19 | } 20 | 21 | public int Transform(int item) 22 | { 23 | throw new NotImplementedException(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.SimpleInjector.Tests/Services/MessageDependentIInstanceProvicer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Shouldly; 7 | 8 | namespace MassiveDynamicProxyGenerator.SimpleInjector.Tests.Services 9 | { 10 | public class MessageDependentIInstanceProvicer : IInstanceProvicer 11 | { 12 | private readonly ITypeA typeA; 13 | private readonly ITypeB typeB; 14 | 15 | public MessageDependentIInstanceProvicer(ITypeA typeA, ITypeB typeB) 16 | { 17 | typeA.ShouldNotBeNull(); 18 | typeB.ShouldNotBeNull(); 19 | 20 | this.typeA = typeA; 21 | this.typeB = typeB; 22 | } 23 | 24 | public void Dispose() 25 | { 26 | } 27 | 28 | public object GetInstance() 29 | { 30 | this.typeA.GetType().ShouldNotBeNull(); 31 | this.typeB.GetType().ShouldNotBeNull(); 32 | 33 | return new MessageService(); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.SimpleInjector.Tests/Services/MessageService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.SimpleInjector.Tests.Services 8 | { 9 | public class MessageService : IMessageService 10 | { 11 | public MessageService() 12 | { 13 | 14 | } 15 | 16 | public int GetCountOfMessagesInFront() 17 | { 18 | return 12; 19 | } 20 | 21 | public void Send(string email, string body) 22 | { 23 | 24 | } 25 | 26 | public void TestMethod() 27 | { 28 | 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.SimpleInjector.Tests/Services/MessageServiceInstanceProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.SimpleInjector.Tests.Services 8 | { 9 | public class MessageServiceInstanceProvider : IInstanceProvicer 10 | { 11 | public MessageServiceInstanceProvider() 12 | { 13 | 14 | } 15 | 16 | public void Dispose() 17 | { 18 | } 19 | 20 | public object GetInstance() 21 | { 22 | return new MessageService(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.SimpleInjector.Tests/Services/StringGenericService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.SimpleInjector.Tests.Services 8 | { 9 | public class StringGenericService : IGenericService 10 | { 11 | public StringGenericService() 12 | { 13 | 14 | } 15 | 16 | public string GetLast() 17 | { 18 | throw new NotImplementedException(); 19 | } 20 | 21 | public string Transform(string item) 22 | { 23 | throw new NotImplementedException(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.SimpleInjector.Tests/Services/TestMessager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.SimpleInjector.Tests.Services 8 | { 9 | public class TestMessager : ITestMessager 10 | { 11 | public TestMessager(IGenericService strg, IGenericService igst, IMessageService messages) 12 | { 13 | 14 | } 15 | public void Send() 16 | { 17 | throw new NotImplementedException(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.SimpleInjector.Tests/Services/TypeA.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.SimpleInjector.Tests.Services 8 | { 9 | public class TypeA : ITypeA 10 | { 11 | public void FooForA() 12 | { 13 | throw new NotImplementedException(); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.SimpleInjector.Tests/Services/TypeB.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.SimpleInjector.Tests.Services 8 | { 9 | public class TypeB : ITypeB 10 | { 11 | public void FooForB() 12 | { 13 | throw new NotImplementedException(); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.SimpleInjector.Tests/Services/TypeC.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.SimpleInjector.Tests.Services 8 | { 9 | public class TypeC : ITypeC 10 | { 11 | public void FooForC() 12 | { 13 | throw new NotImplementedException(); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.SimpleInjector.Tests/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.Tests.NetStandard/MassiveDynamicProxyGenerator.Tests.NetStandard.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | all 24 | runtime; build; native; contentfiles; analyzers; buildtransitive 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.Tests/DynamicObjectProxyTests.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Moq; 8 | using Shouldly; 9 | 10 | namespace MassiveDynamicProxyGenerator.Tests 11 | { 12 | [TestClass] 13 | public class DynamicObjectProxyTests 14 | { 15 | //[TestMethod] 16 | //public void GenerateDynamicObjectProxy_CallVoidMethod_Call() 17 | //{ 18 | // Mock interceptorMoq = new Mock(MockBehavior.Strict); 19 | // interceptorMoq.Setup(t => t.Intercept(It.IsNotNull(), true)) 20 | // .Callback((invocation, isDynamic) => 21 | // { 22 | // invocation.MethodName.ShouldBe("AnyCall"); 23 | // invocation.ReturnType.ShouldBe(typeof(object)); 24 | // invocation.Arguments.ShouldBeEmpty(); 25 | // }); 26 | 27 | // ProxygGenerator generator = new ProxygGenerator(); 28 | // dynamic proxy = generator.GenerateDynamicObjectProxy(interceptorMoq.Object); 29 | 30 | // int a = proxy.AnyCall(); 31 | 32 | // interceptorMoq.VerifyAll(); 33 | //} 34 | 35 | //[TestMethod] 36 | //public void GenerateDynamicObjectProxy_CallReturnMethod_Call() 37 | //{ 38 | // throw new NotImplementedException(); 39 | //} 40 | 41 | //[TestMethod] 42 | //public void GenerateDynamicObjectProxy_CallParameterMethod_Call() 43 | //{ 44 | // throw new NotImplementedException(); 45 | //} 46 | 47 | //[TestMethod] 48 | //public void GenerateDynamicObjectProxy_PropertyGet_Call() 49 | //{ 50 | // throw new NotImplementedException(); 51 | //} 52 | 53 | //[TestMethod] 54 | //public void GenerateDynamicObjectProxy_PropertySet_Call() 55 | //{ 56 | // throw new NotImplementedException(); 57 | //} 58 | 59 | //[TestMethod] 60 | //public void GenerateDynamicObjectProxy_CallMethod_ThrowException() 61 | //{ 62 | // throw new NotImplementedException(); 63 | //} 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.Tests/Examples/Caller.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.Tests.Examples 8 | { 9 | class Caller 10 | { 11 | public Caller(Action action) 12 | { 13 | 14 | } 15 | 16 | public void Call() 17 | { 18 | 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.Tests/Examples/InvocationExample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace MassiveDynamicProxyGenerator.Tests.Examples 9 | { 10 | class InvocationExample : IInvocation 11 | { 12 | public object[] Arguments 13 | { 14 | get; 15 | set; 16 | } 17 | 18 | public Type[] ArgumentTypes 19 | { 20 | get 21 | { 22 | throw new NotImplementedException(); 23 | } 24 | set 25 | { 26 | throw new NotImplementedException(); 27 | } 28 | } 29 | 30 | public string MethodName 31 | { 32 | get; 33 | set; 34 | } 35 | 36 | public Type OriginalType 37 | { 38 | get; 39 | set; 40 | } 41 | 42 | public Type ReturnType 43 | { 44 | get; 45 | set; 46 | } 47 | 48 | public object ReturnValue 49 | { 50 | get; 51 | set; 52 | } 53 | 54 | public MethodBase GetConcreteMethod() 55 | { 56 | throw new NotImplementedException(); 57 | } 58 | 59 | public void Process(object instance) 60 | { 61 | throw new NotImplementedException(); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.Tests/NullInterceptorTests.cs: -------------------------------------------------------------------------------- 1 | using MassiveDynamicProxyGenerator.Tests.TestInterfaces; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | using Shouldly; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace MassiveDynamicProxyGenerator.Tests 11 | { 12 | [TestClass] 13 | public class NullInterceptorTests 14 | { 15 | [TestMethod] 16 | public void NUllAsyncInterceptor_NoTask_ReturnDefault() 17 | { 18 | ProxyGenerator generator = new ProxyGenerator(); 19 | IReturnTypes instance = generator.GenerateProxy(new NullInterceptor()); 20 | 21 | instance.ShouldNotBeNull(); 22 | 23 | instance.CreateSb(string.Empty).ShouldBe(default(StringBuilder)); 24 | instance.GetLength(string.Empty).ShouldBe(default(int)); 25 | instance.GetVoid(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("MassiveDynamicProxyGenerator.Tests")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("MassiveDynamicProxyGenerator.Tests")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("2f31b717-f2b5-46f5-9752-b1c584c661ab")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.Tests/TestExtensions/TypeAssertExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace Shouldly 9 | { 10 | public static class TypeAssertExtensions 11 | { 12 | public static void ShouldBySameTypeAs(this object instance, T their) 13 | { 14 | if (instance == null && their == null) 15 | { 16 | return; 17 | } 18 | 19 | if (instance == null) 20 | { 21 | Assert.Fail("Instance is null."); 22 | } 23 | 24 | if (their == null) 25 | { 26 | Assert.Fail("Their is null."); 27 | } 28 | 29 | if (instance.GetType() != their.GetType()) 30 | { 31 | Assert.Fail($"Instance type '{instance.GetType().FullName}' is not equal type of their '{their.GetType().FullName}'"); 32 | } 33 | } 34 | 35 | public static void ShouldNotBySameTypeAs(this object instance, T their) 36 | { 37 | if (instance == null && their == null) 38 | { 39 | Assert.Fail("Instance and theri is both null."); 40 | } 41 | 42 | if (instance == null || their == null) 43 | { 44 | return; 45 | } 46 | 47 | if (instance.GetType() == their.GetType()) 48 | { 49 | Assert.Fail($"Instance and their is same type '{instance.GetType().FullName}'."); 50 | } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.Tests/TestInterfaces/CallableInterceptorAsyncImpl.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.Tests.TestInterfaces 8 | { 9 | public class CallableInterceptorAsyncImpl : CallableInterceptorAsyncAdapter 10 | { 11 | private readonly IMethodWraper wraper; 12 | 13 | public CallableInterceptorAsyncImpl(IMethodWraper wraper) 14 | :base() 15 | { 16 | if (wraper == null) throw new ArgumentNullException(nameof(wraper)); 17 | 18 | this.wraper = wraper; 19 | } 20 | 21 | protected override bool HandleException(ICallableInvocation invocation, Exception ex, object invocationData) 22 | { 23 | return this.wraper.HandleException(invocation, ex, invocationData); 24 | } 25 | 26 | protected override object OnEnterInvoke(ICallableInvocation invocation) 27 | { 28 | return this.wraper.OnEnterInvoke(invocation); 29 | } 30 | 31 | protected override void OnExitInvoke(ICallableInvocation invocation, object invocationData) 32 | { 33 | this.wraper.OnExitInvoke(invocation, invocationData); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.Tests/TestInterfaces/IAsyncInterface.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.Tests.TestInterfaces 8 | { 9 | public interface IAsyncInterface 10 | { 11 | Task WriteContextAsync(IGrapth graph); 12 | 13 | void WriteContext(IGrapth graph); 14 | 15 | Task GetCountAsync(); 16 | 17 | int GetCount(); 18 | 19 | IGrapth ReadContext(); 20 | 21 | Task ReadContextAsync(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.Tests/TestInterfaces/ICompositeInterface.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.Tests.TestInterfaces 8 | { 9 | public interface ICompositeInterface : IGrapth, IDisposable, IFormattable 10 | { 11 | void AddChild(ICompositeInterface item); 12 | 13 | void Show(double x, double y, double width, double height); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.Tests/TestInterfaces/IGenericInterface.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.Tests.TestInterfaces 8 | { 9 | public interface IGenericInterface 10 | { 11 | T Value 12 | { 13 | get; 14 | set; 15 | } 16 | 17 | void PushNew(string name, T value); 18 | 19 | T Get(string name); 20 | 21 | T[] GetAll(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.Tests/TestInterfaces/IGrapth.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.Tests.TestInterfaces 8 | { 9 | public interface IGrapth 10 | { 11 | Guid Id 12 | { 13 | get; 14 | } 15 | 16 | string Name 17 | { 18 | get; 19 | } 20 | 21 | string DisplayName 22 | { 23 | get; 24 | set; 25 | } 26 | 27 | double[,] CacluateTable(DateTime from, DateTime to); 28 | 29 | IGrapth Combine(IGrapth other); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.Tests/TestInterfaces/IInterfaceWithDefaultMethod.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.Tests.TestInterfaces 8 | { 9 | public interface IInterfaceWithDefaultMethod 10 | { 11 | int GetAize(); 12 | 13 | #if NETSTANDARD || NETCOREAPP 14 | int GetSquare() 15 | { 16 | int size = this.GetSquare(); 17 | return size * size; 18 | } 19 | #endif 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.Tests/TestInterfaces/IMethodWraper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.Tests.TestInterfaces 8 | { 9 | public interface IMethodWraper 10 | { 11 | bool HandleException(ICallableInvocation invocation, Exception ex, object invocationData); 12 | 13 | object OnEnterInvoke(ICallableInvocation invocation); 14 | 15 | void OnExitInvoke(ICallableInvocation invocation, object invocationData); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.Tests/TestInterfaces/INonReturn.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.Tests.TestInterfaces 8 | { 9 | public interface INonReturn 10 | { 11 | void EmptyMethod(); 12 | 13 | void OneArgument(int a); 14 | 15 | void OneArgument(string a); 16 | 17 | void OneArgument(StringBuilder a); 18 | 19 | void TwoArguments(int a, StringBuilder sb); 20 | 21 | void MoreArguments(string a, Exception parentEx, StringBuilder builder, Func transformation); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.Tests/TestInterfaces/IPrototype.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.Tests.TestInterfaces 8 | { 9 | public interface IPrototype 10 | { 11 | IPrototype Clone(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.Tests/TestInterfaces/IReturnTypes.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MassiveDynamicProxyGenerator.Tests.TestInterfaces 8 | { 9 | public struct MyStruct 10 | { 11 | public int Address; 12 | public long UsLong; 13 | public char Asci; 14 | public string PointAbc; 15 | public IntPtr Pointer; 16 | 17 | public static MyStruct InitializeDefault() 18 | { 19 | MyStruct s = new MyStruct(); 20 | s.Address = 158; 21 | s.Asci = 'h'; 22 | s.PointAbc = "male janiatko"; 23 | s.Pointer = IntPtr.Zero; 24 | s.UsLong = 458562544L; 25 | 26 | return s; 27 | } 28 | } 29 | 30 | public interface IReturnTypes 31 | { 32 | StringBuilder CreateSb(string arg); 33 | 34 | int GetLength(string arg); 35 | 36 | void GetVoid(); 37 | 38 | MyStruct GetStruct(); 39 | 40 | int PulseEx(int a, string message, Exception ex); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.Tests/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/Test/MassiveDynamicProxyGenerator.Tests/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/Version.proj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1.7.1 5 | 0 6 | $([System.DateTime]::Now.Year.ToString()) 7 | 8 | 9 | 10 | Copyright © 2016-$(NowYear) harrison314 11 | $(LocalBuildVersion) 12 | harrison314 13 | harrison314 14 | 15 | $(LocalBuildVersion).$(LocalBuildRevision) 16 | $(LocalBuildVersion).$(LocalBuildRevision) 17 | $(LocalBuildVersion).$(LocalBuildRevision) 18 | https://github.com/harrison314/MassiveDynamicProxyGenerator 19 | https://github.com/harrison314/MassiveDynamicProxyGenerator 20 | git 21 | MIT 22 | 23 | -------------------------------------------------------------------------------- /src/img/NugetIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harrison314/MassiveDynamicProxyGenerator/eed714dd848f6885293333188463f8a737d90685/src/img/NugetIcon.png --------------------------------------------------------------------------------