MassiveDynamicProxyGenerator 1.3.0-preview1
See the version list below for details.
dotnet add package MassiveDynamicProxyGenerator --version 1.3.0-preview1
NuGet\Install-Package MassiveDynamicProxyGenerator -Version 1.3.0-preview1
<PackageReference Include="MassiveDynamicProxyGenerator" Version="1.3.0-preview1" />
paket add MassiveDynamicProxyGenerator --version 1.3.0-preview1
#r "nuget: MassiveDynamicProxyGenerator, 1.3.0-preview1"
// Install MassiveDynamicProxyGenerator as a Cake Addin #addin nuget:?package=MassiveDynamicProxyGenerator&version=1.3.0-preview1&prerelease // Install MassiveDynamicProxyGenerator as a Cake Tool #tool nuget:?package=MassiveDynamicProxyGenerator&version=1.3.0-preview1&prerelease
MassiveDynamicProxyGenerator
.Net library for generate proxy class instances
Massive Dynamic Proxy Generator is a library for generating lightweight .NET proxies on the fly at runtime. Proxy objects allow calls to members of an object to be intercepted without modifying the code of the class. Both classes and interfaces can be proxied, however only virtual members can be intercepted.
Fertures:
- Proxy instance generator, for intercept.
- Decorator generator.
- Proxy instance generator, for control instancing real implementation (e.g. lazy loading).
The following platforms are supported:
- .Net 4.0, 4.5, 4.6, 4.6.1, NetStandard 1.6, NetStandard 2.0 and UWP applications (NetStandard 1.4)
Generate decorator
ProxyGenerator generator = new ProxyGenerator();
Calculator realInstance = new Calculator();
ICallableInterceptor interceptor = new CallableInterceptorAdapter((invocation) =>
{
Console.WriteLine(" Log: Call method {0}", invocation.MethodName);
try
{
invocation.Process();
Console.WriteLine(" Log: return: {0}", invocation.ReturnValue ?? "null");
}
catch(Exception ex)
{
Console.WriteLine(" Log: Exception message: {0}", ex.Message);
throw;
}
});
ICalculator decorator = generator.GenerateDecorator<ICalculator>(interceptor, realInstance);
Console.WriteLine("Before call Add with 2013 and 6");
int result = decorator.Add(2013, 6);
Console.WriteLine("Result is {0}", result);
Generate proxy
IInterceptor jsonRpcInterceptor = new InterceptorAdapter((invocation, isDynamic) =>
{
Guid requestId = Guid.NewGuid();
var rcpBody = new
{
jsonrpc = "2.0",
method = invocation.MethodName,
@params = invocation.Arguments,
id = requestId.ToString()
};
string serialized = Newtonsoft.Json.JsonConvert.SerializeObject(rcpBody);
//simulate sending and recrive
Console.WriteLine(" Sending Rpc: {0}", serialized);
string recText = $"{{\"jsonrpc\": \"2.0\", \"result\": 19, \"id\": \"{requestId.ToString()}\"}}";
Console.WriteLine(" Rec Rpc: {0}", recText);
Newtonsoft.Json.Linq.JObject response = Newtonsoft.Json.JsonConvert.DeserializeObject< Newtonsoft.Json.Linq.JObject>(recText);
invocation.ReturnValue = response["result"].ToObject(invocation.ReturnType);
});
ProxyGenerator generator = new ProxyGenerator();
ICalculator calcilator = generator.GenerateProxy<ICalculator>(jsonRpcInterceptor);
int resultModulo = calcilator.Modulo(15, 4);
Console.WriteLine("Modulo 15 and 4 is {0}", resultModulo);
int resultProduct = calcilator.Product(8, 486);
Console.WriteLine("Product 8 and 486 is {0}", resultProduct);
Generate instance proxy
IInstanceProvicer instanceProvider = new LazyInstanceProvider<ICalculator>(
() =>
{
Console.WriteLine(" Log: Create Calculator.");
return new Calculator();
}, false);
ProxyGenerator generator = new ProxyGenerator();
ICalculator calculator = generator.GenerateInstanceProxy<ICalculator>(instanceProvider);
Console.WriteLine("Before call Add with 2013 and 6");
int result = calculator.Add(2013, 6);
Console.WriteLine("Result is {0}", result);
Console.WriteLine("Before call Product with 2013 and 6");
int result2 = calculator.Product(2013, 6);
Console.WriteLine("Result is {0}", result2);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp1.0 was computed. netcoreapp1.1 was computed. netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard1.4 is compatible. netstandard1.5 was computed. netstandard1.6 is compatible. netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net40 is compatible. net403 was computed. net45 is compatible. net451 was computed. net452 was computed. net46 is compatible. net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen30 was computed. tizen40 was computed. tizen60 was computed. |
Universal Windows Platform | uap was computed. uap10.0 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.0
- No dependencies.
-
.NETFramework 4.5
- No dependencies.
-
.NETFramework 4.6
- No dependencies.
-
.NETFramework 4.6.1
- No dependencies.
-
.NETStandard 1.4
- NETStandard.Library (>= 1.6.0)
- System.Dynamic.Runtime (>= 4.3.0)
- System.Reflection.Emit (>= 4.3.0)
- System.Reflection.TypeExtensions (>= 4.3.0)
-
.NETStandard 1.6
- NETStandard.Library (>= 1.6.0)
- System.Dynamic.Runtime (>= 4.3.0)
- System.Reflection.Emit (>= 4.3.0)
-
.NETStandard 2.0
- System.Dynamic.Runtime (>= 4.3.0)
- System.Reflection.Emit (>= 4.3.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on MassiveDynamicProxyGenerator:
Package | Downloads |
---|---|
MassiveDynamicProxyGenerator.SimpleInjector
MassiveDynamicProxyGenerator.SimpleInjector is library of extensions method for IoC container - Simple Injector. Adding methods for register mock implementations, proxys, instance proxies for resolving circular depndencies or lazy initialization and interpetion for decoration instances. |
|
SoftAPIClient
A type-safe REST library |
|
MassiveDynamicProxyGenerator.Microsoft.DependencyInjection
MassiveDynamicProxyGenerator Microsoft.Extensions.DependencyInjection is intergration MassiveDynamicProxyGenerator to standard IoC container in ASP.NET Core. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.7.1 | 145 | 10/8/2024 |
1.7.0 | 677 | 11/15/2023 |
1.5.0 | 41,944 | 11/24/2020 |
1.4.0 | 10,436 | 8/27/2019 |
1.3.0 | 4,120 | 7/10/2018 |
1.3.0-preview1 | 1,697 | 5/8/2018 |
1.2.2 | 2,090 | 4/14/2018 |
1.2.1 | 2,029 | 8/21/2017 |
1.2.0 | 2,134 | 6/28/2017 |
1.2.0-beta1 | 1,766 | 6/13/2017 |
1.1.0 | 1,938 | 3/22/2017 |
1.0.0 | 1,990 | 12/1/2016 |
Change interface IInvocation.
Add universal async ibterceptor CallableInterceptorAsyncAdapter as abstract class for handle error in async task.
Add support for .Net Stdard 2.0.
Fix typo error ProxygGenerator -> ProxyGenerator.